Docs
https://prefecthq.github.io/prefect-shell/
Code
Examples
Sync
from prefect import flow
from prefect_shell import shell_run_command
@flow
def example_shell_run_command_flow():
return shell_run_command(command="ls .", return_all=True)
if __name__ == "__main__":
example_shell_run_command_flow()
from prefect import flow
from prefect_shell import shell_run_command
@flow
def example_shell_loop():
commands = ["mkdir test1", "mkdir test2", "mkdir test3"]
for cmd in commands:
shell_run_command(command=cmd, return_all=True)
if __name__ == "__main__":
example_shell_loop()
Async
import asyncio
from prefect import flow
from prefect_shell import shell_run_command
@flow
async def example_shell_run_command_flow():
await shell_run_command(command="ls .", return_all=True)
if __name__ == "__main__":
asyncio.run(example_shell_run_command_flow())
import asyncio
from prefect import flow
from prefect_shell import shell_run_command
@flow
async def example_shell_loop():
commands = ["mkdir -p test1", "mkdir -p test2", "mkdir -p test3"]
for cmd in commands:
await shell_run_command(command=cmd, return_all=True)
if __name__ == "__main__":
asyncio.run(example_shell_loop())