Exemplo n.º 1
0
]

FILENAMES = pd.DataFrame({'filename': URLS})
CST = Constant(Table('filenames', data=FILENAMES), scheduler=s)
CSV = CSVLoader(index_col=False,
                skipinitialspace=True,
                usecols=['pickup_longitude', 'pickup_latitude'],
                filter_=_filter,
                scheduler=s)

CSV.input.filenames = CST.output.table
PR = Every(scheduler=s)
PR.input.df = CSV.output.table
SCATTERPLOT = MCScatterPlot(scheduler=s,
                            classes=[('Scatterplot', 'pickup_longitude',
                                      'pickup_latitude')],
                            approximate=True)
SCATTERPLOT.create_dependent_modules(CSV, 'table')
s.set_interaction_opts(starving_mods=SCATTERPLOT.get_starving_mods(),
                       max_iter=3,
                       max_time=1.5)
if __name__ == '__main__':
    s.start()
    while True:
        time.sleep(2)
        s.to_json()
        SCATTERPLOT.to_json()  # simulate a web query
        #SCATTERPLOT.get_image()
    s.join()
    print(len(CSV.table()))
CSV = CSVLoader(index_col=False,
                skipinitialspace=True,
                usecols=[
                    'pickup_longitude', 'pickup_latitude', 'dropoff_longitude',
                    'dropoff_latitude'
                ],
                filter_=_filter,
                scheduler=s)  # TODO: reimplement filter in read_csv.py

CSV.input.filenames = CST.output.table
PR = Every(scheduler=s)
PR.input.df = CSV.output.table
MULTICLASS = MCScatterPlot(scheduler=s,
                           classes=[('pickup', 'pickup_longitude',
                                     'pickup_latitude'),
                                    ('dropoff', 'dropoff_longitude',
                                     'dropoff_latitude')],
                           approximate=True)
MULTICLASS.create_dependent_modules(CSV, 'table')
s.set_interaction_opts(starving_mods=MULTICLASS.get_starving_mods(),
                       max_iter=3,
                       max_time=1.5)
if __name__ == '__main__':
    s.start()
    while True:
        time.sleep(2)
        s.to_json()
        MULTICLASS.to_json()  # simulate a web query
    s.join()
    print(len(CSV.table()))