Thread
#prefect-server
    a

    Andrew Stewart

    7 months ago
    Hello! I'm new to prefect and I'm trying to use the prefect cli to register my a flow. Every time I run it, it returns with "0 registered." I even tried to register one of the tutorial programs (command: prefect register --project "misc" --path 03_parameterized_etl_flow.py) and it did the same thing. I was able to get one flow to register using the flow.register() method in my script, but I can't get the cli to detect my flows.
    Kevin Kho

    Kevin Kho

    7 months ago
    Hi @Andrew Stewart! Welcome to Prefect. Are you doing this command in the directory with the file?
    a

    Andrew Stewart

    7 months ago
    Yes. I'm on Windows if it matters.
    Kevin Kho

    Kevin Kho

    7 months ago
    Could you show me the log? Does it detect nothing? Or detect no flow with changes?
    Do you see this:
    Collecting flows...
    ======================== 0 registered ========================
    or
    Registering 'unique logger'... Skipped (metadata unchanged)
    ================== 0 registered, 1 skipped ==================
    What Prefect version are you on?
    a

    Andrew Stewart

    7 months ago
    I'm on version 0.15.13
    Kevin Kho

    Kevin Kho

    7 months ago
    can you try providing an absolute path?
    that’s very weird. might be a bug on windows
    Michael Adkins

    Michael Adkins

    7 months ago
    Can you share the contents of the file you’re passing?
    a

    Andrew Stewart

    7 months ago
    Absolute path doesn't work either.
    I just discovered "prefect run" doesn't work either, but running the script in python works.
    @Michael Adkins I started trying it with some custom flows that I wrote, but right now I'm literally trying to register one of the tutorial files from the docs/github.
    Michael Adkins

    Michael Adkins

    7 months ago
    You are defining your flow in a function then only calling that function if your file is run as a script
    So when
    prefect run
    or
    prefect register
    look for flows in your file, we do not find them.
    You could do something like this instead:
    def get_flow():
        with Flow("etl") as flow:
            airport = Parameter("airport", default="IAD")
            radius = Parameter("radius", default=200)
        
            reference_data = extract_reference_data()
            live_data = extract_live_data(airport, radius, reference_data)
        
            transformed_live_data = transform(live_data, reference_data)
        
            load_reference_data(reference_data)
            load_live_data(transformed_live_data)
       return flow
    
    flow = get_flow()
    
    
    if __name__ == "__main__":
        flow.run(airport="DCA", radius=10)
    a

    Andrew Stewart

    7 months ago
    OK, thank you! I was writing my own scripts using those tutorial files as a template, so that must be my problem there.
    So, you need to have initialized flow objects in the main body of the program for it register them?
    Kevin Kho

    Kevin Kho

    7 months ago
    Yes because it evaluates the script then looks for Flow objects and pulls them for registration