Skip to main content

prefect.cli.shell

Shell command — native cyclopts implementation. Run shell commands as Prefect flows.

Functions

output_stream

output_stream(pipe: IO[str], logger_function: Callable[[str], None]) -> None
Read from a pipe line by line and log using the provided logging function.

output_collect

output_collect(pipe: IO[str], container: list[str]) -> None
Collect output from a subprocess pipe and store it in a container list.

run_shell_process

run_shell_process(command: str, log_output: bool = True, stream_stdout: bool = False, log_stderr: bool = False, popen_kwargs: Optional[dict[str, Any]] = None)
Execute a shell command and log its output. Designed for use within Prefect flows to run shell commands as part of task execution. Args:
  • command: The shell command to execute.
  • log_output: If True, log stdout/stderr to Prefect logs.
  • stream_stdout: If True, stream stdout to Prefect logs.
  • log_stderr: If True, log stderr to Prefect logs.
  • popen_kwargs: Additional keyword arguments for subprocess.Popen.

watch

watch(command: str)
Execute a shell command and observe it as a Prefect flow.

serve

serve(command: str)
Create and serve a deployment that runs a shell command.