Skip to content

Conversation

andrewchambers
Copy link

@andrewchambers andrewchambers commented Aug 16, 2023

This implementation also includes an example bytewax adapter which can be used to process realtime inserts with bytewax.

An example bytewax flow is shown below:

import uuid
import btrdb
from btrdb.experimental.bytewax_connectors import InsertSubscription
from bytewax.dataflow import Dataflow
from bytewax.connectors.stdio import StdOutput

def selector(db):
	# Selector can be anything that returns a list of uuids.
	rows = db.query('select uuid from streams')
	uuids = [uuid.UUID(row['uuid']) for row in rows]
	return uuids

flow = Dataflow()
flow.input("realtime_sub", InsertSubscription(selector, refresh_delay=30))
flow.output("print_output", StdOutput())

@andrewchambers andrewchambers force-pushed the realtimesubs branch 7 times, most recently from 03c0ac3 to d448eb5 Compare August 16, 2023 09:23
yield page.SQLQueryRow

@error_handler
def subscribe(self, update_queue):

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can we add type hinting for the update_queue parameter?

Copy link
Author

@andrewchambers andrewchambers Aug 16, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah, I think I will do a pass of type hinting + docstrings + tests. The queue is slightly awkward because of how grpc handles bidirectional streams.

import threading
import weakref

from bytewax.inputs import DynamicInput, StatelessSource

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not important yet, but will need to update the pyproject.toml optional dependencies to include bytewax

This implementation also includes an example bytewax adapter
which can be used to process inserts with bytewax.

An example bytewax flow is shown below:

```
import uuid
import btrdb
from btrdb.experimental.bytewax_connectors import InsertSubscription
from bytewax.dataflow import Dataflow
from bytewax.connectors.stdio import StdOutput

def selector(db):
	# Selector can be anything that returns a list of uuids.
	rows = db.query('select uuid from streams')
	uuids = [uuid.UUID(row['uuid']) for row in rows]
	return uuids

flow = Dataflow()
flow.input("realtime_sub", InsertSubscription(selector, selector_refresh_interval=30))
flow.output("print_output", StdOutput())
```
self._background_worker.start()
self._read_worker.start()

def next(self):
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I attempted to use the bytewax flow example, and it seems in bytewax=='0.17.1' there is no next it's either next_batch or next_awake

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah, this was written against v0.16, needs to be reworked slightly for 0.17.

jleifnf and others added 3 commits September 29, 2023 15:56
…57)

* update setuptools parameters for strict standards starting 2023-Oct-30

* remove invalid url for homepage of the project

* remove invalid url for homepage of the project

* update the docs url in pyproject.toml
Base automatically changed from staging to master March 26, 2024 20:45
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants