https://prefect.io logo
#prefect-community
Title
# prefect-community
s

Samarth

06/09/2022, 2:35 PM
Hey, have a question: • Using Prefect 1.0 • Using
Local
storage and
Prefect Cloud
I want to use
stored_as_script=True
for my flow (pickle storage is not working with an SQLAlchemy object for some reason), and so I need to specify
path
— but that is giving me an error. Sharing the relevant code snippet and error.
Copy code
with Flow(
        "eco_flow", 
        schedule=schedule, 
        storage=Local(stored_as_script=True, path='~/.prefect/flows/test-flow.py')
    ) as flow:

    cities = ['mumbai', 'new-delhi']
    
    for city in cities:
        data = get_traffic_data(city)  
        clean_data = clean_traffic_data(data)
        insert_to_db(clean_data)
Error after registering the flow:
Failed to load and execute flow run: ModuleNotFoundError("No module named '~/'")
I guess I am defining the
path
incorrectly?
k

Kevin Kho

06/09/2022, 2:47 PM
I think you might to spell it out because that is not unpacked and then Prefect tries to import the Flow.
Copy code
from path... import flow
like that
s

Samarth

06/09/2022, 3:29 PM
Discussed this with Kevin on DM and it's now sorted. I had a conceptual misunderstanding re how script storage works. I was pointing to a non-existent flow file as I assumed that prefect will generate it automatically when the flow is registered — which is incorrect. The path needs to point to the flow script. That fixed the error. Thanks Kevin!
2 Views