Thread
#prefect-community
    t

    Thomas Hoeck

    9 months ago
    Hi. I just started getting the following error when registering flows in our CI/CD pipeline. Is this happening for anyone else? We are running 0.15.10:
    Traceback (most recent call last):
    File "register_flows.py", line 20, in <module>
    register_flows(all_flows)
    File "register_flows.py", line 14, in register_flows
    prefect_client.register(
    File "/root/miniconda3/lib/python3.8/site-packages/prefect/client/client.py", line 1242, in register
    self.graphql(
    File "/root/miniconda3/lib/python3.8/site-packages/prefect/client/client.py", line 569, in graphql
    raise ClientError(result["errors"])
    prefect.exceptions.ClientError: [{'path': ['set_schedule_active'], 'message': "Required parameters were not supplied: {'version1', 'version2'}", 'extensions': {'code': 'INTERNAL_SERVER_ERROR'}}]
    Anna Geller

    Anna Geller

    9 months ago
    @Thomas Hoeck Do you have any Parameter tasks for which you didn’t specify default values?
    t

    Thomas Hoeck

    9 months ago
    yes. But is that required?
    @Anna Geller I have two parameters called "version1" and "version2".
    with no defaults.
    It might be related to that there is already a schedule on the flow using defaults from before the parameters were added.
    Anna Geller

    Anna Geller

    9 months ago
    @Thomas Hoeck the problem with that is that Prefect cannot run if it doesn’t know what value to use for those parameters. It’s always a good idea to include default values e.g.
    bucket_name = Parameter("bucket_name", default="prefectdata")
    Then, you can overwrite this value at runtime, when you manually start the flow run, but when it runs on schedule, it will use the default value
    t

    Thomas Hoeck

    9 months ago
    The problem happens at registerer time, not a runtime so you can registerer a flow with a Parameter with no default?
    @Anna Geller
    Or is it because it already has a schedule which uses defaults? @Anna Geller
    Anna Geller

    Anna Geller

    9 months ago
    @Thomas Hoeck can you show how you defined it? Yes, you can registerer a flow with a Parameter with no default. But you would only be able to run it e.g. via UI/API/CLI by providing those values explicitly.
    i.e. you couldn’t schedule such a flow. Since default parameter values are required to schedule flows, parameter_defaults can be specified directly on clocks e.g.
    clock1 = clocks.IntervalClock(start_date=now, 
                                    interval=datetime.timedelta(minutes=1), 
                                    parameter_defaults={"p": "CLOCK 1"})
    Kevin Kho

    Kevin Kho

    9 months ago
    I think this is what you are talking about right?
    So the Flow doesn’t inherit clock parameters for quick runs, which is why you still need to define defaults on the Flow or set required to False
    t

    Thomas Hoeck

    9 months ago
    Hmm. @Kevin Kho I tried registering the flow in a different name and then it registeres fine. I then deleted all versions of the flow, and tried registerering it in the old name and got
    prefect.exceptions.ClientError: [{'path': ['set_schedule_active'], 'message': "Required parameters were not supplied: {'version2', 'version1'}", 'extensions': {'code': 'INTERNAL_SERVER_ERROR'}}]
    @Anna Geller are schedules deleted in the cloud in the backend if you the delete a flow group, or will the apear again, if you register a flow with the same name?
    Anna Geller

    Anna Geller

    9 months ago
    @Thomas Hoeck afaik only the schedules you created via UI/API, not those set in a flow code. But really as long as you assign default parameter values, your registration and triggering flow will work. The issue you have is due to a lack of default parameter values.
    t

    Thomas Hoeck

    9 months ago
    @Anna Geller When I deleted the schedule (which was created in the UI) and then registered the flow (with parameters which without defaults) it worked. So I guess the registration is rejected because there existed a UI-created schedule which was not compatible with the Parameters on the flow.
    Anna Geller

    Anna Geller

    9 months ago
    @Thomas Hoeck the schedules created in the UI are applied via flow group settings which take precedence over flow settings set in code. You can read more about it here. Scheduled flow with Parameter tasks without default values won’t be able to run on schedule - you can read more here. Especially this section explains what I meant: