def __init__(self, datafn=random_datablock, interval='500ms', dask=False, start=True, **kwargs): if dask: from streamz.dask import DaskStream source = DaskStream() else: source = Source() self.loop = source.loop self.interval = pd.Timedelta(interval).total_seconds() self.source = source self.continue_ = [False] # like the oppose of self.stopped self.kwargs = kwargs stream = self.source.map(lambda x: datafn(**x, **kwargs)) example = datafn(last=pd.Timestamp.now(), now=pd.Timestamp.now(), **kwargs) super(PeriodicDataFrame, self).__init__(stream, example) if start: self.start()
def __init__(self, datafn=random_datablock, interval='500ms', dask=False, **kwargs): if dask: from streamz.dask import DaskStream source = DaskStream() loop = source.loop else: source = Source() loop = IOLoop.current() self.interval = pd.Timedelta(interval).total_seconds() self.source = source self.continue_ = [True] self.kwargs = kwargs stream = self.source.map(lambda x: datafn(**x, **kwargs)) example = datafn(last=pd.Timestamp.now(), now=pd.Timestamp.now(), **kwargs) super(PeriodicDataFrame, self).__init__(stream, example) loop.add_callback(self._cb, self.interval, self.source, self.continue_)
def __init__(self, freq='100ms', interval='500ms', dask=False): if dask: from streamz.dask import DaskStream source = DaskStream() loop = source.loop else: source = Source() loop = IOLoop.current() self.freq = pd.Timedelta(freq) self.interval = pd.Timedelta(interval).total_seconds() self.source = source self.continue_ = [True] stream = self.source.map(_random_df) example = _random_df((time(), time(), self.freq)) super(Random, self).__init__(stream, example) loop.add_callback(self._cb, self.interval, self.freq, self.source, self.continue_)
def __init__(self, parameters, url, auth={}, frequency=100, dask=False, start=False, timeout=2): if dask: from streamz.dask import DaskStream source = DaskStream() self.loop = source.loop else: source = streamz.Source(asynchronous=False) self.loop = IOLoop.current() self.source = source self.url = url self.parameters = [(param, "") if isinstance(param, str) else (param[0], param[1]) for param in parameters] self.frequency = frequency self.continue_ = [True] self.timeout = timeout auth_kwargs = auth.copy() auth_url = auth.pop( "url", urlparse.urlunsplit( urlparse.urlsplit(url)[:2] + ("Login", "", ""))) self.auth = HistorianAuth(auth_url, **auth) example = self.make_df( tuple([(time.time(), name, float("nan"), unit) for name, unit in self.parameters])) stream = self.source.unique().map(self.make_df) super(sdf.DataFrame, self).__init__(stream, example=example) self.http_client = AsyncHTTPClient() if start: self.start()
def __init__(self, freq='100ms', interval='500ms', dask=False): if dask: from streamz.dask import DaskStream source = DaskStream() else: source = Source() self.source = source start = {'last': time(), 'freq': pd.Timedelta(freq)} stream = self.source.accumulate(_random_accumulator, returns_state=True, start=start) from tornado.ioloop import PeriodicCallback self.interval = pd.Timedelta(interval).total_seconds() * 1000 def trigger(): source._emit(None) self.pc = PeriodicCallback(trigger, self.interval) self.pc.start() _, example = _random_accumulator(start, None) super(Random, self).__init__(stream, example)
def stream(loop, request, client): # flake8: noqa if request.param == 'core': return Stream() else: return DaskStream()
def stream(request, client): # flake8: noqa if request.param == "core": return Stream() else: return DaskStream()