Hi - Prefect Experts, Im running into an error tha...
# prefect-community
b
Hi - Prefect Experts, Im running into an error that indicates I am unable to schedule a flow that has required parameters. Is that expected? 🧵
1
1️⃣ 1
I found this issue that lead me to believe it should be supported. https://github.com/PrefectHQ/prefect/issues/1804
k
Can you trying adding a default parameter to your flow to see if there is still an error?
b
I tried that and it was still an issue.
We can remove the required flag, but then we just need some extra flow logic to make sure everything is populated when the flow is manually run.
k
What version of Prefect are you in? Do you mind giving a small example of your flow to see if I can reproduce?
b
We are running Prefect 1.3.0
Let me see if I can create a stripped down example.
I created a stripped down flow example and its working as I would expect. Im going to follow up with the person who raised the issue to me.
Copy code
@task(log_stdout=True)
def pprinter(val):
    print(val)


schedule = Schedule(
    # emit an event every day
    clocks=[
        IntervalClock(
            start_date=pendulum.datetime(2022, 9, 8, 8, tz="America/New_York"),
            interval=timedelta(days=2),
            parameter_defaults={
                "not_fake": "some_value",
            },
        )
    ],
)


def create_flow() -> Flow:
    with Flow(**nfp.flow_constructor(), schedule=schedule) as flow:
        fake = Parameter(name="fake", default="fake", required=True)
        not_fake = Parameter(name="note_fake", default="not_fake", required=True)

        pprinter(val="fake " + fake)
        pprinter(val="not_fake " + not_fake)

        flow.run_config = nfp.get_k8_config()
        flow.executor = nfp.get_dask_config(adapt_kwargs={"minimum": 2, "maximum": 2})
        return flow


FLOW = create_flow()
I tracked it down. If you have a parameter that is required and includes a default value you need to set the value in the
Schedule
or it will generate an error.
Copy code
Scheduling with parameters
Prefect cannot auto-schedule flows that have required parameters, because the scheduler won't know what value to use. You will get an error if you try to turn on scheduling for such a flow.
To resolve this, provide a default value for your parameters in your flow code or the schedule clock: