When I run a flow without using all the parameters...
# ask-community
j
When I run a flow without using all the parameters I get an error Flow:
Copy code
with Flow("ROI Report Generator") as flow:

    start_date = Parameter(name="start_date")
    end_date = Parameter(name="end_date")
    to_list = Parameter(name="to_list")
    email_domain = Parameter(name="email_domain", default="")
    account_uuid = Parameter(name="account_uuid")
Run:
Copy code
state = flow.run(
            account_uuid=527132950,
            start_date="2020-11-01",
            email_domain="",
            end_date=None,
            to_list=["<mailto:jeff.newburn@logikcull.com|jeff.newburn@logikcull.com>"],
        )
Error:
Copy code
TypeError: run() got an unexpected keyword argument 'account_uuid'
Can someone help me understand what is going on here? Why do Parameters have to be used in a flow for the flow not to explode?
k
flow.run()
has a dict for parameters.
flow.run(parameters={'account_uuid': 527132950})
. You can set
Parameter(name="xxx", required=False)
j
I am a bit confused. I am passing in all the required parameters and the flow works as long as all the parameters are used in tasks. But in the example if the flow doesn’t use the parameters in some task it gets an error for the keyword arguments.
k
Ah I know what you mean now. I would need to ask some other team members tomorrow since today is a holiday
j
Cool It isn’t critical just seems really odd.
k
Hey, this is because the task is being created but not called.
Parameter()
creates it, but passing it somewhere is the one that actually calls it. Without using it, the Parameter doesn’t get registered because it’s a task that wasn’t used. To avoid this, you might be able to do:
Copy code
with Flow("ROI Report Generator") as flow:

    start_date = Parameter(name="start_date")()
    end_date = Parameter(name="end_date")()
Only tasks that are called end up being registered
j
Ah ok thank you for that! makes sense