Vlad S
05/02/2024, 11:44 PMVlad S
05/02/2024, 11:44 PMmyflow.deploy(
name="myflow-docker",
work_pool_name="mypool-docker",
image=DeploymentImage(
name="myflow-image",
tag="latest"
),
push=False,
build=False,
)
After running the above python script the deployment is created
If I inspect it with prefect deployment inspect 'myflow-flow/myflow-docker'
it shows the following
'path': '.',
'entrypoint': 'src/path/a/b/c',
How can I override the entrypoint and path of this flow when building this container?
The only mention I found in your docs is here, and it gives no actual information about how to do this: https://docs.prefect.io/latest/concepts/deployments/?h=entrypoint#required-dataVlad S
05/03/2024, 3:21 PMVlad S
05/03/2024, 3:23 PMVlad S
05/07/2024, 2:56 PMNate
05/07/2024, 3:04 PMpath
at all and you should just set the entrypoint in your prefect.yaml relative to your repo rootNate
05/07/2024, 3:05 PMNate
05/07/2024, 3:05 PMVlad S
05/07/2024, 3:18 PMNate
05/07/2024, 3:23 PMNate
05/07/2024, 3:25 PMNate
05/07/2024, 3:29 PMMarvin
05/07/2024, 3:29 PMfrom_source
with Prefect to set an entrypoint, you'll actually use the serve
function of the flow. Here is an example to show how this is done:
python
import time
from prefect import flow, task
from pydantic import BaseModel, Field
class Data(BaseModel):
key: str
value: dict = Field(default_factory=dict)
@task
def fetch_data_for_key(key: str) -> Data:
"""A task that simulates fetching data from some source"""
return Data(key=key, value={"data": "some data"})
@task
def process_data(data: Data) -> Data:
"""A task that simulates processing data"""
print(f"Processing {data!r} (I swear)")
time.sleep(3)
return data
@flow
def work_i_need_to_do_sometimes(keys: list[str]):
"""Work you might need to do ever so often"""
raw_data_futures = fetch_data_for_key.map(keys)
process_data.map(raw_data_futures)
if __name__ == "__main__":
work_i_need_to_do_sometimes.serve(
name="sporradic-deployment",
parameters={"keys": ["foo", "bar", "baz"]},
)
By calling serve
on the flow, you can start it as a deployment with a given name and parameters for entry.
For more in-depth details, you can check the code here.Nate
05/07/2024, 3:30 PMNate
05/07/2024, 3:31 PMNate
05/07/2024, 3:32 PMVlad S
05/07/2024, 3:33 PMNate
05/07/2024, 3:40 PMVlad S
05/07/2024, 3:43 PMNate
05/07/2024, 3:47 PMVlad S
05/07/2024, 3:47 PMNate
05/07/2024, 3:53 PMVlad S
05/07/2024, 9:15 PMNate
05/07/2024, 9:18 PMNate
05/07/2024, 9:19 PMimage
job variable from the work pool for that deployment, which you can do for any job variable on a given work poolVlad S
05/07/2024, 9:34 PMNate
05/07/2024, 9:35 PMimage
Vlad S
05/07/2024, 9:39 PMI rebuilt with a repo name, but that doesn't work either:job_variables:
# image: '{{ build_image.image }}'
image: local/t1:latest
Nate
05/07/2024, 9:40 PMVlad S
05/07/2024, 9:46 PMNate
05/07/2024, 10:02 PMNate
05/07/2024, 10:03 PM» docker build . -t works-fine:local -f Dockerfile.demo
and then
» prefect --no-prompt deploy -n test
and
» prefect worker start --pool 'docker-work'
» prefect deployment run 'healthcheck/test'
Vlad S
05/07/2024, 10:04 PMNate
05/07/2024, 10:04 PMlatest
tag, we assume the image is remote based on some k8s convention I think
you could open an issue if you don't think that behavior is idealVlad S
05/07/2024, 10:10 PMVlad S
05/07/2024, 10:26 PMNate
05/07/2024, 10:27 PMVlad S
05/08/2024, 5:43 PMVlad S
05/08/2024, 5:44 PMVlad S
05/08/2024, 5:45 PMNate
05/08/2024, 6:06 PMservices:
worker:
image: prefecthq/prefect:2-python3.12
restart: always
command:
[
"prefect",
"worker",
"start",
"--pool",
"docker-work",
"--install-policy",
"if-not-present"
]
env_file:
- ../../.env
ports:
- "8081:8081" # if you want healthchecks, otherwise not necessary
volumes:
- /var/run/docker.sock:/var/run/docker.sock
environment:
- DOCKER_HOST=unix:///var/run/docker.sock
Nate
05/08/2024, 6:07 PMvolumes:
- /var/run/docker.sock:/var/run/docker.sock
environment:
- DOCKER_HOST=unix:///var/run/docker.sock
Vlad S
05/08/2024, 6:19 PMVlad S
05/09/2024, 4:02 PMVlad S
05/09/2024, 6:54 PMbenorbital
05/18/2024, 7:21 AM