Agent Debugging & Agent Execution error with FTP Storage in Windows

Hi there, I have problem running my flow through agent. The flow has been successfully deployed with FTP RemoteStorage, and has no problem with default LocalStorage.

I am running the agent on Windows machine with local Prefect server API, the terimnal has been promoted to Administrator mode.

Here are error message from the agent:

15:02:36.537 | ERROR   | Flow run 'ebony-giraffe' - Flow could not be retrieved from deployment.
Traceback (most recent call last):
  File "C:\Users\Mike\Envs\prefect-worker\lib\site-packages\prefect\", line 256, in retrieve_flow_then_begin_flow_run
    flow = await load_flow_from_flow_run(flow_run, client=client)
  File "C:\Users\Mike\Envs\prefect-worker\lib\site-packages\prefect\", line 103, in with_injected_client
    return await fn(*args, **kwargs)
  File "C:\Users\Mike\Envs\prefect-worker\lib\site-packages\prefect\", line 54, in load_flow_from_flow_run
    await storage_block.get_directory(from_path=deployment.path, local_path=".")
  File "C:\Users\Mike\Envs\prefect-worker\lib\site-packages\prefect\", line 296, in get_directory
    return self.filesystem.get(from_path, local_path, recursive=True)
  File "C:\Users\Mike\Envs\prefect-worker\lib\site-packages\fsspec\", line 801, in get
    self.get_file(rpath, lpath, **kwargs)
  File "C:\Users\Mike\Envs\prefect-worker\lib\site-packages\fsspec\implementations\", line 136, in get_file
    outfile = open(lpath, "wb")
PermissionError: [Errno 13] Permission denied: 'C:/Users/Mike/AppData/Local/Temp/tmpdyhsl6o4prefect'
15:02:36.574 | DEBUG   | prefect.client - Using ephemeral application with database at sqlite+aiosqlite:///C:\Users\Mike\.prefect\orion.db
15:02:36.988 | INFO    | prefect.infrastructure.process - Process 'ebony-giraffe' exited cleanly.

Does anyone know what the problem is?

And if it is possible to debug the agent execution in VS Code? I found the prefect agent similar with Celery worker and have tried to configure the launch.json but it seems that the prefect.exe cannot be recogonized as a python module.

1 Like

Looks like you’re running the flow on a machine that doesn’t allow to write to that local directory, you can change that using:

prefect config set PREFECT_LOCAL_STORAGE_PATH='C:/Users/Mike/storage'

It seems that the config is not valid. I have tried to set the config to a new profile and deployed the flow again. The PREFECT_LOCAL_STORAGE_PATH is correctly configed according to Orion UI Settings. The agent is still trying to fetch code from FTP storage to default tmp folder.

The source code as follows seems to hardcode the localpath to ‘.’ rather not referring to the setting.

And I have altered the hardcoded ‘.’ to ‘C:/Users/Mike/storage’ but the error still occurs, prompting
PermissionError: [Errno 13] Permission denied: 'C:/Users/Mike/storage'

1 Like

I’d cross-check with your system admin, it looks like you have no permissions to that location