Richard Hughes
02/16/2022, 2:55 PMKevin Kho
upstream_tasks
takes Task objects like the actual variable. Not the name.Richard Hughes
02/16/2022, 3:03 PMfor key in ODSCloneGrantScripts:
ODS_Grant_Executing = SqlExecution(Database='ODS_DBT', SqlScript=ODSCloneGrantScripts[key], task_args={"name":"ODS_CLONE_GRANT: "+str(key)}, upstream_tasks=None)
flow_run = create_flow_run(flow_name="System.SQLDynamicExecution",
project_name="PROD",
parameters={"SQLFileName": "F:\\Shares\\PostCloneGrants.sql"
})
flow_run.set_upstream()
Kevin Kho
@task
def add_one(x):
res = x + 1
print(res)
return res
@task
def add_two(x):
res = x + 2
print(res)
return res
with Flow("forloop") as flow:
inputs = [1, 2, 3, 4, 5]
tasks = []
for _in in inputs:
a = add_one(_in)
b = add_two(a)
tasks.append(a)
tasks.append(b)
# set dependencies
for i in range(1, len(tasks)):
tasks[i].set_upstream(tasks[i - 1])
flow.run()
Richard Hughes
02/17/2022, 3:25 PM