Dijar Vrella
06/17/2024, 8:33 AMDijar Vrella
06/17/2024, 9:21 AMNate
06/17/2024, 1:11 PMfrom prefect import flow
@flow(log_prints=True)
def hello_docker():
"""
A simple flow that prints 'Hello, Docker!' to the logs
"""
print("Hello, Docker!")
if __name__ == "__main__":
hello_docker()
• define your deployment
◦ using `prefect.yaml` (my preference)
◦ using `.deploy`
• start a worker prefect worker start --type docker --pool my-pool
Dijar Vrella
06/17/2024, 1:17 PMNate
06/17/2024, 1:20 PMhello_docker
function in my example represents your flow that a worker would submit for execution as a container
so if you went the prefect.yaml
route, you would
• create your deployment with prefect deploy -n hello-docker
given the 2 files I referenced
• start a worker `prefect worker start --type docker --pool your-pool`(which creates your-pool
if it doesnt already exist)
• either run prefect deployment run ...
or click run on your deployment in the UI to have it execute
ie the worker is responsible for picking up the function at your entrypoint
and submitting it according to the infra config (i.e work pool)Nate
06/17/2024, 1:20 PMDijar Vrella
06/17/2024, 1:31 PMDijar Vrella
06/17/2024, 1:32 PMDijar Vrella
06/17/2024, 1:37 PMdocker run --gpus all -v "$(pwd)/../test.py:/workspace/test.py" -v /ninjadata:/ninjadata --group-add ninja -it --cap-add SYSLOG ninja/build:$1 python test.py
Dijar Vrella
06/17/2024, 1:38 PMninja/build:latest
running the container that passes these parameters:
docker run --gpus all -v "$(pwd)/../test.py:/workspace/test.py" -v /ninjadata:/ninjadata --group-add ninja -it --cap-add SYSLOG ninja/build:latest
Also pass the python test.py
to be executedDijar Vrella
06/17/2024, 2:06 PMNate
06/17/2024, 2:17 PMdocker
client directly from within a flow like hello_docker
that could use any docker features that the work pool may not support
for example the gpus
flag is not currently supported directly in the docker work pool (though we'd like to add it) so you could just write / deploy a flow that invokes docker however you need
you can schedule a call hereBring your towel and join one of the fastest growing data communities. Welcome to our second-generation open source orchestration platform, a completely rethought approach to dataflow automation.
Powered by