Timo
06/20/2023, 8:24 AMfrom prefect_shell import ShellOperation
with ShellOperation(
commands=["exit 1", "echo 'Hello, world!'"],
) as shell_operation:
shell_process = shell_operation.trigger()
shell_process.wait_for_completion()
shell_output = shell_process.fetch_result()
This runs both statements and then throws the error.Nate
06/20/2023, 8:35 AM&&
between?
In [1]: from prefect_shell import ShellOperation
...:
...: shell_operation = ShellOperation(commands=["exit 1", "&&", "echo 'Hello world!'"])
In [2]: shell_operation.run()
09:34:20.328 | INFO | prefect.ShellOperation - PID 16310 triggered with 3 commands running inside the '.' directory.
...
RuntimeError: PID 16310 failed with return code 1.
Timo
06/20/2023, 8:56 AMNate
06/20/2023, 8:59 AMTimo
06/20/2023, 9:23 AM["dbt run -m model_1", "&&", "dbt run -m model_2"]
ends in
dbt run -m model_1 --project_dir /path --profiles_dir /profile
&& --project_dir /path --profiles_dir /profile
dbt run -m model_2 --project_dir /path --profiles_dir /profile
Nate
06/20/2023, 9:26 AMShellOperation
s?Timo
06/20/2023, 9:30 AMNate
06/20/2023, 9:55 AMShellOperation
that fails fast as &&
does if properly placed between commands? if so i can open a ticket and work on that as time allowsTimo
06/20/2023, 10:02 AMDbtOperation
. For ShellOperation
it fails fast when adding &&
(as ur example showed above).
But for the DbtOperation
the --project_dir
and --profiles_dir
argument are added to each command. But it also adds this to the &&
which then fails if the first dbt command runs successful.
dbt run -m model_1 --project_dir /path --profiles_dir /profile
&& --project_dir /path --profiles_dir /profile <------------------- WILL FAIL HERE
dbt run -m model_2 --project_dir /path --profiles_dir /profile
So there might be a option to prevent adding these parameter to specific commands or adding a exception if the command is &&
.Nate
06/20/2023, 10:08 AMShellOperation
because DbtCoreOperation
inherits from it
so i was suggesting adding some kwarg to shell operation that we could pass through to the dbt impl and allow something like
dbt_op = DbtCoreOperation(["dbt run -m model_1", "dbt run -m model_2"], stop_on_failure=True)
which would raise the failure if model 1's run failsTimo
06/20/2023, 10:10 AMTimo
06/20/2023, 10:10 AMNate
06/20/2023, 10:16 AMTimo
06/20/2023, 10:17 AMSean Williams
06/20/2023, 2:50 PMdbt run --select model_1 model_2
. If you want faster failure you can also add a --fail-fast
flag, which will end the dbt operation if a single node fails.Nate
06/20/2023, 2:51 PMTimo
06/21/2023, 5:00 AMdbt build
and then execute a macro call by using dbt run-operation
afterwards. You can't combine this in one cmd. Another example maybe instead of using dbt build
you first want to call`dbt run` and then call a dbt test
not for all but for special models. You then need to put these into two commands.Nate
06/21/2023, 6:07 AMyang yu
09/08/2023, 5:49 PM