Sergey
11/16/2021, 8:20 AMAnna Geller
with case
context manager.
So instead of `with case(list_check(new_events), False)`: it would be:
condition = list_check(new_events)
with case(condition, False):
some_task_on_false()
Anna Geller
Anna Geller
with case(list_check(new_events), False)
- this passes a task to the case()
• with case(condition, False)
- this passes data that is a result of the list_check taskSergey
11/16/2021, 9:53 AM#Если списко не пустой
tf = list_check(new_events)
with case(tf, False):
range_date = pd.date_range(start='2021-08-01', end=datetime.today(), freq='MS') #получаем диапазон месяцкв, с которых необходимо выгрзуить данные
for date in range_date:
new_events_in_app = extract_clickhouse(track_id, events, date, 'event', new_events)
tf2 = list_check(new_events)
with case(tf2, False):
next
tf2 = list_check(new_events)
with case(tf2, True):
merge_data = merge(new_events_in_app, ab_users)
load_data(merge_data)
events_in_app = filter_df(events_in_app, new_events)
merge_data = merge(events_in_app, ab_users)
load_data(merge_data)
tf = list_check(new_events)
with case(tf, True):
#Если список пустой, то загружаем суточные данные
logs(events_in_app)
merge_data = merge(events_in_app, ab_users)
load_data(merge_data)
Sergey
11/16/2021, 9:53 AMSergey
11/16/2021, 9:54 AM@task(name='list_check')
def list_check(new_event_list):
tf = len(new_event_list) == 0
return tf
Sergey
11/16/2021, 10:05 AMwith case (date_check (end_date), True):
with case (date_check (end_date), False):
And it successfully fulfillsAnna Geller
Kevin Kho
case
will raise a SKIP
flag when the condition is not met. SKIP will propagate to downstream tasks. If you need something to run, you can use the always_run
trigger.