Esempio n. 1
0
def test_interval():
    interval = Interval(datetime.date(year=2010, month=1, day=1),
                        datetime.date(year=2012, month=1, day=1),
                        relativedelta(years=1))
    expanded = interval.expand()
    repr_ = ('Interval from 2010-01-01 to 2012-01-01 with '
             'delta relativedelta(years=+1)')
    expected = [(datetime.date(2010, 1, 1), datetime.date(2011, 1, 1)),
                (datetime.date(2011, 1, 1), datetime.date(2012, 1, 1))]

    assert expanded == expected
    assert repr(interval) == repr_
Esempio n. 2
0
def test_param_grid_w_interval():
    pg = ParamGrid({'a': Interval(0, 10, 2), 'b': [2, 4, 6, 8, 10]})
    assert compare(list(pg.zip()), [{
        'a': (0, 2),
        'b': 2
    }, {
        'a': (2, 4),
        'b': 4
    }, {
        'a': (4, 6),
        'b': 6
    }, {
        'a': (6, 8),
        'b': 8
    }, {
        'a': (8, 10),
        'b': 10
    }])
Esempio n. 3
0
                                 closed='left',
                                 freq='D')
    values = np.random.rand(dates_series.shape[0])
    df = pd.DataFrame({'dates': dates_series, 'values': values})
    df.to_parquet(str(product))


dag = DAG()
product = File('{{name}}.parquet')

start_date = date(year=2010, month=1, day=1)
end_date = date(year=2019, month=6, day=1)
delta = relativedelta(years=1)

params_array = ParamGrid({
    'dates': Interval(start_date, end_date, delta)
}).zip()


def namer(params):
    s = str(params['dates'][0]).replace('-', '_')
    e = str(params['dates'][1]).replace('-', '_')
    return 'get_data_{}_{}'.format(s, e)


make_task_group(task_class=PythonCallable,
                task_kwargs={
                    'source': get_data,
                    'product': product
                },
                dag=dag,