id int64 0 1.29M | original_id stringlengths 32 32 | swhid stringlengths 100 170 | sha1 stringlengths 40 40 | repo_name stringlengths 2 45 | repo_group stringclasses 12
values | filepath stringlengths 5 153 | name stringlengths 1 14.9k | type stringclasses 3
values | code stringlengths 7 2.12M |
|---|---|---|---|---|---|---|---|---|---|
1,300 | 97dc5ed12248719b245670ad1346153d | swh:1:cnt:8757d5a62950e91c090d1957556892e3d7193053;origin=https://gitlab.wikimedia.org/repos/data-engineering/eventutilities-python.git;lines=47-57/ | 5eccad71aaf57ef31da4140ea9a3cef176fe73a0 | eventutilities-python | analytics | eventutilities_python/stream/functions.py | http_process_function::decorator::wrapper() | function | def wrapper():
http_session = requests.Session()
retries = Retry(
total=max_retries,
backoff_factor=retry_backoff_factor,
status_forcelist=retry_status_forcelist,
)
adapter = HTTPAdapter(max_retries=retries, pool_maxsize=poo... |
1,301 | c157b08d18ea9107c3146a83e1c352a8 | swh:1:cnt:164d5bb11978853d28a068d00e042a93e3ee58f9;origin=https://gitlab.wikimedia.org/repos/data-engineering/eventutilities-python.git;lines=167-188/ | ffdaa197c554ffd7f894cc1561d46c7e42ba6b10 | eventutilities-python | analytics | eventutilities_python/stream/manager.py | stream_manager::arg_parser(cls, parser: Optional[ArgumentParser] = None) | function | def arg_parser(cls, parser: Optional[ArgumentParser] = None) -> ArgumentParser:
"""Returns an ArgumentParser which can be used to auto instantiate a
stream_manager from CLI and/or config files. You can augment this
parser with your own CLI opts if you need to.
:param parser: If not give... |
1,302 | 7d12a41ccb202f39e9af2063a5e65022 | swh:1:cnt:164d5bb11978853d28a068d00e042a93e3ee58f9;origin=https://gitlab.wikimedia.org/repos/data-engineering/eventutilities-python.git;lines=250-359/ | ffdaa197c554ffd7f894cc1561d46c7e42ba6b10 | eventutilities-python | analytics | eventutilities_python/stream/manager.py | stream_manager::__init__(
self,
job_name: str,
source: SourceDescriptor,
sink: SinkDescriptor,
# NOTE: We'd prefer to just set error_sink = None, and/or
# support 'auto error sink stream' from a str, but
# using a Union/Optional type means that jsonargparse
... | function | def __init__(
self,
job_name: str,
source: SourceDescriptor,
sink: SinkDescriptor,
# NOTE: We'd prefer to just set error_sink = None, and/or
# support 'auto error sink stream' from a str, but
# using a Union/Optional type means that jsonargparse
# can't pr... |
1,303 | f197027ef8ad73616c57e06a75811795 | swh:1:cnt:164d5bb11978853d28a068d00e042a93e3ee58f9;origin=https://gitlab.wikimedia.org/repos/data-engineering/eventutilities-python.git;lines=430-431/ | ffdaa197c554ffd7f894cc1561d46c7e42ba6b10 | eventutilities-python | analytics | eventutilities_python/stream/manager.py | Stream::filter(self, func: Callable[[Any], Any], name: Optional[str] = None) | function | def filter(self, func: Callable[[Any], Any], name: Optional[str] = None) -> Any:
pass |
1,304 | b355fefd100556723e84dff2b2c5e41a | swh:1:cnt:164d5bb11978853d28a068d00e042a93e3ee58f9;origin=https://gitlab.wikimedia.org/repos/data-engineering/eventutilities-python.git;lines=438-439/ | ffdaa197c554ffd7f894cc1561d46c7e42ba6b10 | eventutilities-python | analytics | eventutilities_python/stream/manager.py | Stream::process(self, func: Callable[[Any], Any], name: Optional[str] = None) | function | def process(self, func: Callable[[Any], Any], name: Optional[str] = None) -> Any:
pass |
1,305 | 8c23dcf52844842dec5c27300140bcfe | swh:1:cnt:164d5bb11978853d28a068d00e042a93e3ee58f9;origin=https://gitlab.wikimedia.org/repos/data-engineering/eventutilities-python.git;lines=449-499/ | ffdaa197c554ffd7f894cc1561d46c7e42ba6b10 | eventutilities-python | analytics | eventutilities_python/stream/manager.py | FlinkStream::__init__(
self,
env: StreamExecutionEnvironment,
datastream_factory: EventDataStreamFactory,
job_name: str,
source_descriptor: SourceDescriptor,
sink_descriptor: SinkDescriptor,
error_sink_descriptor: Optional[SinkDescriptor] = None,
process_m... | function | def __init__(
self,
env: StreamExecutionEnvironment,
datastream_factory: EventDataStreamFactory,
job_name: str,
source_descriptor: SourceDescriptor,
sink_descriptor: SinkDescriptor,
error_sink_descriptor: Optional[SinkDescriptor] = None,
process_max_worker... |
1,306 | 9aa5ffb09e9d9980cef6bfb3e888c435 | swh:1:cnt:164d5bb11978853d28a068d00e042a93e3ee58f9;origin=https://gitlab.wikimedia.org/repos/data-engineering/eventutilities-python.git;lines=85-158/ | ffdaa197c554ffd7f894cc1561d46c7e42ba6b10 | eventutilities-python | analytics | eventutilities_python/stream/manager.py | load_config(
argv: Optional[List[str]] = None,
parser: Optional[ArgumentParser] = None,
defaults: Optional[Dict[Any, Any]] = None,
default_config_files: Optional[List[str]] = None,
) | function | def load_config(
argv: Optional[List[str]] = None,
parser: Optional[ArgumentParser] = None,
defaults: Optional[Dict[Any, Any]] = None,
default_config_files: Optional[List[str]] = None,
) -> Namespace:
"""Returns a jsonargparse Namespace object with all configured classes
instantiated from config... |
1,307 | 8d2dfc4d2a5e08d92077cf2211d08426 | swh:1:cnt:164d5bb11978853d28a068d00e042a93e3ee58f9;origin=https://gitlab.wikimedia.org/repos/data-engineering/eventutilities-python.git;lines=514-516/ | ffdaa197c554ffd7f894cc1561d46c7e42ba6b10 | eventutilities-python | analytics | eventutilities_python/stream/manager.py | FlinkStream::partition_by(self, func: Callable[[Any], Any]) | function | def partition_by(self, func: Callable[[Any], Any]) -> Self:
self.datastream = self.datastream.key_by(func)
return self |
1,308 | a408bb85e749663dde09f3b15062dc7e | swh:1:cnt:164d5bb11978853d28a068d00e042a93e3ee58f9;origin=https://gitlab.wikimedia.org/repos/data-engineering/eventutilities-python.git;lines=518-610/ | ffdaa197c554ffd7f894cc1561d46c7e42ba6b10 | eventutilities-python | analytics | eventutilities_python/stream/manager.py | FlinkStream::process(
self,
func: EventDictMapFunction,
name: Optional[str] = None,
async_enabled: Optional[bool] = None,
max_workers: Optional[int] = None,
batch_size: Optional[int] = None,
batch_duration_ms: Optional[int] = None,
) | function | def process(
self,
func: EventDictMapFunction,
name: Optional[str] = None,
async_enabled: Optional[bool] = None,
max_workers: Optional[int] = None,
batch_size: Optional[int] = None,
batch_duration_ms: Optional[int] = None,
) -> Self:
"""Applies a map f... |
1,309 | 0ac9327b30d1e48fb6d0643c869ada1b | swh:1:cnt:164d5bb11978853d28a068d00e042a93e3ee58f9;origin=https://gitlab.wikimedia.org/repos/data-engineering/eventutilities-python.git;lines=434-435/ | ffdaa197c554ffd7f894cc1561d46c7e42ba6b10 | eventutilities-python | analytics | eventutilities_python/stream/manager.py | Stream::partition_by(self, func: Callable[[Any], Any]) | function | def partition_by(self, func: Callable[[Any], Any]) -> Any:
pass |
1,310 | ee859c41775f9f8ced8512b5879efe3e | swh:1:cnt:164d5bb11978853d28a068d00e042a93e3ee58f9;origin=https://gitlab.wikimedia.org/repos/data-engineering/eventutilities-python.git;lines=1027-1046/ | ffdaa197c554ffd7f894cc1561d46c7e42ba6b10 | eventutilities-python | analytics | eventutilities_python/stream/manager.py | EventProcessFunction::process_element(
self,
event: EventDict,
ctx: KeyedProcessFunction.Context,
) | function | def process_element(
self,
event: EventDict,
ctx: KeyedProcessFunction.Context,
) -> Generator[Union[EventDict, Tuple[OutputTag, EventDict]], None, None]:
self.counter_metrics[self.metric_in_total_name].inc()
# -- Asynchronous mode
# Execute a batch of function calls... |
1,311 | 3e705c7d8b81d30b12a8929ef534e3b9 | swh:1:cnt:164d5bb11978853d28a068d00e042a93e3ee58f9;origin=https://gitlab.wikimedia.org/repos/data-engineering/eventutilities-python.git;lines=361-406/ | ffdaa197c554ffd7f894cc1561d46c7e42ba6b10 | eventutilities-python | analytics | eventutilities_python/stream/manager.py | stream_manager::__enter__(self) | function | def __enter__(self):
# Call get_flink_env() to ensure that
# eventutilities java deps are loaded in flink env at runtime.
self.flink_env = get_flink_env()
datastream_factory = EventDataStreamFactory.of(
self.schema_uris,
self.stream_config_uri,
self.ht... |
1,312 | 42a5c8633d79051dc3216f5f321b52da | swh:1:cnt:164d5bb11978853d28a068d00e042a93e3ee58f9;origin=https://gitlab.wikimedia.org/repos/data-engineering/eventutilities-python.git;lines=821-833/ | ffdaa197c554ffd7f894cc1561d46c7e42ba6b10 | eventutilities-python | analytics | eventutilities_python/stream/manager.py | EventProcessFunction::open(self, runtime_ctx: RuntimeContext) | function | def open(self, runtime_ctx: RuntimeContext) -> None:
self.init_metrics(runtime_ctx)
if self.async_enabled:
# Here a ThreadPoolExecutor is used because:
# 1. it does not require modifying the enrich function too much.
# 2. enrichment is I/O bound (we need to wait on sl... |
1,313 | be30412206997adb508f5d243458e57b | swh:1:cnt:164d5bb11978853d28a068d00e042a93e3ee58f9;origin=https://gitlab.wikimedia.org/repos/data-engineering/eventutilities-python.git;lines=839-880/ | ffdaa197c554ffd7f894cc1561d46c7e42ba6b10 | eventutilities-python | analytics | eventutilities_python/stream/manager.py | EventProcessFunction::_handle_process_error(
self,
e: Exception,
event: EventDict,
) | function | def _handle_process_error(
self,
e: Exception,
event: EventDict,
) -> Generator[Tuple[OutputTag, EventDict], None, None]:
"""Log the error, increment error counter metric, and if
error_output_tag is set, produce an error event to the error output tag
side output.
... |
1,314 | 5f3f6df3c55fe170826176c55ddb506c | swh:1:cnt:164d5bb11978853d28a068d00e042a93e3ee58f9;origin=https://gitlab.wikimedia.org/repos/data-engineering/eventutilities-python.git;lines=931-947/ | ffdaa197c554ffd7f894cc1561d46c7e42ba6b10 | eventutilities-python | analytics | eventutilities_python/stream/manager.py | EventProcessFunction::_close_batch(self) | function | def _close_batch(self) -> List[Tuple[Callable[[], EventDict], EventDict]]:
"""
Either `batch_size` records have been processed, or
`batch_duration_ms` as elapsed. The current batch can be closed.
Return pending list of result_suppliers and reset ``batch_future_result_suppliers``.
... |
1,315 | 537bc07f0b74ec8b5d1051282016ea80 | swh:1:cnt:164d5bb11978853d28a068d00e042a93e3ee58f9;origin=https://gitlab.wikimedia.org/repos/data-engineering/eventutilities-python.git;lines=974-984/ | ffdaa197c554ffd7f894cc1561d46c7e42ba6b10 | eventutilities-python | analytics | eventutilities_python/stream/manager.py | EventProcessFunction::_process_element_synchronous(
self,
event: EventDict,
) | function | def _process_element_synchronous(
self,
event: EventDict,
) -> Generator[Union[EventDict, Tuple[OutputTag, EventDict]], None, None]:
# Defensive check
assert not self.async_enabled, "_process_element_synchronous called but async_enabled=True."
# call _yield_results now with ... |
1,316 | efd957673c61112d8878ab303e12e63e | swh:1:cnt:164d5bb11978853d28a068d00e042a93e3ee58f9;origin=https://gitlab.wikimedia.org/repos/data-engineering/eventutilities-python.git;lines=408-414/ | ffdaa197c554ffd7f894cc1561d46c7e42ba6b10 | eventutilities-python | analytics | eventutilities_python/stream/manager.py | stream_manager::__exit__(self, exc_type, exc_value, tb) | function | def __exit__(self, exc_type, exc_value, tb):
self.flink_env.close()
if exc_value:
logging.error(exc_value)
traceback.print_tb(tb)
raise exc_value |
1,317 | 7d075184b7aaa5e9bb0a1999c2a8939a | swh:1:cnt:164d5bb11978853d28a068d00e042a93e3ee58f9;origin=https://gitlab.wikimedia.org/repos/data-engineering/eventutilities-python.git;lines=501-512/ | ffdaa197c554ffd7f894cc1561d46c7e42ba6b10 | eventutilities-python | analytics | eventutilities_python/stream/manager.py | FlinkStream::filter(self, func: EventDictFilterFunction, name: Optional[str] = None) | function | def filter(self, func: EventDictFilterFunction, name: Optional[str] = None) -> Self:
"""Applies a filter function to a datastream.
:param func: a Python Callable
:param name: Will be used as the Flink operator name and in metrics
:return:
"""
name = name or callable_repr... |
1,318 | 9af9b9a6e54a62149c49630461e0b5ac | swh:1:cnt:164d5bb11978853d28a068d00e042a93e3ee58f9;origin=https://gitlab.wikimedia.org/repos/data-engineering/eventutilities-python.git;lines=835-837/ | ffdaa197c554ffd7f894cc1561d46c7e42ba6b10 | eventutilities-python | analytics | eventutilities_python/stream/manager.py | EventProcessFunction::close(self) | function | def close(self) -> None:
if self.executor is not None:
self.executor.shutdown() |
1,319 | ef2322b9c591786a2ec61da5f549be98 | swh:1:cnt:164d5bb11978853d28a068d00e042a93e3ee58f9;origin=https://gitlab.wikimedia.org/repos/data-engineering/eventutilities-python.git;lines=882-929/ | ffdaa197c554ffd7f894cc1561d46c7e42ba6b10 | eventutilities-python | analytics | eventutilities_python/stream/manager.py | EventProcessFunction::_yield_results(
self,
result_suppliers: List[Tuple["Callable[[], EventDict]", EventDict]],
) | function | def _yield_results(
self,
result_suppliers: List[Tuple["Callable[[], EventDict]", EventDict]],
) -> Generator[Union[EventDict, Tuple[OutputTag, EventDict]], None, None]:
"""
Sequentially iterates over result_suppliers and calls each one to get the result.
Yields each result a... |
1,320 | b255eb454868f9c180205f23ca135aec | swh:1:cnt:164d5bb11978853d28a068d00e042a93e3ee58f9;origin=https://gitlab.wikimedia.org/repos/data-engineering/eventutilities-python.git;lines=949-971/ | ffdaa197c554ffd7f894cc1561d46c7e42ba6b10 | eventutilities-python | analytics | eventutilities_python/stream/manager.py | EventProcessFunction::on_timer(
self,
timestamp: int,
ctx: "KeyedProcessFunction.OnTimerContext",
) | function | def on_timer(
self,
timestamp: int,
ctx: "KeyedProcessFunction.OnTimerContext",
) -> Generator[Union[EventDict, Tuple[OutputTag, EventDict]], None, None]:
"""
Called when a processing-time timer fires for an async minibatch.
NOTE: When ``async_enabled`` is False, ret... |
1,321 | d4abc4e277ab878793a40c7b5f9c3f8a | swh:1:cnt:164d5bb11978853d28a068d00e042a93e3ee58f9;origin=https://gitlab.wikimedia.org/repos/data-engineering/eventutilities-python.git;lines=986-1024/ | ffdaa197c554ffd7f894cc1561d46c7e42ba6b10 | eventutilities-python | analytics | eventutilities_python/stream/manager.py | EventProcessFunction::_process_element_asynchronous(
self,
event: EventDict,
ctx: KeyedProcessFunction.Context,
) | function | def _process_element_asynchronous(
self,
event: EventDict,
ctx: KeyedProcessFunction.Context,
) -> Generator[Union[EventDict, Tuple[OutputTag, EventDict]], None, None]:
# Defensive checks
assert self.async_enabled, "_process_element_asynchronous called but async_enabled=False... |
1,322 | 3157dcfd556cf1592048ba090f7be016 | swh:1:cnt:164d5bb11978853d28a068d00e042a93e3ee58f9;origin=https://gitlab.wikimedia.org/repos/data-engineering/eventutilities-python.git;lines=713-783/ | ffdaa197c554ffd7f894cc1561d46c7e42ba6b10 | eventutilities-python | analytics | eventutilities_python/stream/manager.py | EventProcessFunction::__init__(
self,
func: EventDictMapFunction,
name: str,
emitter_id: str,
error_output_tag: Optional[OutputTag] = None,
max_workers: int = 12,
batch_size: int = 12,
batch_duration_ms: int = 60 * 2 * 1000,
async_enabled: bool = T... | function | # NOTE: we also emit memory_{mem_info_key}_bytes
# Latest value of memory bytes used. Data is provided by
# psutil.Process().memory_full_info(), so actual
# metrics emitted will match the keys for whatever that returns.
def __init__(
self,
func: EventDictMapFunction,
name: str,
... |
1,323 | 51f566fcd6ddd645252c1d9659a839a8 | swh:1:cnt:164d5bb11978853d28a068d00e042a93e3ee58f9;origin=https://gitlab.wikimedia.org/repos/data-engineering/eventutilities-python.git;lines=785-819/ | ffdaa197c554ffd7f894cc1561d46c7e42ba6b10 | eventutilities-python | analytics | eventutilities_python/stream/manager.py | EventProcessFunction::init_metrics(self, runtime_ctx: RuntimeContext) | function | def init_metrics(self, runtime_ctx: RuntimeContext) -> None:
"""Initialize Flink metrics for this ProcessFunction."""
# In Prometheus, this will make metrics like:
# flink_taskmanager_job_task_operator_event_process_function_<metric_name>
# {event_process_function=<self.name>, ... }
... |
1,324 | e713d8fd32b103d4021b391fc6603b0b | swh:1:cnt:164d5bb11978853d28a068d00e042a93e3ee58f9;origin=https://gitlab.wikimedia.org/repos/data-engineering/eventutilities-python.git;lines=243-248/ | ffdaa197c554ffd7f894cc1561d46c7e42ba6b10 | eventutilities-python | analytics | eventutilities_python/stream/manager.py | stream_manager::check_valid_stream_version(stream_descriptor: EventStreamDescriptor) | function | def check_valid_stream_version(stream_descriptor: EventStreamDescriptor) -> None:
if not stream_descriptor.is_version_pinned():
raise ValueError(
f"{stream_descriptor} - 'latest' is not a valid version."
"An event version must be declared as $major.$minor.$patch"
... |
1,325 | fcb41b754ecca69dfbd1c3ed08de0a56 | swh:1:cnt:164d5bb11978853d28a068d00e042a93e3ee58f9;origin=https://gitlab.wikimedia.org/repos/data-engineering/eventutilities-python.git;lines=191-240/ | ffdaa197c554ffd7f894cc1561d46c7e42ba6b10 | eventutilities-python | analytics | eventutilities_python/stream/manager.py | stream_manager::from_config(cls, config: Namespace) | function | def from_config(cls, config: Namespace) -> "stream_manager":
"""Instantiate stream_manager with a jsonargparsed config Namespace
(with instantiated dataclass params).
Example:
>>> stream_manager.from_config(stream_manager.arg_parser())
or more generally:
>>> ... |
1,326 | 1c89482876a298d395c0e3c0692fb2ef | swh:1:cnt:164d5bb11978853d28a068d00e042a93e3ee58f9;origin=https://gitlab.wikimedia.org/repos/data-engineering/eventutilities-python.git;lines=416-420/ | ffdaa197c554ffd7f894cc1561d46c7e42ba6b10 | eventutilities-python | analytics | eventutilities_python/stream/manager.py | stream_manager::__str__(self) | function | def __str__(self):
return (
f"{self.__class__.__name__} {self.job_name}: "
f"{self.source_descriptor} -> {self.sink_descriptor}"
) |
1,327 | ee1074015313ac42f9171de9d764159b | swh:1:cnt:164d5bb11978853d28a068d00e042a93e3ee58f9;origin=https://gitlab.wikimedia.org/repos/data-engineering/eventutilities-python.git;lines=442-443/ | ffdaa197c554ffd7f894cc1561d46c7e42ba6b10 | eventutilities-python | analytics | eventutilities_python/stream/manager.py | Stream::execute(self) | function | def execute(self) -> Any:
pass |
1,328 | d758c0a43b10aa0dba8e6905911543f7 | swh:1:cnt:164d5bb11978853d28a068d00e042a93e3ee58f9;origin=https://gitlab.wikimedia.org/repos/data-engineering/eventutilities-python.git;lines=612-633/ | ffdaa197c554ffd7f894cc1561d46c7e42ba6b10 | eventutilities-python | analytics | eventutilities_python/stream/manager.py | FlinkStream::execute(self, collect: bool = False) | function | def execute(self, collect: bool = False) -> Optional[Union[CloseableIterator, List[Row]]]:
"""Triggers the program execution.
:param collect: If True, data_stream.execute_and_collect() will
be returned, otherwise the pipeline will
just be executed.
:r... |
1,329 | c4b9eb2412516bd18d843dd3b123cbb1 | swh:1:cnt:164d5bb11978853d28a068d00e042a93e3ee58f9;origin=https://gitlab.wikimedia.org/repos/data-engineering/eventutilities-python.git;lines=161-420/ | ffdaa197c554ffd7f894cc1561d46c7e42ba6b10 | eventutilities-python | analytics | eventutilities_python/stream/manager.py | stream_manager | type | class stream_manager:
argparse_namespace: str = "stream_manager"
"""Prefix namespace key in which arg_parser expects stream_manager
configs.."""
@classmethod
def arg_parser(cls, parser: Optional[ArgumentParser] = None) -> ArgumentParser:
"""Returns an ArgumentParser which can be used to aut... |
1,330 | 7f5ea8d9f3a46c536b8641396cc0ba83 | swh:1:cnt:164d5bb11978853d28a068d00e042a93e3ee58f9;origin=https://gitlab.wikimedia.org/repos/data-engineering/eventutilities-python.git;lines=423-443/ | ffdaa197c554ffd7f894cc1561d46c7e42ba6b10 | eventutilities-python | analytics | eventutilities_python/stream/manager.py | Stream | type | class Stream(ABC):
"""Stream is an interface that implies operations on a datastream.
It defines the API contract with users of eventutilities-python.
"""
@abstractmethod
def filter(self, func: Callable[[Any], Any], name: Optional[str] = None) -> Any:
pass
@abstractmethod
def part... |
1,331 | ddc73434745d264791f097501301031e | swh:1:cnt:164d5bb11978853d28a068d00e042a93e3ee58f9;origin=https://gitlab.wikimedia.org/repos/data-engineering/eventutilities-python.git;lines=446-633/ | ffdaa197c554ffd7f894cc1561d46c7e42ba6b10 | eventutilities-python | analytics | eventutilities_python/stream/manager.py | FlinkStream | type | class FlinkStream(Stream):
"""An Apache Flink Event Platform stream pipeline builder."""
def __init__(
self,
env: StreamExecutionEnvironment,
datastream_factory: EventDataStreamFactory,
job_name: str,
source_descriptor: SourceDescriptor,
sink_descriptor: SinkDesc... |
1,332 | e0fd2965460ecd559a8cf5bc74bdb0de | swh:1:cnt:164d5bb11978853d28a068d00e042a93e3ee58f9;origin=https://gitlab.wikimedia.org/repos/data-engineering/eventutilities-python.git;lines=636-1046/ | ffdaa197c554ffd7f894cc1561d46c7e42ba6b10 | eventutilities-python | analytics | eventutilities_python/stream/manager.py | EventProcessFunction | type | class EventProcessFunction(KeyedProcessFunction):
"""
A ProcessFunction that:
- Calls a user provided function, expected to take a single event dict,
and return a transformed event dict.
- In asynchronous mode (default), implements a thread pool on a minibatch to allow
concurrent function ... |
1,333 | bd6e893d2bf9f363757495fc0aee51ae | swh:1:cnt:dbec09e890f31407e3167074789a6c29d7f461a7;origin=https://gitlab.wikimedia.org/repos/data-engineering/eventutilities-python.git;lines=9-34/ | 993535a040aeef2ce66adbc62883380be3b89711 | eventutilities-python | analytics | eventutilities_python/testing/utils.py | read_records_from_flink_row_file_sink(sink: Union[str, SinkDescriptor]) | function | def read_records_from_flink_row_file_sink(sink: Union[str, SinkDescriptor]) -> List[EventDict]:
"""A helper function for reading JSON records out of a local output path
that a Flink sink has written to. Useful for testing the results of a data
pipeline after the Sink has written results.
:param sink: E... |
1,334 | 82bbfd8f2bebf0771a0aaaee6503b8bb | swh:1:cnt:dbec09e890f31407e3167074789a6c29d7f461a7;origin=https://gitlab.wikimedia.org/repos/data-engineering/eventutilities-python.git;lines=37-54/ | 993535a040aeef2ce66adbc62883380be3b89711 | eventutilities-python | analytics | eventutilities_python/testing/utils.py | assert_error_event(
record,
expected_error_message,
expected_stream_name,
expected_schema_uri,
expected_error_type
) | function | def assert_error_event(
record,
expected_error_message,
expected_stream_name,
expected_schema_uri,
expected_error_type
):
"""Lil' helper to assert that an error event looks like it should."""
assert record["message"] == expected_error_message, "error event should have error message"
asse... |
1,335 | ac85be55a564590db3c89ac9ff916712 | swh:1:cnt:e7ce117c573e1e31a40c446833aa0eff981968d1;origin=https://gitlab.wikimedia.org/repos/data-engineering/eventutilities-python.git;lines=62-83/ | 05eff28c5f7e9ebd2e843a185ef9f1a8a7dfb5dd | eventutilities-python | analytics | tests/test_data_loading.py | test_from_files(
flink_env,
flink_datastream_factory,
test_event_example_files,
test_event_example,
) | function | def test_from_files(
flink_env,
flink_datastream_factory,
test_event_example_files,
test_event_example,
):
"""
Test data event data can be loaded and deserialised from files.
"""
source = flink_datastream_factory.file_source(
stream_name=test_event_example.name,
uris=test... |
1,336 | e00e6ba5244118ca9f435e767a281a58 | swh:1:cnt:e7ce117c573e1e31a40c446833aa0eff981968d1;origin=https://gitlab.wikimedia.org/repos/data-engineering/eventutilities-python.git;lines=55-59/ | 05eff28c5f7e9ebd2e843a185ef9f1a8a7dfb5dd | eventutilities-python | analytics | tests/test_data_loading.py | execute_and_compare(datastream, expected) | function | def execute_and_compare(datastream, expected):
results = list(datastream.execute_and_collect())
assert len(results) == len(expected)
assert all(results)
assert all(list(x in results for x in expected)) |
1,337 | 484633392cc88bf46d906edb2e8eee56 | swh:1:cnt:e7ce117c573e1e31a40c446833aa0eff981968d1;origin=https://gitlab.wikimedia.org/repos/data-engineering/eventutilities-python.git;lines=110-168/ | 05eff28c5f7e9ebd2e843a185ef9f1a8a7dfb5dd | eventutilities-python | analytics | tests/test_data_loading.py | test_row_file_sink(
tmp_path,
flink_env,
flink_datastream_factory,
test_event_example_files,
test_event_example,
) | function | def test_row_file_sink(
tmp_path,
flink_env,
flink_datastream_factory,
test_event_example_files,
test_event_example,
):
"""
Test that a datastream can be serialized through the eventutilities-flink
JsonRowSerializationSchema -> JsonEventGenerator by writing
the data into a row record... |
1,338 | 8b970ecab1f7902fab1cc12159f49778 | swh:1:cnt:e7ce117c573e1e31a40c446833aa0eff981968d1;origin=https://gitlab.wikimedia.org/repos/data-engineering/eventutilities-python.git;lines=133-141/ | 05eff28c5f7e9ebd2e843a185ef9f1a8a7dfb5dd | eventutilities-python | analytics | tests/test_data_loading.py | test_row_file_sink::transform(e) | function | # convert to dict for ease of comparison
def transform(e):
e["test"] = "transformed by test"
# Delete meta.dt and meta.stream to be sure it
# is set by the JsonEventGenerator serialization.
del e["meta"]["dt"]
del e["meta"]["stream"]
return e |
1,339 | 56d43930a2ff8b45acc91430985a8b99 | swh:1:cnt:e7ce117c573e1e31a40c446833aa0eff981968d1;origin=https://gitlab.wikimedia.org/repos/data-engineering/eventutilities-python.git;lines=86-107/ | 05eff28c5f7e9ebd2e843a185ef9f1a8a7dfb5dd | eventutilities-python | analytics | tests/test_data_loading.py | test_from_data(
flink_env,
flink_datastream_factory,
test_event_example_data,
test_event_example,
) | function | def test_from_data(
flink_env,
flink_datastream_factory,
test_event_example_data,
test_event_example,
):
"""
Test that event data can be loaded and deserialised from a collection of dictionaries.
"""
source = flink_datastream_factory.collection_source(
stream_name=test_event_exam... |
1,340 | 0047f7154ce1b3592deb8e5bfc7edace | swh:1:cnt:3af8fe9bf09f403f15142eadf4a82906be44f99e;origin=https://gitlab.wikimedia.org/repos/data-engineering/eventutilities-python.git;lines=110-112/ | aa256b3ce195190714bdc3f782b82e79b39a73a2 | eventutilities-python | analytics | tests/test_flink.py | test_instant_to_datetime() | function | def test_instant_to_datetime():
converted_dt = instant_to_datetime(fixture_instant)
assert converted_dt == fixture_dt |
1,341 | 634730b00f5a4778f03b447265316a64 | swh:1:cnt:3af8fe9bf09f403f15142eadf4a82906be44f99e;origin=https://gitlab.wikimedia.org/repos/data-engineering/eventutilities-python.git;lines=120-123/ | aa256b3ce195190714bdc3f782b82e79b39a73a2 | eventutilities-python | analytics | tests/test_flink.py | test_convert_pyflink_to_python(row_fixture, dict_record_fixture) | function | def test_convert_pyflink_to_python(row_fixture, dict_record_fixture):
result = convert_pyflink_to_python(row_fixture)
assert result == dict_record_fixture.record_dict |
1,342 | 85b3c375bc402f3fbfb2cb919fcad16a | swh:1:cnt:3af8fe9bf09f403f15142eadf4a82906be44f99e;origin=https://gitlab.wikimedia.org/repos/data-engineering/eventutilities-python.git;lines=137-141/ | aa256b3ce195190714bdc3f782b82e79b39a73a2 | eventutilities-python | analytics | tests/test_flink.py | test_pyflink_python_conversion_roundtrip(row_fixture, dict_record_fixture) | function | def test_pyflink_python_conversion_roundtrip(row_fixture, dict_record_fixture):
row = convert_python_to_pyflink(
convert_pyflink_to_python(row_fixture), dict_record_fixture.type_info
)
assert row == row_fixture |
1,343 | 1c09eb6746c49ea0f27086b4c8befdb7 | swh:1:cnt:3af8fe9bf09f403f15142eadf4a82906be44f99e;origin=https://gitlab.wikimedia.org/repos/data-engineering/eventutilities-python.git;lines=162-182/ | aa256b3ce195190714bdc3f782b82e79b39a73a2 | eventutilities-python | analytics | tests/test_flink.py | test_http_client_routes(fixture_schema_uris, fixture_stream_config_uri) | function | def test_http_client_routes(fixture_schema_uris, fixture_stream_config_uri):
http_client_routes = {}
datastream_factory = EventDataStreamFactory.of(
fixture_schema_uris.split(","), fixture_stream_config_uri, http_client_routes
)
assert datastream_factory
# Test that an EventStreamFactory ca... |
1,344 | 5c43d174d1e3ab0ef3cc2cfcaefd1293 | swh:1:cnt:3af8fe9bf09f403f15142eadf4a82906be44f99e;origin=https://gitlab.wikimedia.org/repos/data-engineering/eventutilities-python.git;lines=207-220/ | aa256b3ce195190714bdc3f782b82e79b39a73a2 | eventutilities-python | analytics | tests/test_flink.py | test_event_row_type_info_conversion() | function | def test_event_row_type_info_conversion():
JEventRowTypeInfo = flink_jvm().org.wikimedia.eventutilities.flink.EventRowTypeInfo
nested_row_type_info = Types.ROW([Types.INT(), Types.STRING()])
row_type_info = Types.ROW([nested_row_type_info])
# We should be able to handle nested EventRowTypeInfo objects... |
1,345 | 9170ede4159d9b15a1cb1de3173cc4e5 | swh:1:cnt:3af8fe9bf09f403f15142eadf4a82906be44f99e;origin=https://gitlab.wikimedia.org/repos/data-engineering/eventutilities-python.git;lines=236-264/ | aa256b3ce195190714bdc3f782b82e79b39a73a2 | eventutilities-python | analytics | tests/test_flink.py | test_keyed_stream_config(
fixture_schema_uris,
fixture_stream_config_uri,
test_event_example_keyed
) | function | # Check that a keyed stream configuration is properly initialized in the
# wrapped java code. eventutilities_python does not access key information directly,
# but under the hood it will be propagated to KafkaSink (in the wrapped Java code path).
# This test is minimal, and has been introduced only to ensure the right ... |
1,346 | 82323df6db000265a7ec6d4c3f6ec350 | swh:1:cnt:3af8fe9bf09f403f15142eadf4a82906be44f99e;origin=https://gitlab.wikimedia.org/repos/data-engineering/eventutilities-python.git;lines=33-74/ | aa256b3ce195190714bdc3f782b82e79b39a73a2 | eventutilities-python | analytics | tests/test_flink.py | dict_record_fixture() | function | def dict_record_fixture() -> DictWithTypeInfo:
type_info = Types.ROW_NAMED(
[
"str_field",
"nested",
"array_str_field",
"array_dt_field",
"other",
"array_obj_field",
"tuple_field",
],
[
Types.STRI... |
1,347 | e090f3d4b79b5d4450097be44201190d | swh:1:cnt:3af8fe9bf09f403f15142eadf4a82906be44f99e;origin=https://gitlab.wikimedia.org/repos/data-engineering/eventutilities-python.git;lines=78-92/ | aa256b3ce195190714bdc3f782b82e79b39a73a2 | eventutilities-python | analytics | tests/test_flink.py | row_fixture() | function | def row_fixture() -> Row:
return Row(
**{
"str_field": "str value",
"nested": Row(**{"f1": "f1 value", "dt": fixture_instant}),
"array_str_field": ["v1", "v2"],
"array_dt_field": [fixture_instant],
"other": None,
"array_obj_field": [
... |
1,348 | 19e9a6d62276c5e4563a61c09be12573 | swh:1:cnt:3af8fe9bf09f403f15142eadf4a82906be44f99e;origin=https://gitlab.wikimedia.org/repos/data-engineering/eventutilities-python.git;lines=95-107/ | aa256b3ce195190714bdc3f782b82e79b39a73a2 | eventutilities-python | analytics | tests/test_flink.py | is_event_row_type_info(j_type_info: JavaObject) | function | def is_event_row_type_info(j_type_info: JavaObject) -> bool:
"""
Check whether a Java TypeInfo object is an
org.wikimedia.eventutilities.flink.EventRowTypeInfo.
:param j_type_info:any Java TypeInfo object.
:return:
"""
JEventRowTypeInfo = flink_jvm().org.wikimedia.eventutilities.flink.Event... |
1,349 | f8e2641e427204db7105c18bf2e91188 | swh:1:cnt:3af8fe9bf09f403f15142eadf4a82906be44f99e;origin=https://gitlab.wikimedia.org/repos/data-engineering/eventutilities-python.git;lines=115-117/ | aa256b3ce195190714bdc3f782b82e79b39a73a2 | eventutilities-python | analytics | tests/test_flink.py | test_datetime_to_instant() | function | def test_datetime_to_instant():
converted_instant = datetime_to_instant(fixture_dt)
assert converted_instant == fixture_instant |
1,350 | 9df7f132d585fbb4cb7c5eceb66f2fb8 | swh:1:cnt:3af8fe9bf09f403f15142eadf4a82906be44f99e;origin=https://gitlab.wikimedia.org/repos/data-engineering/eventutilities-python.git;lines=126-134/ | aa256b3ce195190714bdc3f782b82e79b39a73a2 | eventutilities-python | analytics | tests/test_flink.py | test_convert_python_to_pyflink(dict_record_fixture, row_fixture) | function | def test_convert_python_to_pyflink(dict_record_fixture, row_fixture):
"""
Test conversion from a Python dict to a Flink Row.
"""
record_row = convert_python_to_pyflink(
dict_record_fixture.record_dict, dict_record_fixture.type_info
)
assert record_row == row_fixture |
1,351 | 96e60b13a8066913d95958e9ba9d2d3d | swh:1:cnt:3af8fe9bf09f403f15142eadf4a82906be44f99e;origin=https://gitlab.wikimedia.org/repos/data-engineering/eventutilities-python.git;lines=144-159/ | aa256b3ce195190714bdc3f782b82e79b39a73a2 | eventutilities-python | analytics | tests/test_flink.py | test_dict_datastream_to_row(dict_record_fixture, row_fixture) | function | def test_dict_datastream_to_row(dict_record_fixture, row_fixture):
"""
Test conversion from a DataStream of dictionaries to a DataStream
of Rows.
"""
env = StreamExecutionEnvironment.get_execution_environment()
datastream = (
env.from_collection(
[dict_record_fixture.record_d... |
1,352 | 709073a586f054853d583ac5e72e34b2 | swh:1:cnt:3af8fe9bf09f403f15142eadf4a82906be44f99e;origin=https://gitlab.wikimedia.org/repos/data-engineering/eventutilities-python.git;lines=185-204/ | aa256b3ce195190714bdc3f782b82e79b39a73a2 | eventutilities-python | analytics | tests/test_flink.py | test_invalid_http_client_routes(fixture_schema_uris) | function | def test_invalid_http_client_routes(fixture_schema_uris):
# If we try to route to meta via a non-existing URI, an exception will be raised.
# [...]
# Request to uri
# http://some.config.uri.mock/w/api.php?format=json&action=streamconfigs&all_settings=true
# failed.
# BasicHttpResult(failure) ... |
1,353 | 37cf83e0529964a243d6ef6c6875a865 | swh:1:cnt:3af8fe9bf09f403f15142eadf4a82906be44f99e;origin=https://gitlab.wikimedia.org/repos/data-engineering/eventutilities-python.git;lines=223-233/ | aa256b3ce195190714bdc3f782b82e79b39a73a2 | eventutilities-python | analytics | tests/test_flink.py | test_kafka_sink_delivery_guarantee(flink_env, flink_datastream_factory, test_event_example) | function | def test_kafka_sink_delivery_guarantee(flink_env, flink_datastream_factory, test_event_example):
with pytest.raises(ValueError):
flink_datastream_factory.kafka_sink(
stream_name=test_event_example.name,
schema_version=test_event_example.version,
bootstrap_servers="test-br... |
1,354 | 57720fa5c25d18c7e07a067108071971 | swh:1:cnt:11c96a7c2337362f26e287895c06ebeddbd990ab;origin=https://gitlab.wikimedia.org/repos/data-engineering/eventutilities-python.git;lines=13-15/ | 040af11780bc0c4272e1a9d08c24c66c732b8369 | eventutilities-python | analytics | tests/test_stream_descriptor.py | test_stream_descriptor_schema_default_version() | function | def test_stream_descriptor_schema_default_version():
stream_descriptor = EventStreamDescriptor(name="test.event.stream")
assert stream_descriptor.version == "latest" |
1,355 | 7fec5fb69f2c6118ed9ce43b4a3b44df | swh:1:cnt:11c96a7c2337362f26e287895c06ebeddbd990ab;origin=https://gitlab.wikimedia.org/repos/data-engineering/eventutilities-python.git;lines=41-52/ | 040af11780bc0c4272e1a9d08c24c66c732b8369 | eventutilities-python | analytics | tests/test_stream_descriptor.py | test_source_descriptor_parallelism_defaults_to_none() | function | # --- ConnectorDescriptor.parallelism ---
# NOTE: These test were written with assistance
# from an AI coding agent (Composer — Cursor 1.5).
def test_source_descriptor_parallelism_defaults_to_none():
desc = SourceDescriptor(
connector="file",
stream="test.event.example:1.1.0",
option... |
1,356 | e47131cec60afdd2ae6834cd5ea33fb1 | swh:1:cnt:11c96a7c2337362f26e287895c06ebeddbd990ab;origin=https://gitlab.wikimedia.org/repos/data-engineering/eventutilities-python.git;lines=28-38/ | 040af11780bc0c4272e1a9d08c24c66c732b8369 | eventutilities-python | analytics | tests/test_stream_descriptor.py | test_invalid_stream_descriptor() | function | def test_invalid_stream_descriptor():
with pytest.raises(ValueError):
EventStreamDescriptor.from_string(None)
# Schema version is required.
with pytest.raises(ValueError):
EventStreamDescriptor.from_string("test.event.stream")
# Invalid input. Name is missing.
with pytest.raises(Va... |
1,357 | cd1448c26023e7ba9774c59720ecf603 | swh:1:cnt:11c96a7c2337362f26e287895c06ebeddbd990ab;origin=https://gitlab.wikimedia.org/repos/data-engineering/eventutilities-python.git;lines=55-62/ | 040af11780bc0c4272e1a9d08c24c66c732b8369 | eventutilities-python | analytics | tests/test_stream_descriptor.py | test_source_descriptor_parallelism_explicit() | function | def test_source_descriptor_parallelism_explicit():
desc = SourceDescriptor(
connector="file",
stream="test.event.example:1.1.0",
options={"uris": []},
parallelism=8,
)
assert desc.parallelism == 8 |
1,358 | 72427a1ee3dd98a6b35b1531cb2c7ed0 | swh:1:cnt:11c96a7c2337362f26e287895c06ebeddbd990ab;origin=https://gitlab.wikimedia.org/repos/data-engineering/eventutilities-python.git;lines=74-81/ | 040af11780bc0c4272e1a9d08c24c66c732b8369 | eventutilities-python | analytics | tests/test_stream_descriptor.py | test_sink_descriptor_parallelism_explicit() | function | def test_sink_descriptor_parallelism_explicit():
desc = SinkDescriptor(
connector="file",
stream="test.event.example:1.1.0",
options={"uri": "file:///tmp/out"},
parallelism=4,
)
assert desc.parallelism == 4 |
1,359 | f5b996cfdb9fe2046894369f93add535 | swh:1:cnt:11c96a7c2337362f26e287895c06ebeddbd990ab;origin=https://gitlab.wikimedia.org/repos/data-engineering/eventutilities-python.git;lines=104-120/ | 040af11780bc0c4272e1a9d08c24c66c732b8369 | eventutilities-python | analytics | tests/test_stream_descriptor.py | test_source_descriptor_datastream_skips_set_parallelism_when_none() | function | def test_source_descriptor_datastream_skips_set_parallelism_when_none():
desc = SourceDescriptor(
connector="file",
stream="test.event.example:1.1.0",
options={"uris": []},
)
mock_after_name = MagicMock()
mock_from_source_chain = MagicMock()
mock_from_source_chain.name.return... |
1,360 | 264262c0567141dafe3c6b500404d6fb | swh:1:cnt:11c96a7c2337362f26e287895c06ebeddbd990ab;origin=https://gitlab.wikimedia.org/repos/data-engineering/eventutilities-python.git;lines=18-25/ | 040af11780bc0c4272e1a9d08c24c66c732b8369 | eventutilities-python | analytics | tests/test_stream_descriptor.py | test_stream_descriptor_parsing() | function | def test_stream_descriptor_parsing():
stream_descriptor = EventStreamDescriptor.from_string("test.event.stream:1.1.0")
assert stream_descriptor.name == "test.event.stream"
assert stream_descriptor.version == "1.1.0"
stream_descriptor = EventStreamDescriptor.from_string("test.event.stream:latest")
a... |
1,361 | 9f6037aa4c34c351d7fb32fb7f9b328e | swh:1:cnt:11c96a7c2337362f26e287895c06ebeddbd990ab;origin=https://gitlab.wikimedia.org/repos/data-engineering/eventutilities-python.git;lines=65-71/ | 040af11780bc0c4272e1a9d08c24c66c732b8369 | eventutilities-python | analytics | tests/test_stream_descriptor.py | test_sink_descriptor_parallelism_defaults_to_none() | function | def test_sink_descriptor_parallelism_defaults_to_none():
desc = SinkDescriptor(
connector="file",
stream="test.event.example:1.1.0",
options={"uri": "file:///tmp/out"},
)
assert desc.parallelism is None |
1,362 | 3bad5a759e7c5ff293e9839d7cc79f34 | swh:1:cnt:11c96a7c2337362f26e287895c06ebeddbd990ab;origin=https://gitlab.wikimedia.org/repos/data-engineering/eventutilities-python.git;lines=84-101/ | 040af11780bc0c4272e1a9d08c24c66c732b8369 | eventutilities-python | analytics | tests/test_stream_descriptor.py | test_source_descriptor_datastream_applies_parallelism_when_set() | function | def test_source_descriptor_datastream_applies_parallelism_when_set():
desc = SourceDescriptor(
connector="file",
stream="test.event.example:1.1.0",
options={"uris": []},
parallelism=3,
)
mock_after_name = MagicMock()
mock_from_source_chain = MagicMock()
mock_from_sour... |
1,363 | eaac2140e1832ae1601468d4f916850e | swh:1:cnt:11c96a7c2337362f26e287895c06ebeddbd990ab;origin=https://gitlab.wikimedia.org/repos/data-engineering/eventutilities-python.git;lines=123-141/ | 040af11780bc0c4272e1a9d08c24c66c732b8369 | eventutilities-python | analytics | tests/test_stream_descriptor.py | test_sink_descriptor_sink_to_applies_parallelism_when_set() | function | def test_sink_descriptor_sink_to_applies_parallelism_when_set():
desc = SinkDescriptor(
connector="file",
stream="test.event.example:1.1.0",
options={"uri": "file:///tmp/out"},
parallelism=7,
)
fake_sink = Sink(MagicMock())
datastream = MagicMock()
after_sink_to = Mag... |
1,364 | b4b27f428e7d446969562f23603ba659 | swh:1:cnt:11c96a7c2337362f26e287895c06ebeddbd990ab;origin=https://gitlab.wikimedia.org/repos/data-engineering/eventutilities-python.git;lines=144-161/ | 040af11780bc0c4272e1a9d08c24c66c732b8369 | eventutilities-python | analytics | tests/test_stream_descriptor.py | test_sink_descriptor_sink_to_skips_set_parallelism_when_none() | function | def test_sink_descriptor_sink_to_skips_set_parallelism_when_none():
desc = SinkDescriptor(
connector="file",
stream="test.event.example:1.1.0",
options={"uri": "file:///tmp/out"},
)
fake_sink = Sink(MagicMock())
datastream = MagicMock()
after_sink_to = MagicMock()
after_n... |
1,365 | 632bfc84ba1b7510aa4d66ac84d6438c | swh:1:cnt:972bb8e27faadb3b959ff5c49e7189db10d9df64;origin=https://gitlab.wikimedia.org/repos/data-engineering/eventutilities-python.git;lines=21-48/ | f7f411402647e5c7ae9dc706b7da9259a3abe332 | eventutilities-python | analytics | tests/test_stream_manager.py | test_flink_stream_manager_init(
fixture_schema_uris,
fixture_stream_config_uri,
source_descriptor_file_test_event_example,
test_event_enriched,
) | function | def test_flink_stream_manager_init(
fixture_schema_uris,
fixture_stream_config_uri,
source_descriptor_file_test_event_example,
test_event_enriched,
):
"""
Initialise a stream.
It is expected that source and sink schemas are resolved, and source / sink are
instantiated.
"""
manage... |
1,366 | 516b36b3e1712c50927b18a6d189d2b0 | swh:1:cnt:972bb8e27faadb3b959ff5c49e7189db10d9df64;origin=https://gitlab.wikimedia.org/repos/data-engineering/eventutilities-python.git;lines=225-273/ | f7f411402647e5c7ae9dc706b7da9259a3abe332 | eventutilities-python | analytics | tests/test_stream_manager.py | test_flink_stream_manager_enrich_async_enabled_false(
tmp_path,
flink_env,
fixture_schema_uris,
fixture_stream_config_uri,
source_descriptor_file_test_event_example,
test_event_enriched,
) | function | # The test_flink_stream_manager_*_async_enabled_false functions below were authored
# with AI assistance (Cursor coding agent / Composer), alongside the async_enabled=False
# refactor of EventProcessFunction. Update them if synchronous process semantics change.
def test_flink_stream_manager_enrich_async_enabled_false(... |
1,367 | ec00cb57235e41530770702dd7c64f1e | swh:1:cnt:972bb8e27faadb3b959ff5c49e7189db10d9df64;origin=https://gitlab.wikimedia.org/repos/data-engineering/eventutilities-python.git;lines=347-409/ | f7f411402647e5c7ae9dc706b7da9259a3abe332 | eventutilities-python | analytics | tests/test_stream_manager.py | test_flink_stream_manager_enrich_with_error_async_enabled_false(
tmp_path,
flink_env,
fixture_schema_uris,
fixture_stream_config_uri,
source_descriptor_file_test_event_example,
test_event_enriched,
test_event_error,
) | function | def test_flink_stream_manager_enrich_with_error_async_enabled_false(
tmp_path,
flink_env,
fixture_schema_uris,
fixture_stream_config_uri,
source_descriptor_file_test_event_example,
test_event_enriched,
test_event_error,
):
"""Error side output and main output behave like async mode when ... |
1,368 | 927bf93ef3ebbba3fdf92c77b76757d7 | swh:1:cnt:972bb8e27faadb3b959ff5c49e7189db10d9df64;origin=https://gitlab.wikimedia.org/repos/data-engineering/eventutilities-python.git;lines=481-483/ | f7f411402647e5c7ae9dc706b7da9259a3abe332 | eventutilities-python | analytics | tests/test_stream_manager.py | test_flink_stream_manager_enrich_invalid_output::enrich(test_event: dict) | function | def enrich(test_event: dict) -> Optional[dict]:
if test_event["test_int"] != 3:
return test_event |
1,369 | c59edadbaecce6360725eb57633e3c56 | swh:1:cnt:972bb8e27faadb3b959ff5c49e7189db10d9df64;origin=https://gitlab.wikimedia.org/repos/data-engineering/eventutilities-python.git;lines=51-73/ | f7f411402647e5c7ae9dc706b7da9259a3abe332 | eventutilities-python | analytics | tests/test_stream_manager.py | test_flink_stream_manager_init_with_default_custom_sink(
fixture_schema_uris,
fixture_stream_config_uri,
source_descriptor_file_test_event_example,
test_event_enriched,
test_event_error,
) | function | def test_flink_stream_manager_init_with_default_custom_sink(
fixture_schema_uris,
fixture_stream_config_uri,
source_descriptor_file_test_event_example,
test_event_enriched,
test_event_error,
):
manager = stream_manager(
job_name="test_manager",
schema_uris=fixture_schema_uris,
... |
1,370 | a301fe1c1dd2f7e793f95f8092ca0200 | swh:1:cnt:972bb8e27faadb3b959ff5c49e7189db10d9df64;origin=https://gitlab.wikimedia.org/repos/data-engineering/eventutilities-python.git;lines=276-344/ | f7f411402647e5c7ae9dc706b7da9259a3abe332 | eventutilities-python | analytics | tests/test_stream_manager.py | test_flink_stream_manager_enrich_with_error(
tmp_path,
flink_env,
fixture_schema_uris,
fixture_stream_config_uri,
flink_datastream_factory,
source_descriptor_file_test_event_example,
test_event_enriched,
test_event_error,
) | function | def test_flink_stream_manager_enrich_with_error(
tmp_path,
flink_env,
fixture_schema_uris,
fixture_stream_config_uri,
flink_datastream_factory,
source_descriptor_file_test_event_example,
test_event_enriched,
test_event_error,
):
def enrich_with_error(test_event: dict) -> dict:
... |
1,371 | 9533b5303795c3d0cf9ec660cdbf867a | swh:1:cnt:972bb8e27faadb3b959ff5c49e7189db10d9df64;origin=https://gitlab.wikimedia.org/repos/data-engineering/eventutilities-python.git;lines=412-474/ | f7f411402647e5c7ae9dc706b7da9259a3abe332 | eventutilities-python | analytics | tests/test_stream_manager.py | test_flink_stream_manager_enrich_multiple_process_and_errors(
stream_with_error_sink,
test_event_error,
) | function | def test_flink_stream_manager_enrich_multiple_process_and_errors(
stream_with_error_sink,
test_event_error,
):
test_int_to_enriched_fields = {
1: "I am enriched by enrich1",
2: "I am enriched by enrich2",
}
test_int_to_error_message = {
3: repr(ValueError("error in enrich1")... |
1,372 | f613c1e889b905f2330e6d136f60c63f | swh:1:cnt:972bb8e27faadb3b959ff5c49e7189db10d9df64;origin=https://gitlab.wikimedia.org/repos/data-engineering/eventutilities-python.git;lines=537-585/ | f7f411402647e5c7ae9dc706b7da9259a3abe332 | eventutilities-python | analytics | tests/test_stream_manager.py | test_async_http_process_function_decorator(
stream_with_error_sink,
test_event_error,
) | function | def test_async_http_process_function_decorator(
stream_with_error_sink,
test_event_error,
):
@http_process_function()
def http_enrichment(event, http_session):
if event["test_int"] == 3:
raise ValueError("error in Enrich process function")
with mock.patch.object(http_session,... |
1,373 | bd0a127c6b22c69ea10e598df5b22fe6 | swh:1:cnt:972bb8e27faadb3b959ff5c49e7189db10d9df64;origin=https://gitlab.wikimedia.org/repos/data-engineering/eventutilities-python.git;lines=76-168/ | f7f411402647e5c7ae9dc706b7da9259a3abe332 | eventutilities-python | analytics | tests/test_stream_manager.py | test_stream_unknown(
fixture_schema_uris,
fixture_stream_config_uri,
source_descriptor_file_test_event_example,
test_event_enriched,
) | function | def test_stream_unknown(
fixture_schema_uris,
fixture_stream_config_uri,
source_descriptor_file_test_event_example,
test_event_enriched,
):
"""
When consuming or producing a stream that does not exist,
eventutilities will raise a java.io.FileNotFoundException (local schema repo).
In Pyth... |
1,374 | 125ae83d58e4cd15d22ec5d26d3723de | swh:1:cnt:972bb8e27faadb3b959ff5c49e7189db10d9df64;origin=https://gitlab.wikimedia.org/repos/data-engineering/eventutilities-python.git;lines=286-292/ | f7f411402647e5c7ae9dc706b7da9259a3abe332 | eventutilities-python | analytics | tests/test_stream_manager.py | test_flink_stream_manager_enrich_with_error::enrich_with_error(test_event: dict) | function | def enrich_with_error(test_event: dict) -> dict:
assert isinstance(test_event, dict)
if test_event["test_int"] == 2:
raise ValueError("GOT AN ERROR HERE")
test_event["enriched_field"] = "I am enriched"
return test_event |
1,375 | c460e015dec082fe9f1d61bb0c540f2c | swh:1:cnt:972bb8e27faadb3b959ff5c49e7189db10d9df64;origin=https://gitlab.wikimedia.org/repos/data-engineering/eventutilities-python.git;lines=477-503/ | f7f411402647e5c7ae9dc706b7da9259a3abe332 | eventutilities-python | analytics | tests/test_stream_manager.py | test_flink_stream_manager_enrich_invalid_output(
stream_with_error_sink,
test_event_error,
) | function | def test_flink_stream_manager_enrich_invalid_output(
stream_with_error_sink,
test_event_error,
):
def enrich(test_event: dict) -> Optional[dict]:
if test_event["test_int"] != 3:
return test_event
with stream_with_error_sink as stream:
stream.partition_by(lambda e: e["test_de... |
1,376 | 6458b0df16f4cfdbc795827b185a3677 | swh:1:cnt:972bb8e27faadb3b959ff5c49e7189db10d9df64;origin=https://gitlab.wikimedia.org/repos/data-engineering/eventutilities-python.git;lines=171-222/ | f7f411402647e5c7ae9dc706b7da9259a3abe332 | eventutilities-python | analytics | tests/test_stream_manager.py | test_flink_stream_manager_enrich(
tmp_path,
flink_env,
fixture_schema_uris,
fixture_stream_config_uri,
source_descriptor_file_test_event_example,
test_event_enriched,
) | function | def test_flink_stream_manager_enrich(
tmp_path,
flink_env,
fixture_schema_uris,
fixture_stream_config_uri,
source_descriptor_file_test_event_example,
test_event_enriched,
):
"""
Test that a FlinkStreamManager enrichment pipeline works:
Row -> dict, enrich, then dict -> Row.
"""
... |
1,377 | d6e347c09f9d398605f0bf198a27901a | swh:1:cnt:972bb8e27faadb3b959ff5c49e7189db10d9df64;origin=https://gitlab.wikimedia.org/repos/data-engineering/eventutilities-python.git;lines=184-187/ | f7f411402647e5c7ae9dc706b7da9259a3abe332 | eventutilities-python | analytics | tests/test_stream_manager.py | test_flink_stream_manager_enrich::enrich(test_event: dict) | function | def enrich(test_event: dict) -> dict:
assert isinstance(test_event, dict)
test_event["enriched_field"] = "I am enriched"
return test_event |
1,378 | d6e347c09f9d398605f0bf198a27901a | swh:1:cnt:972bb8e27faadb3b959ff5c49e7189db10d9df64;origin=https://gitlab.wikimedia.org/repos/data-engineering/eventutilities-python.git;lines=242-245/ | f7f411402647e5c7ae9dc706b7da9259a3abe332 | eventutilities-python | analytics | tests/test_stream_manager.py | test_flink_stream_manager_enrich_async_enabled_false::enrich(test_event: dict) | function | def enrich(test_event: dict) -> dict:
assert isinstance(test_event, dict)
test_event["enriched_field"] = "I am enriched"
return test_event |
1,379 | 125ae83d58e4cd15d22ec5d26d3723de | swh:1:cnt:972bb8e27faadb3b959ff5c49e7189db10d9df64;origin=https://gitlab.wikimedia.org/repos/data-engineering/eventutilities-python.git;lines=358-364/ | f7f411402647e5c7ae9dc706b7da9259a3abe332 | eventutilities-python | analytics | tests/test_stream_manager.py | test_flink_stream_manager_enrich_with_error_async_enabled_false::enrich_with_error(test_event: dict) | function | def enrich_with_error(test_event: dict) -> dict:
assert isinstance(test_event, dict)
if test_event["test_int"] == 2:
raise ValueError("GOT AN ERROR HERE")
test_event["enriched_field"] = "I am enriched"
return test_event |
1,380 | bf41802c28b58f61e8e699b0cca2de07 | swh:1:cnt:972bb8e27faadb3b959ff5c49e7189db10d9df64;origin=https://gitlab.wikimedia.org/repos/data-engineering/eventutilities-python.git;lines=506-534/ | f7f411402647e5c7ae9dc706b7da9259a3abe332 | eventutilities-python | analytics | tests/test_stream_manager.py | test_flink_stream_manager_enrich_invalid_output_async_enabled_false(
stream_with_error_sink,
test_event_error,
) | function | def test_flink_stream_manager_enrich_invalid_output_async_enabled_false(
stream_with_error_sink,
test_event_error,
):
"""Invalid None output is reported to error sink when async_enabled=False."""
def enrich(test_event: dict) -> Optional[dict]:
if test_event["test_int"] != 3:
return ... |
1,381 | 927bf93ef3ebbba3fdf92c77b76757d7 | swh:1:cnt:972bb8e27faadb3b959ff5c49e7189db10d9df64;origin=https://gitlab.wikimedia.org/repos/data-engineering/eventutilities-python.git;lines=512-514/ | f7f411402647e5c7ae9dc706b7da9259a3abe332 | eventutilities-python | analytics | tests/test_stream_manager.py | test_flink_stream_manager_enrich_invalid_output_async_enabled_false::enrich(test_event: dict) | function | def enrich(test_event: dict) -> Optional[dict]:
if test_event["test_int"] != 3:
return test_event |
1,382 | 44921abf85520df4a927563a3ce48425 | swh:1:cnt:972bb8e27faadb3b959ff5c49e7189db10d9df64;origin=https://gitlab.wikimedia.org/repos/data-engineering/eventutilities-python.git;lines=426-431/ | f7f411402647e5c7ae9dc706b7da9259a3abe332 | eventutilities-python | analytics | tests/test_stream_manager.py | test_flink_stream_manager_enrich_multiple_process_and_errors::enrich1(test_event: dict) | function | def enrich1(test_event: dict) -> dict:
if test_event["test_int"] == 3:
raise ValueError("error in enrich1")
test_event["enriched_field"] = "I am enriched by enrich1"
return test_event |
1,383 | fc930c5c19a090ac44990f7d08346b6a | swh:1:cnt:972bb8e27faadb3b959ff5c49e7189db10d9df64;origin=https://gitlab.wikimedia.org/repos/data-engineering/eventutilities-python.git;lines=433-439/ | f7f411402647e5c7ae9dc706b7da9259a3abe332 | eventutilities-python | analytics | tests/test_stream_manager.py | test_flink_stream_manager_enrich_multiple_process_and_errors::enrich2(enriched_event: dict) | function | def enrich2(enriched_event: dict) -> dict:
if enriched_event["test_int"] == 4:
raise ValueError("error in enrich2")
elif enriched_event["test_int"] == 2:
enriched_event["enriched_field"] = "I am enriched by enrich2"
return enriched_event |
1,384 | ac59e373cb7c4affb4db541ca215e72c | swh:1:cnt:972bb8e27faadb3b959ff5c49e7189db10d9df64;origin=https://gitlab.wikimedia.org/repos/data-engineering/eventutilities-python.git;lines=542-554/ | f7f411402647e5c7ae9dc706b7da9259a3abe332 | eventutilities-python | analytics | tests/test_stream_manager.py | test_async_http_process_function_decorator::http_enrichment(event, http_session) | function | def http_enrichment(event, http_session):
if event["test_int"] == 3:
raise ValueError("error in Enrich process function")
with mock.patch.object(http_session, "get") as get_mock:
# This code is execute on a beam worker thread,
# so we need to patch the instance of req... |
1,385 | 8d45fbb54de7684ed599b13487fc8bb3 | swh:1:cnt:81cb7a542299b3743dca05ad7307cdcfee584bbb;origin=https://gitlab.wikimedia.org/repos/data-engineering/eventutilities-python.git;lines=85-106/ | b7010f84a3f07530594f2de24459e7418227dc32 | eventutilities-python | analytics | tests/test_stream_manager_config.py | test_stream_manager_from_args_with_config_file(
fixture_stream_manager_config_file,
test_event_enriched,
) | function | def test_stream_manager_from_args_with_config_file(
fixture_stream_manager_config_file,
test_event_enriched,
):
arg_parser = ArgumentParser()
arg_parser.add_argument("--custom0", type=str)
argv = [
"--custom0",
"value1",
"--config",
str(fixture_stream_manager_config_... |
1,386 | c7f0f94c171077ba67c7bf4821d2b52b | swh:1:cnt:81cb7a542299b3743dca05ad7307cdcfee584bbb;origin=https://gitlab.wikimedia.org/repos/data-engineering/eventutilities-python.git;lines=29-45/ | b7010f84a3f07530594f2de24459e7418227dc32 | eventutilities-python | analytics | tests/test_stream_manager_config.py | test_stream_manager_from_args_custom_arg(
fixture_stream_manager_argv,
test_event_enriched,
) | function | def test_stream_manager_from_args_custom_arg(
fixture_stream_manager_argv,
test_event_enriched,
):
arg_parser = ArgumentParser()
arg_parser.add_argument("--custom0", type=str)
argv = fixture_stream_manager_argv + ["--custom0", "value0"]
config = load_config(argv=argv, parser=arg_parser)
as... |
1,387 | 2fadf8ebff1a97328d139394482a36ef | swh:1:cnt:81cb7a542299b3743dca05ad7307cdcfee584bbb;origin=https://gitlab.wikimedia.org/repos/data-engineering/eventutilities-python.git;lines=16-26/ | b7010f84a3f07530594f2de24459e7418227dc32 | eventutilities-python | analytics | tests/test_stream_manager_config.py | test_stream_manager_from_args_base(
fixture_stream_manager_argv,
test_event_enriched,
) | function | def test_stream_manager_from_args_base(
fixture_stream_manager_argv,
test_event_enriched,
):
config = load_config(argv=fixture_stream_manager_argv)
manager = stream_manager.from_config(config)
assert isinstance(manager.source_descriptor, SourceDescriptor)
assert isinstance(manager.sink_descript... |
1,388 | da790308b0388a8aa807774633b166f6 | swh:1:cnt:81cb7a542299b3743dca05ad7307cdcfee584bbb;origin=https://gitlab.wikimedia.org/repos/data-engineering/eventutilities-python.git;lines=109-196/ | b7010f84a3f07530594f2de24459e7418227dc32 | eventutilities-python | analytics | tests/test_stream_manager_config.py | test_stream_manager_from_args_with_multiple_config_sources_and_relative_uri(
tmp_path, fixture_stream_manager_config_file, test_event_enriched, test_event_error
) | function | def test_stream_manager_from_args_with_multiple_config_sources_and_relative_uri(
tmp_path, fixture_stream_manager_config_file, test_event_enriched, test_event_error
):
arg_parser = ArgumentParser()
arg_parser.add_argument("--custom0", type=str)
config2_file_path = tmp_path / "config2.yaml"
config2... |
1,389 | cbbebe3b51b5d46b8fa609df383b04c1 | swh:1:cnt:81cb7a542299b3743dca05ad7307cdcfee584bbb;origin=https://gitlab.wikimedia.org/repos/data-engineering/eventutilities-python.git;lines=198-234/ | b7010f84a3f07530594f2de24459e7418227dc32 | eventutilities-python | analytics | tests/test_stream_manager_config.py | test_from_config_succeeds_when_cwd_parent_not_writeable(
tmp_path, fixture_stream_manager_argv, test_event_enriched
) | function | def test_from_config_succeeds_when_cwd_parent_not_writeable(
tmp_path, fixture_stream_manager_argv, test_event_enriched
):
"""When cwd's parent is not writeable (e.g. K8s /srv/app), from_config must succeed.
The manager uses Path_dr(os.getcwd()): directory must exist and be readable, not writable.
Thi... |
1,390 | 63b59cc060d85606bfc3c8583e99c05d | swh:1:cnt:81cb7a542299b3743dca05ad7307cdcfee584bbb;origin=https://gitlab.wikimedia.org/repos/data-engineering/eventutilities-python.git;lines=48-82/ | b7010f84a3f07530594f2de24459e7418227dc32 | eventutilities-python | analytics | tests/test_stream_manager_config.py | test_stream_manager_from_args_with_error_sink_configured(
fixture_stream_manager_argv, test_event_enriched, test_event_error
) | function | # @pytest.mark.skip(reason="This does not work! " "See comment on error_sink param in stream_manage")
def test_stream_manager_from_args_with_error_sink_configured(
fixture_stream_manager_argv, test_event_enriched, test_event_error
):
arg_parser = ArgumentParser()
arg_parser.add_argument("--custom0", type=st... |
1,391 | b56e24196a3471295b79158d0eec976b | swh:1:cnt:cf7dc0406d027f86092a84af5559d72536655365;origin=https://gitlab.wikimedia.org/repos/data-engineering/node-url-get.git;lines=19-45/ | 9234e519a36e54c97ae1a78bd1efb1e52912bd3a | node-url-get | analytics | index.js | objectFactory | function | /**
* Converts a utf-8 byte buffer or a YAML/JSON string into
* an object and returns it.
* @param {string|Buffer|Object} data
* @return {Object}
*/
function objectFactory(data) {
// If we were given a byte Buffer, parse it as utf-8 string.
if (data instanceof Buffer) {
data = data.toString('utf-8'... |
1,392 | 7f7f124ecc3932126bb3f1460e7ed1f3 | swh:1:cnt:cf7dc0406d027f86092a84af5559d72536655365;origin=https://gitlab.wikimedia.org/repos/data-engineering/node-url-get.git;lines=115-140/ | 9234e519a36e54c97ae1a78bd1efb1e52912bd3a | node-url-get | analytics | index.js | urlGet | function | /**
* Given a string URL, returns a Promise of the contents at that
* URL. Supports both file:// (via fs.readFile) and other http
* based URLs with preq.get.
* @param {string} url
* @param {Object} options Options to pass to the function used to
* open the url. This will be different
* ... |
1,393 | c6e2fa36d7c27cbc69934923958a7f68 | swh:1:cnt:cf7dc0406d027f86092a84af5559d72536655365;origin=https://gitlab.wikimedia.org/repos/data-engineering/node-url-get.git;lines=80-113/ | 9234e519a36e54c97ae1a78bd1efb1e52912bd3a | node-url-get | analytics | index.js | resolveUri | function | /**
* Takes a possibly relative uri, and augments it so that it is better suited for use in requests.
* If the uri is already qualified (e.g. is starts with a protocol scheme), baseUri will
* not be prepended.
* If the uri already ends in a file extensions, defaultFileExtension will not be appended.
* If the base... |
1,394 | faca881455a5737cd44a0121692e382f | swh:1:cnt:cf7dc0406d027f86092a84af5559d72536655365;origin=https://gitlab.wikimedia.org/repos/data-engineering/node-url-get.git;lines=59-78/ | 9234e519a36e54c97ae1a78bd1efb1e52912bd3a | node-url-get | analytics | index.js | fileExtension | function | /**
* Returns the file extension (or the last part after a final '.' in a file basename)
* of a filename path. If no file extension is present, this returns an empty string.
* If the final part of a file name after '.' is numeric, this is not a file
* extension, and an empty string will be returned.
* @param {stri... |
1,395 | 49350fc939f3ee980493c8057a0df142 | swh:1:cnt:cf7dc0406d027f86092a84af5559d72536655365;origin=https://gitlab.wikimedia.org/repos/data-engineering/node-url-get.git;lines=50-57/ | 9234e519a36e54c97ae1a78bd1efb1e52912bd3a | node-url-get | analytics | index.js | uriHasProtocol | function | /**
* Returns true if the uri has protocol schema on the front, else false.
* @param {string} uri
* @return {boolean}
*/
function uriHasProtocol(uri) {
return uriProtocolRegex.test(uri);
} |
1,396 | 2a0fc9d130196b3e46bf48faa8a9ab8d | swh:1:cnt:cf7dc0406d027f86092a84af5559d72536655365;origin=https://gitlab.wikimedia.org/repos/data-engineering/node-url-get.git;lines=142-157/ | 9234e519a36e54c97ae1a78bd1efb1e52912bd3a | node-url-get | analytics | index.js | urlGetObject | function | /**
* Given a URL, returns a Promise of the contents at that
* converted into an Object. The content at URL
* must either be a JSON or YAML string.
* @param {string} url
* @param {Object} options Options to pass to the function used to
* open the url. This will be different
* ... |
1,397 | 5a39da48eb20487089561f44b71225c3 | swh:1:cnt:cf7dc0406d027f86092a84af5559d72536655365;origin=https://gitlab.wikimedia.org/repos/data-engineering/node-url-get.git;lines=159-181/ | 9234e519a36e54c97ae1a78bd1efb1e52912bd3a | node-url-get | analytics | index.js | urlGetFirstObject | function | /**
* Given a list of URLs, returns a Promise of the first resolved
* result of urlGetObject. If no URL resolves, this will return
* the final rejection.
* @param {Array<string>} urls
* @param {Object} options Options to pass to the function used to
* open the url. This will be different
... |
1,398 | 901346a5a4fbf8d93dad075e084c6c96 | swh:1:cnt:cf7dc0406d027f86092a84af5559d72536655365;origin=https://gitlab.wikimedia.org/repos/data-engineering/node-url-get.git;lines=183-209/ | 9234e519a36e54c97ae1a78bd1efb1e52912bd3a | node-url-get | analytics | index.js | uriGetFirstObject | function | /**
* Combines resolveUri and urlGetObjectFirst to return the first
* baseUri + uri combination that resolves to an object.
* @param {string} uri
* uri to resolve with baseUri and defaultFileExtension
* @param {Array<string>} baseUris
* If given, uris that don't start with a protocol scheme will be prep... |
1,399 | 95d0c302e2d390cc102664505c9dc1fe | swh:1:cnt:fbf62cc2fb6404dffe866bee25f7276093b27f56;origin=https://gitlab.wikimedia.org/repos/data-engineering/node-url-get.git;lines=29-31/ | 16dfeba253b6d22d5d51f90f82a94ceef2135ba5 | node-url-get | analytics | test/index.js | writeTempFile | function | function writeTempFile() {
fs.writeFileSync(filePath, testObjectYaml);
} |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.