Sonia Goyal
05/31/2023, 11:55 AMState Message
Flow could not be retrieved from deployment. Traceback (most recent call last): File "<frozen importlib._bootstrap_external>", line 846, in exec_module File "<frozen importlib._bootstrap_external>", line 982, in get_code File "<frozen importlib._bootstrap_external>", line 1039, in get_data FileNotFoundError: [Errno 2] No such file or directory: 'flow_name.py' The above exception was the direct cause of the following exception: ScriptError: Script at 'flow_name.py' encountered an exception: FileNotFoundError(2, 'No such file or directory')
Below is our dir structure in github
└── src
├── dev
│ └── flows
│ ├── flow
│ │ ├── README.md
│ │ ├── flow_name.py
│ │ ├── flow_deployment.py
And the deployment file is like this
from flow import flow
from prefect.blocks.system import JSON
from prefect.deployments import Deployment
from prefect.filesystems import GitHub
storage = GitHub.load("gh-poc")
FLOW_NAME = "flow_name"
deployment = Deployment.build_from_flow(
flow=flow_name,
name=FLOW_NAME,
parameters={},
storage=storage,
path="src/dev/flows/flow_name",
skip_upload=True,
)
if __name__ == "__main__":
deployment.apply()
print("Deployment applied")
Christopher Boyd
05/31/2023, 12:57 PM/src/dev/flows/flow/flow_name
Christopher Boyd
05/31/2023, 12:57 PMpath="src/dev/flows/flow_name",
Christopher Boyd
05/31/2023, 12:58 PMpath=/src/dev/flows/flow,
entrypoint=flow_name.py:<flow definition function>
Sonia Goyal
05/31/2023, 1:35 PMSonia Goyal
05/31/2023, 1:36 PMChristopher Boyd
05/31/2023, 1:37 PMChristopher Boyd
05/31/2023, 1:38 PMChristopher Boyd
05/31/2023, 1:38 PMChristopher Boyd
05/31/2023, 1:38 PMpath
it’s being retrieved from /src/dev/flows/flow_name
from the github blockSonia Goyal
05/31/2023, 1:58 PMpath="src/dev/flows/flow_name",
Mitch
07/12/2023, 4:06 PMDownloading flow code from storage at 'performance-aggregation-table'
FileNotFoundError: [Errno 2] No such file or directory: '/opt/prefect/performance-aggregation-table'
└── githubrepo
├── performance-aggregation-table
│ └── performance_aggregation_table.py
github_block = GitHub(
repository = "XXX",
reference = "github-test", #Branch name
access_token ="XXX",
)
deployment = Deployment.build_from_flow(
path="performance-aggregation-table",
entrypoint="performance_aggregation_table.py:run_perf_agg",
Mitch
07/12/2023, 4:09 PMChristopher Boyd
07/12/2023, 4:14 PM/opt/prefect
would be the default working directory that a clone would occur intoChristopher Boyd
07/12/2023, 4:14 PM/opt/prefect
will contain the directory of the GitHub block, which would then contain your flowChristopher Boyd
07/12/2023, 4:15 PMChristopher Boyd
07/12/2023, 4:16 PMtest-repo
then the path is /opt/prefect/test-repo
and the entrypoint is performance_aggregation_table.py:run_perf_agg
Mitch
07/12/2023, 4:24 PMMitch
07/12/2023, 4:31 PMposition-pnl-pipeline
is performance-aggregation-table/performance_aggregation_table.py
path="/opt/prefect/position-pnl-pipeline/performance-aggregation-table",
entrypoint="performance_aggregation_table.py:run_perf_agg",
Downloading flow code from storage at '/opt/prefect/position-pnl-pipeline/performance-aggregation-table'
Flow could not be retrieved from deployment.
Traceback (most recent call last):
File "/opt/pysetup/.venv/lib/python3.10/site-packages/prefect/engine.py", line 395, in retrieve_flow_then_begin_flow_run
flow = await load_flow_from_flow_run(flow_run, client=client)
File "/opt/pysetup/.venv/lib/python3.10/site-packages/prefect/client/utilities.py", line 51, in with_injected_client
return await fn(*args, **kwargs)
File "/opt/pysetup/.venv/lib/python3.10/site-packages/prefect/deployments/deployments.py", line 199, in load_flow_from_flow_run
await storage_block.get_directory(from_path=deployment.path, local_path=".")
File "/opt/pysetup/.venv/lib/python3.10/site-packages/prefect/filesystems.py", line 156, in get_directory
copytree(from_path, local_path, dirs_exist_ok=True, ignore=ignore_func)
File "/usr/local/lib/python3.10/shutil.py", line 557, in copytree
with os.scandir(src) as itr:
FileNotFoundError: [Errno 2] No such file or directory: '/opt/prefect/position-pnl-pipeline/performance-aggregation-table'
Mitch
07/12/2023, 4:50 PMChristopher Boyd
07/12/2023, 6:00 PMprefect deploy
way? I’ll be honest, it’s been a hot minute since I’ve done the pythonic deployment + a github repo block, so it’s possible my steps aren’t right here either. It looks like it’s trying to download from that path (first line) not the cloned repoMitch
07/12/2023, 6:03 PMMitch
07/12/2023, 6:44 PMChristopher Boyd
07/12/2023, 7:04 PMMitch
07/13/2023, 4:04 PM