Hey, have a question: - Using Prefect 1.0 - Using ...
# prefect-community
s
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
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
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!