https://prefect.io logo
#prefect-server
Title
# prefect-server
a

Andrew Stewart

02/09/2022, 3:05 PM
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.
k

Kevin Kho

02/09/2022, 3:10 PM
Hi @Andrew Stewart! Welcome to Prefect. Are you doing this command in the directory with the file?
a

Andrew Stewart

02/09/2022, 3:11 PM
Yes. I'm on Windows if it matters.
k

Kevin Kho

02/09/2022, 3:11 PM
Could you show me the log? Does it detect nothing? Or detect no flow with changes?
Do you see this:
Copy code
Collecting flows...
======================== 0 registered ========================
or
Copy code
Registering 'unique logger'... Skipped (metadata unchanged)
================== 0 registered, 1 skipped ==================
What Prefect version are you on?
a

Andrew Stewart

02/09/2022, 3:14 PM
I'm on version 0.15.13
k

Kevin Kho

02/09/2022, 3:16 PM
can you try providing an absolute path?
that’s very weird. might be a bug on windows
z

Zanie

02/09/2022, 3:19 PM
Can you share the contents of the file you’re passing?
a

Andrew Stewart

02/09/2022, 3:27 PM
Absolute path doesn't work either.
I just discovered "prefect run" doesn't work either, but running the script in python works.
@Zanie 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.
z

Zanie

02/09/2022, 3:37 PM
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:
Copy code
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)
🙌 1
a

Andrew Stewart

02/09/2022, 3:43 PM
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?
k

Kevin Kho

02/09/2022, 4:02 PM
Yes because it evaluates the script then looks for Flow objects and pulls them for registration
🙏 1
4 Views