Comments (1)
before doing so, I would suggest normalizing the input/output.
For ex:
class StreamDoc(dict):
def __init__(self, *args, **kwargs):
'''
Normalizing inputs/outputs
attributes : the metadata
outputs : a dictionary of outputs
argnames : a list of keys into dictionary of outputs of what the arguments are
kwargnames : a list of keys into dictionary of outputs of what the kwargs are
'''
self['attributes'] = dict()
self['outputs'] = dict(**kwargs)
self['kwargnames'] = list(kwargs.keys())
self['argnames'] = list()
for i, arg in enumerate(args):
key = "_arg{}".format(i)
self['outputs'][key] = arg
self['argnames'].append(key)
# needed to distinguish that it is a StreamDoc by stream methods
self['_StreamDoc'] = 'StreamDoc v1.0'
#... add methods to select/add /remove inputs/outputs, modify attributes etc
The reason why I mention this is that I think this would be coupled with the collections idea. A list of things coming from a stream could be interpreted in a few ways:
- ordered sequence in how to input arguments
- separate computations for each argument.
For example, method 1 would yield something like:
def add(a,b):
return a + b
s1 = Stream()
s2 = s1.map(add)
s1.emit([1, 2, 'stop', 1, 3, 'stop'])
s2.sink(print)
whereas method 2 would be something like:
def add(a,b):
return a + b
s1 = Stream()
s2 = s1.map(add)
#roughly...
s1.emit([StreamDoc(1,2), StreamDoc(1,3)])
s2.sink(print)
If adding collections, was one of these two methods in mind? Or is there another better way?
Just some thoughts. I'm inclined to go for method 2. We're currently using dask and have an object similar to that of method 2.
For method 2, putting the arguments into the function could be as simple as decorating the update
routines. Something like:
def parse_streamdoc(name):
def streamdoc_dec(f):
def f_new(x, **kwargs_additional):
args = list()
for argkey in x['argnames']:
args.append(x['outputs'][argkey])
# same for kwargs
kwargs.update(kwargs_additional)
return f(*args, **kwargs)
return f_new
return stream_dec
etc...
we use something similar so it didn't require much time to post here (don't worry, I'm not making the assumption this library is something to depend on, but I'm hoping for it! :-) )
Anyway, I'd be happy to hear thoughts, and definitely would like to hear your insight on potential shortcomings of this approach as simply the ideas can help us on our end. (We're working on better shaping API for our experimental xray beamline)
from streamz.
Related Issues (20)
- missing positional argument: 'topic' in to_mqtt HOT 5
- How to parametrize stream/pipeline creation? HOT 2
- Passing Username and Password to from_mqtt() HOT 4
- Dynamically add upstreams to zip HOT 2
- Dropping `pkg_resources`
- AttributeError: 'Output' object has no attribute '_ipython_display_' HOT 3
- flatten doesn't work with iterables without defined length HOT 2
- visualizing streams and changing variables during runtime HOT 5
- Is it possible to use event time/syntethic time rather than system time? HOT 2
- Time based lookback window? HOT 1
- Streamz not working in Jupyterlite
- Collect does not allow awaitable sinks
- Quickstart lacks conda/environments/streamz_dev.yml HOT 6
- Hello from LorryStream and Kotori / Streamz is cool HOT 1
- Add pytest fixture to clean up the IO loop HOT 4
- Streamz hvplot resets zoom and pan on each update HOT 3
- streamz's typing system can't work properly in vscode HOT 2
- Streamz with websocket not steaming any data HOT 5
- Parallel streams with buffers HOT 3
- Is streamz not maintained anymore? What happened to cuStreamz? HOT 9
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from streamz.