Thinking the example under “Prefect approach” may help you.
w
Will Milner
03/24/2021, 7:35 PM
mapping could work, I'm trying to pass the result into a ShellTask, though I suppose I could convert the task into python and invoke the shell from there
k
Kevin Kho
03/26/2021, 5:35 PM
Hey @Will Milner, maybe something like this would help this use case
Kevin Kho
03/26/2021, 5:35 PM
Copy code
from prefect import Flow
from prefect.tasks.shell import ShellTask
sql_list = ["1.sql", "2.sql", "3.sql"]
shell_task = ShellTask(
helper_script="",
shell="bash",
log_stderr=True,
return_all=True,
stream_output=True,
)
with Flow(name="Example") as flow:
tasks = [
shell_task(
command="/opt/prefect_env/bin/python /path/to//SnowSQL.py {}".format(
statement
)
)
for statement in sql_list
]
for i in range(1, len(tasks)):
tasks[i].set_upstream(tasks[i - 1])
flow.run()
Kevin Kho
03/26/2021, 5:36 PM
This loops through tasks while setting the upstream dependency
Bring your towel and join one of the fastest growing data communities. Welcome to our second-generation open source orchestration platform, a completely rethought approach to dataflow automation.