<@ULVA73B9P> When I run a deployment from the comm...
# ask-marvin
j
@Marvin When I run a deployment from the command line, is there a way I can have the output of the flow run appear in my terminal?
m
thought for 216.4 seconds
Short answer: not directly. Assuming Prefect 3.x,
prefect deployment run
can watch the run’s state but does not stream logs into your terminal. What you can do: - Watch the run status -
Copy code
prefect deployment run <FLOW>/<DEPLOYMENT> --watch
- This keeps the command open until the run reaches a terminal state, but it won’t stream logs. - Docs: prefect deployment CLI - View logs after triggering a run - Get the run ID from the output of
prefect deployment run
, then: -
Copy code
prefect flow-run logs <RUN_ID>
- There’s no live “follow” flag, but you can approximate tailing: -
Copy code
while true; do clear; prefect flow-run logs <RUN_ID> --tail -n 200; sleep 2; done
- Docs: prefect flow-run CLI - Stream logs by running the worker in the foreground - If you start your worker in your terminal, you’ll see your flow’s logs there when it picks up the run: -
Copy code
prefect worker start -p <WORK_POOL_NAME>
- In another terminal, trigger the run: -
Copy code
prefect deployment run <FLOW>/<DEPLOYMENT> --watch
- The run will not execute until a worker is running. - Advanced: execute a specific run locally - If you already have a run ID and the environment to execute it, you can run: -
Copy code
prefect flow-run execute <RUN_ID>
- This will execute the run in your terminal and stream logs, similar to what a worker does. If you share your version (2.x vs 3.x) and how you’re running deployments (worker type, local vs remote), I can tailor the best option for your setup.