Vijay K J
11/16/2023, 2:36 PMFlow could not be retrieved from deployment.
Traceback (most recent call last):
File "/usr/local/lib/python3.10/site-packages/prefect/projects/steps/core.py", line 111, in run_steps
step_output = await run_step(step, upstream_outputs)
File "/usr/local/lib/python3.10/site-packages/prefect/projects/steps/core.py", line 91, in run_step
step_func = _get_function_for_step(fqn, requires=keywords.get("requires"))
File "/usr/local/lib/python3.10/site-packages/prefect/projects/steps/core.py", line 41, in _get_function_for_step
step_func = import_object(fully_qualified_name)
File "/usr/local/lib/python3.10/site-packages/prefect/utilities/importtools.py", line 212, in import_object
module = load_module(module_name)
File "/usr/local/lib/python3.10/site-packages/prefect/utilities/importtools.py", line 183, in load_module
return importlib.import_module(module_name)
File "/usr/local/lib/python3.10/importlib/__init__.py", line 126, in import_module
return _bootstrap._gcd_import(name[level:], package, level)
File "<frozen importlib._bootstrap>", line 1050, in _gcd_import
File "<frozen importlib._bootstrap>", line 1027, in _find_and_load
File "<frozen importlib._bootstrap>", line 1001, in _find_and_load_unlocked
ModuleNotFoundError: No module named 'prefect.deployments.steps'; 'prefect.deployments' is not a package
The above exception was the direct cause of the following exception:
Traceback (most recent call last):
File "/usr/local/lib/python3.10/site-packages/prefect/engine.py", line 331, in retrieve_flow_then_begin_flow_run
flow = await load_flow_from_flow_run(flow_run, client=client)
File "/usr/local/lib/python3.10/site-packages/prefect/client/utilities.py", line 40, in with_injected_client
return await fn(*args, **kwargs)
File "/usr/local/lib/python3.10/site-packages/prefect/deployments.py", line 202, in load_flow_from_flow_run
output = await run_steps(deployment.pull_steps)
File "/usr/local/lib/python3.10/site-packages/prefect/projects/steps/core.py", line 125, in run_steps
raise StepExecutionError(f"Encountered error while running {fqn}") from exc
prefect.projects.steps.core.StepExecutionError: Encountered error while running prefect.deployments.steps.set_working_directory
Marvin
11/16/2023, 2:37 PMwith Flow()
syntax and flow.run()
are now obsolete. The new way to define flows/tasks is using the @flow
and @task
decorators. Subflows are just flows called from within a flow. Instead of my_flow.run()
, you just call flows now.
I would recommend checking your Prefect version and ensuring your code is compatible with that version. If you're using an older version of Prefect, you might need to update your code to use the new syntax. If you're using the latest version and still encountering this issue, it might be a bug and you should consider reporting it to the Prefect team.Vijay K J
11/16/2023, 2:44 PMMarvin
11/16/2023, 2:45 PMprefect deploy
command is not obsolete. It is used to deploy your flows. You can deploy all the flows with prefect deploy --all
or deploy them individually by name, for example: prefect deploy -n hello/default
.
Before deploying, make sure your Docker daemon is running. Once the deployments are successfully created, you can run them from the UI or the CLI.
You can initialize your deployment configuration, which creates the prefect.yaml
file, by running the CLI command prefect init
in any directory or repository that stores your flow code. Prefect ships with many off-the-shelf "recipes" that allow you to get started with more structure within your prefect.yaml
file. Run prefect init
to be prompted with available recipes in your installation. You can provide a recipe name in your initialization command with the --recipe
flag.Vijay K J
11/16/2023, 2:48 PMprefect init
and prefect deploy
to generate the deployment configuration. However, the last step is to set the working directory which fails while running the flow
pull:
- prefect.deployments.steps.set_working_directory:
directory: /opt/prefect
Marvin
11/16/2023, 2:48 PMset_working_directory
step in your prefect.yaml
file. This step is supposed to set the working directory for your flow, but it's failing for some reason.
Unfortunately, I couldn't find specific information about this error in the Prefect documentation or community resources. It's possible that this is a bug or an issue specific to your environment or configuration.
Here are a few things you could try:
1. Make sure the directory /opt/prefect
exists and is accessible. The error could be due to the directory not existing or the user running the flow not having the necessary permissions to access it.
2. Try using an absolute path for the directory. If you're already doing this, try using a relative path instead.
3. If you're running this in a Docker container, make sure the directory is correctly mounted in the container.
4. Check the Prefect version you're using. If you're not using the latest version, try upgrading to see if that resolves the issue.
If none of these suggestions help, I would recommend reaching out to the Prefect community or support for further assistance. They might be able to provide more specific guidance based on your exact configuration and environment.