https://prefect.io logo
Title
j

Jason

04/26/2022, 2:29 PM
I'm having trouble locating the local_script_path:
return os.stat(filename).st_size
      FileNotFoundError: [Errno 2] No such file or directory: 'hello-flow.py'
The S3 storage class is configured in a shared module between flows as such:
storage = S3(
                bucket="EDITED-prod-platform-prefect",
                key=f"{project}/flows/{flow_name}.py",
                stored_as_script=True,
                local_script_path=f"projects/Examples/flows/{flow_name}.py",
            )
k

Kevin Kho

04/26/2022, 2:42 PM
There’s nothing fancy with the local_script_path, it just gets passed to boto3 directly here and this local script relative path should work.
hello-flow
is flow name in this example?
I had no problems here:
from prefect import Flow, task
from prefect.storage import S3
@task
def abc():
    return 1

with Flow('s3 test') as flow:
    abc()

flow.storage = S3(bucket="coiled-prefect", key="shoe-flow.py",
                  stored_as_script=True,
                  local_script_path="shoe-flow.py",)
flow.register("databricks")
where my file was named
shoe-flow.py
j

Jason

04/26/2022, 3:22 PM
But that's the same path as your flow? I think my issue is using a shared module. Relative pathing doesn't seem to fix it either:
return os.path.getsize(filename)
        File "/opt/hostedtoolcache/Python/3.9.12/x64/lib/python3.9/genericpath.py", line 50, in getsize
    return os.stat(filename).st_size
      FileNotFoundError: [Errno 2] No such file or directory: './projects/Examples/flows/hello-flow.py'
But if I run this from a parent-level notebook, it's fine:
path.exists('./projects/Examples/flows/')
k

Kevin Kho

04/26/2022, 3:24 PM
Just confirming this is during registration time right?
So you mean you are trying to register a file in another directory?
j

Jason

04/26/2022, 3:41 PM
Oh, flow-name != file-name in my example. My bad. Solved 🙂
k

Kevin Kho

04/26/2022, 3:51 PM
oh lol