MCPcopy
hub / github.com/PrefectHQ/prefect / test_docker_deploy

Function test_docker_deploy

integration-tests/test_docker_deploy.py:30–123  ·  view source on GitHub ↗

Deploy and run a flow in a Docker container with runtime package installation using uv. Demonstrates using EXTRA_PIP_PACKAGES to install dependencies at runtime.

()

Source from the content-addressed store, hash-verified

28
29
30def test_docker_deploy():
31 """
32 Deploy and run a flow in a Docker container with runtime package installation using uv.
33 Demonstrates using EXTRA_PIP_PACKAGES to install dependencies at runtime.
34 """
35 try:
36 subprocess.check_call(
37 [
38 "uv",
39 "run",
40 "--isolated",
41 "prefect",
42 "work-pool",
43 "create",
44 "test-docker-pool",
45 "-t",
46 "docker",
47 ],
48 stdout=sys.stdout,
49 stderr=sys.stderr,
50 )
51
52 dockerfile = Path("docker-deploy.Dockerfile")
53
54 dockerfile.write_text(
55 dedent(
56 """
57 FROM prefecthq/prefect:3-latest
58 COPY integration-tests/test_docker_deploy.py /opt/prefect/integration-tests/test_docker_deploy.py
59 """
60 )
61 )
62
63 flow_that_needs_pandas.deploy(
64 name="docker-demo-deployment",
65 work_pool_name="test-docker-pool",
66 job_variables={
67 "env": {"EXTRA_PIP_PACKAGES": "pandas"},
68 "image": "prefect-integration-test-docker-deploy",
69 },
70 image=DockerImage(
71 name="prefect-integration-test-docker-deploy",
72 dockerfile=str(dockerfile),
73 ),
74 build=True,
75 push=False,
76 )
77
78 dockerfile.unlink()
79
80 flow_run = run_deployment(
81 "flow-that-needs-pandas/docker-demo-deployment",
82 timeout=0,
83 )
84
85 # Execute the flow run
86 subprocess.check_call(
87 [

Callers

nothing calls this directly

Calls 7

DockerImageClass · 0.90
run_deploymentFunction · 0.90
write_textMethod · 0.80
deployMethod · 0.80
read_flow_runFunction · 0.70
runMethod · 0.45
is_completedMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…