Scott Asher

    Scott Asher

    1 year ago
    I’m still seeing this error, even with my flow entirely created in the main script:
    File "/usr/scratch/sasher/pyenvs/prefect/lib/python3.6/site-packages/prefect/utilities/storage.py", line 85, in extract_flow_from_file
        raise ValueError("No flow found in file.")
    ValueError: No flow found in file.
    Full code:
    from prefect import Flow
    from prefect.environments import LocalEnvironment
    from prefect.environments.storage import Local
    
    
    
    import logging
    logging.getLogger(__name__)
    
    if __name__ == "__main__":
        with Flow(
            "Daily DAG",
            environment=LocalEnvironment(),
            storage=Local(stored_as_script=True, path=__file__)
        ) as flow:
            from x import construct_dag, prefectize
            tasks = prefectize(construct_dag(), flow)
            for task in tasks:
                flow.add_task(task)
    I’m game to try another type of storage, but I’m concerned about pickling for my complicated classes.
    Michael Adkins

    Michael Adkins

    1 year ago
    if __name__ == "__main__":
    is not true when
    extract_flow_from_file
    is run. It loads the code from your file and then executes it (but not as a script i.e. not in the main thread) then looks for your variable.
    Scott Asher

    Scott Asher

    1 year ago
    ah, i’m an idiot, now i understand what you’re saying
    i totally misread your colleague’s response before
    Michael Adkins

    Michael Adkins

    1 year ago
    🙃 it happens
    Goofy python behavior