def test_streams_init() -> None: stream_a = Stream('a') stream_b = Stream('b') streams = Streams([stream_a, stream_b]) assert streams.stream_list == [stream_a, stream_b] assert streams.stream_names == ['a', 'b']
async def _main() -> None: stream1 = Stream("test_stream_join_1") stream2 = Stream("test_stream_join_2") async with Streams([stream1, stream2]) as streams: async for value in streams.join(): print(value)
async def main(): stream1 = Stream('test_stream_1') stream2 = Stream('test_stream_2') async with Streams([stream1, stream2]) as streams: async for value in streams.join('time_catch', 2): print("===") pp(value) print("===")
async def main() -> None: stream1 = Stream("test_stream_1") stream2 = Stream("test_stream_2") async with Streams([stream1, stream2]) as streams: async for value in streams.join("update_state"): print("===") pp(value) print("===\n")
async def main(): stream1 = Stream('test_stream_1') stream2 = Stream('test_stream_2') async with Streams([stream1, stream2]) as streams: async for value in streams.merge(): # Return a tuple: # (stream name, record id, record content) print(f"{value[0].decode()}: {value[1].decode()}")
async def _main() -> None: stream1 = Stream("test_stream_1") stream2 = Stream("test_stream_2") async with Streams([stream1, stream2]) as streams: async for value in streams.join("time_catch"): return value with pytest.raises(TypeError): await _main()
async def _main() -> List[Tuple[bytes, bytes, Dict[bytes, bytes]]]: stream1 = Stream("test_stream_merge_1") stream2 = Stream("test_stream_merge_2") async with Streams([stream1, stream2]) as streams: i = 0 result = [] async for value in streams.merge(): if i < 5: result.append(value) i += 1 else: break return result
async def _main() -> List[Dict[bytes, Dict[bytes, bytes]]]: stream1 = Stream("test_stream_1") stream2 = Stream("test_stream_2") async with Streams([stream1, stream2]) as streams: i = 0 result = [] async for value in streams.join("time_catch", 0.3): if i < 5: # value: {b'stream_name': ( # b'id', OrderedDict(b'k': b'v') # )} result.append({k: dict(v[1]) for k, v in value.items()}) i += 1 else: break return result
async def main(): model = creme.linear_model.LogisticRegression() stream1 = Stream('test_stream_1') stream2 = Stream('test_stream_2') async with Streams([stream1, stream2]) as streams: async for value in streams.join('time_catch', 5): try: val_1 = float(value[b'test_stream_1'][1][b'val']) val_2 = float(value[b'test_stream_2'][1][b'val']) except KeyError as e: logging.warning(f'key error: {e}') else: model.fit_one( {'f1': val_1, 'f2': val_2}, random.choice([True, False]) ) print("===") print(f'a: {model.intercept}') print(f'b1: {model.weights["f1"]}') print(f'b2: {model.weights["f2"]}') print("===")