Chern Hong Poh
10/12/2022, 10:08 AMShellTask
that returns Command failed with exit code 2
when I registered and quick run the prefect flow. I registered the flow using this command prefect register flow --file testing.py --project staging
. Appreciated if someone can help. This has been bugging me since morning.
## print2.py
print("hello")
## testing.py
import os
import datetime
from datetime import timedelta
import pendulum
import prefect
from prefect import case
from prefect import Flow
from prefect import Parameter
from prefect import task
from prefect.environments.storage import S3
from prefect.schedules import filters
from prefect.schedules.clocks import IntervalClock
from prefect.schedules.schedules import Schedule
from prefect.tasks.control_flow import merge
from prefect.tasks.dbt import DbtShellTask
from prefect.tasks.shell import ShellTask
import subprocess
@task(name="Logging")
def logging_result(stuff):
logger = prefect.context.get("logger")
return <http://logger.info|logger.info>(stuff)
@task(name="Run Python Script", log_stdout=True)
def run_script():
return ShellTask(command=f"python3 print2.py").run()
with Flow(name="DBT Python daily run") as flow:
python_run = run_script()
final = logging_result(python_run)
#flow_state = flow.run()
#shell_output = flow_state.result[python_run].result
#print(shell_output)
Slack ConversationMatthieu Lhonneux
10/20/2022, 6:51 AMShellTask.run(command="python3 print2.py")
Or
ShellTask(command="python3 print2.py")
https://docs-v1.prefect.io/api/latest/tasks/shell.html#shelltask