Nick Hoffmann
04/11/2024, 3:31 AM/workdir/src/<package>
in the image (where /workdir
is set as the working directory in the image build process), and when registering a deployment to the server, it says the entrypoint is src/path/to/file:flow_function
as I would expect. However, when trying to actually run the deployment, it immediately fails with
Flow could not be retrieved from deployment.
Traceback (most recent call last):
File "", line 991, in exec_module
File "", line 1128, in get_code
File "", line 1186, in get_data
FileNotFoundError: [Errno 2] No such file or directory: '/opt/prefect/src/path/to/file.py'
which causes
prefect.exceptions.ScriptError: Script at 'src/path/to/file.py' encountered an exception: FileNotFoundError(2, 'No such file or directory')
So I am confused as to why Prefect is looking for it in /opt/prefect
.
I am trying creating the deployment with
my_flow.to_deployment(name="test-deployment", work_pool_name="my-work-pool")
and don't see anything in the documentation about changing the entrypoint or path when using .to_deployment()
.Nate
04/11/2024, 11:06 AM.deploy
? if so, you shouldn't need to_deployment
Nick Hoffmann
04/11/2024, 1:55 PMimport prefect
from dataclasses import dataclass
from typing import Optional, Any, List
@dataclass
class MyDeployment:
flow: prefect.Flow
name: str
kwargs: Dict[str, Any]
def generate_deployment_list() -> List[MyDeployment]:
# My custom logic for building parameter sets for each deployment
...
dep_list: List[MyDeployment] = generate_deployment_list()
dep_list = [dep.flow.to_deployment(name=dep.name, **dep.kwargs) for dep in dep_list]
prefect.deploy(*dep_list,
work_pool_name="my-work-pool",
image="my-image-built-in-CI",
build=False)
Nate
04/11/2024, 1:57 PMprefect.yaml
? this seems like a natural use case for itNate
04/11/2024, 1:59 PMNate
04/11/2024, 2:00 PMNick Hoffmann
04/11/2024, 2:00 PMprefect.yaml
fileNick Hoffmann
04/11/2024, 2:01 PMCOPY
line to copy source code into that /opt/prefect
path, but still no diceNate
04/11/2024, 2:12 PMNick Hoffmann
04/12/2024, 1:06 PMNate
04/12/2024, 1:07 PMNick Hoffmann
04/12/2024, 1:10 PM