Hi, trying out Prefect cloud, I have a Python scri...
# prefect-community
Hi, trying out Prefect cloud, I have a Python script that saves a png file using Matplotlib The method
takes in a
arg (below is some sample code):
Copy code
CWD = os.path.dirname(os.path.abspath(__file__)) # Get CWD
file_path = os.path.join(CWD, "picture.png") # Save in CWD
This all works fine when I am running it on my server using
, however, when it is registered on cloud, invoking a Quick Run results in the error :
PermissionError: [Errno 13] Permission denied: '/picture.png'
The error shows that
is unable to be parsed to the current working directory that the script is being run from when triggered from Cloud. Would appreciate any insight.. if it helps, I am getting data from Google Sheets, plotting it and sending it to Slack, so I'd like to Prefect this workflow.
I found out the reason - CWD was called when inside a @task decorator. Calling CWD outside the scope of that task works, but can I understand why?
It sounds like when you're running your flow locally, you're doing so with elevated permission (maybe
or as a user with access to that file?) but perhaps your agent/executor don't have those same permissions?
This doesn't get parsed when called from Prefect cloud ( but gets parsed when run locally via
, from within
Copy code
So the path resolves to just
. Writing to the root folder
is not allowed, hence
PermissionError: [Errno 13]
. The error is resolved when CWD gets called outside of