-
Notifications
You must be signed in to change notification settings - Fork 14.3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Allow optional defaults in required fields with manual triggered dags #31301
Allow optional defaults in required fields with manual triggered dags #31301
Conversation
I have a follow-up PR which I'd need to resolve conflicts once this one is merged and which would close the AIP-50. Therefore I'd like to get this PR merged. |
Conflicts generated by early merge of #31583 are now resolved, ready for re-review - hoping for a merge :-D |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM, however, we should do the trigger refactoring in a separate PR. Also, since this is a change in behaviour, I will move it to 2.7.0 because 2.6.2 is only for bug fixes
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think this is too relaxed for validation. validate_schedule_and_params
only check for nullable and default values where validate
did an actual Param.resolve
.
With this change, there is no actual type validation performed before bagging a Dag, and we have no import error if we provide a "string" default value for a 'number' param.
This will then crash the scheduler on the next scheduled run.
Thanks @pierrejeambrun for the feedback. I understand that not validating at-all is potentially opening the door too wide for "any" garbage not valid default param. I adjusted to validate a param if either the DAG is scheduled regularly (so default values must be valid) or if a default value is provided - only if no value or During the fix I found three other glitches in consistency, so I fixed this alongside, hope this is OK:
|
021b9fb
to
d5fa69c
Compare
…tional-defaults-in-required-fields-w-manual-triggered-dags
…tional-defaults-in-required-fields-w-manual-triggered-dags
Dear maintainer, another rebase because of a conflict. Propose to push this rather to 2.8.0 as it is not a critical bugfix, leftovers are rather 50% a function as well. Looking forward for another review. Status update: After a lot of fixes have been separated to other PRs which have been merged, the only "real" leftover change in this PR is actually one line: Other content of this PR is just according documentation and further pytests checking more conditions for valid and invalid parameters. |
.. note:: | ||
Schema validation on DAG definitions is only made if a schedule is defined. If a manual or external trigger | ||
is defined (e.g. via ``schedule=None``) then params are validated during submission. This allows to enforce | ||
undefined parameters being defined at trigger time. | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
.. note:: | |
Schema validation on DAG definitions is only made if a schedule is defined. If a manual or external trigger | |
is defined (e.g. via ``schedule=None``) then params are validated during submission. This allows to enforce | |
undefined parameters being defined at trigger time. | |
.. note:: | |
Schema validation on DAG definitions is only made if ``schedule`` is provided. If ``schedule=None`` then params are validated during submission. This allows to enforce | |
undefined parameters being defined at trigger time. | |
the sentence This allows to enforce undefined parameters being defined at trigger time.
remains confusing to me
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sorry, the not native speaker english... thanks for the feedback. Tried to re-phrase a bit - better now?
@@ -309,6 +313,10 @@ The following features are supported in the Trigger UI Form: | |||
If you want to change values manually, the JSON configuration can be adjusted. Changes are overridden when form fields change. | |||
- If you want to render custom HTML as form on top of the provided features, you can use the ``custom_html_form`` attribute. | |||
|
|||
.. note:: | |||
If the field is required you need to specify a valid default value as well. Exception is if DAG is defined with |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
what do you mean "valid default"
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sorry, the not native speaker english... thanks for the feedback. Tried to re-phrase a bit - better now?
…tional-defaults-in-required-fields-w-manual-triggered-dags
…tional-defaults-in-required-fields-w-manual-triggered-dags
…ired-fields-w-manual-triggered-dags
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Just a few nit, looking good.
…tional-defaults-in-required-fields-w-manual-triggered-dags
…ired-fields-w-manual-triggered-dags
…ired-fields-w-manual-triggered-dags
…ired-fields-w-manual-triggered-dags
…ired-fields-w-manual-triggered-dags
closes: #31299
This PR relaxes the DAG validation at parse time for JSON Param validation for DAGs which are triggered manual. For a manual triggered DAG the
params
are validated at time of trigger.This makes the current
DAG
class constructor/__init__()
validation consistent with the DAG parsing validation. which allows:params
for manually triggered DAGs w/o default values - to enforce users to really provide a value (w/o just hitting "Trigger" button and run a flow by accident with a bad default)Effects of change of this PR:
params
validations for scheduled DAGs keep the same as validparams
are needed for automated schedulingHow to test?
example_params_ui_tutorial
is also possible to be parsed w/o required field defaults (See bug report)example_params_ui_tutorial
DAG manual w/o filling required field, validation in form will block youexample_params_ui_tutorial
DAG via CLI:airflow dags trigger example_params_ui_tutorial
- should also block you with missing parameter (unless you add the missing param in the CLI call).Note: Some fixes which originally were contained in the PR are carved out and have been merged to main already. The "new" and current version of this PR is now based on the PR #34248