Hi Everyone, I have added my flows in the Prefect...
# prefect-ui
a
Hi Everyone, I have added my flows in the Prefect, and I have facing an strange issue with the flow names. "The thing is flows run Okay when I trigger them manually but when they are triggered via schedular, they throw an error". Error:
Copy code
Failed due to a TypeError: xyz() missing 1 required positional argument: 'name' in the Prefect flow run.
Code snippet:
Copy code
@flow(flow_run_name=generate_flow_run_name, retries=3, validate_parameters=False, retry_delay_seconds=60, log_prints=True)
def xyz(name: str):
    xyz_task()


if __name__ == "__main__":
    xyz(name="myflow")
Any help would be much appreciated!!!
r
Hey ! When you are declaring name: str you are making the parameter mandatory because you are not sending a default value. When running it manually you have to supply this value but I think your deployment with the schedule is not setting this parameter, hence this error. Does it make sense ?
a
Hi Robin, thank you for your answer but the thing I don't understand is that when I call this function in main
xyz(name="myflow")
I am always specifying the name. As you can see but why it is not able to read it.
r
Because scheduling does not goes through ___name___ == “___main___” but a run triggered by the workpool
a
ah ok, seems like
if __name__ == "__main__":
is the problem here. because it example flows it is doing something similar but without ``if name == "__main__":``
Copy code
@flow(name="Hello Flow")
def hello_world(name="world"):
    message = print_hello(name)

hello_world("Marvin")
Thank you Robin
r
Yes exactly, here the default value is set to “world” so if your deployment does not specify the value ‘name’, it will be set to “world”