Jorge Severino
09/06/2023, 10:20 PMflows/process_01/main.py
flows/process_01/queries/query1.sql
flows/process_01/queries/query2.sql
flows/process_01/queries/query3.sql
It works fine in my local development environment, and I have no problems running the deploy to Prefect Cloud, with a worker on aws EC2.
When running it from Prefect Cloud, I get an error like this:
FileNotFoundError: [Errno 2] No such file or directory: 'flows/process_01/queries/query1.sql'
Is there some configuration in deploy that I need to do, so that it considers non-python files?
My deploy file looks like this:
pull:
- prefect.deployments.steps.git_clone:
id: clone-step
repository: <https://gitlab.com/aaaaa/bbb.git>
branch: master
access_token: '{{ prefect.blocks.secret.gitlab-api-token }}'
- prefect.deployments.steps.pip_install_requirements:
directory: '{{ clone-step.directory }}'
requirements_file: requirements.txt
Jorge Severino
09/07/2023, 3:55 PM/tmp/tmpb10mhcdtprefect/repo-name/
os.getcwd() on local:
C:\Dir1\repo-name\flows\process_01\
Is it possible to set the working directory as the subfolder of the flow (on the example: /repo-name/flows/process_01/), so that os.getcwd() returns that path?Jake Kaplan
09/07/2023, 5:17 PMJorge Severino
09/07/2023, 8:23 PM- prefect.deployments.steps.set_working_directory:
directory: /home/prefect
I think changing working-dir works, but now I get an error with git clone command.
Flow could not be retrieved from deployment.
Traceback (most recent call last):
File "/home/prefect/.local/lib/python3.10/site-packages/prefect/deployments/steps/core.py", line 122, in run_steps
step_output = await run_step(step, upstream_outputs)
File "/home/prefect/.local/lib/python3.10/site-packages/prefect/deployments/steps/core.py", line 93, in run_step
result = await from_async.call_soon_in_new_thread(
File "/home/prefect/.local/lib/python3.10/site-packages/prefect/_internal/concurrency/calls.py", line 291, in aresult
return await asyncio.wrap_future(self.future)
File "/home/prefect/.local/lib/python3.10/site-packages/prefect/_internal/concurrency/calls.py", line 315, in _run_sync
result = self.fn(*self.args, **self.kwargs)
File "/home/prefect/.local/lib/python3.10/site-packages/prefect/deployments/steps/pull.py", line 231, in git_clone
raise RuntimeError(
RuntimeError: Failed to clone repository '<https://gitlab.com/repo/prefect-repo.git>' with exit code 128.
The above exception was the direct cause of the following exception:
Traceback (most recent call last):
File "/home/prefect/.local/lib/python3.10/site-packages/prefect/engine.py", line 394, in retrieve_flow_then_begin_flow_run
flow = await load_flow_from_flow_run(flow_run, client=client)
File "/home/prefect/.local/lib/python3.10/site-packages/prefect/client/utilities.py", line 51, in with_injected_client
return await fn(*args, **kwargs)
File "/home/prefect/.local/lib/python3.10/site-packages/prefect/deployments/deployments.py", line 217, in load_flow_from_flow_run
output = await run_steps(deployment.pull_steps)
File "/home/prefect/.local/lib/python3.10/site-packages/prefect/deployments/steps/core.py", line 150, in run_steps
raise StepExecutionError(f"Encountered error while running {fqn}") from exc
prefect.deployments.steps.core.StepExecutionError: Encountered error while running prefect.deployments.steps.git_clone
Do you have any idea what I'm doing wrong?
This is my code for the pull:
pull:
- prefect.deployments.steps.set_working_directory:
directory: /home/prefect
- prefect.deployments.steps.git_clone:
id: clone-step
repository: <https://gitlab.com/repo/prefect-repo.git>
branch: master
access_token: '{{ prefect.blocks.secret.gitlab-api-token }}'
- prefect.deployments.steps.pip_install_requirements:
directory: '{{ clone-step.directory }}'
requirements_file: requirements.txt
Jake Kaplan
09/07/2023, 8:36 PMJorge Severino
09/08/2023, 5:31 PMprefect.deployments.steps.set_working_directory
setting, it works on Prefect Cloud.
Maybe it's a permissions issue, and the process can't do the git clone in the new path. how can i validate that? since the worker is correctly configured in Prefect Cloud.Jake Kaplan
09/08/2023, 6:22 PMrun_shell_script
utility pull step to verify things:
https://docs.prefect.io/latest/guides/prefect-deploy/#utility-steps
I think you'll need to set stream output to True to see it but you can try things like checking the perms of the current dirJorge Severino
09/08/2023, 8:50 PMCURRENT_DIR = str(Path(__file__).parent.absolute())