-
Notifications
You must be signed in to change notification settings - Fork 16.4k
remove params.validate call in validate_params #59653
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
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -123,6 +123,21 @@ def test_validate_options(self) -> None: | |
| ) | ||
| hitl_op.validate_options() | ||
|
|
||
| def test_init_allow_no_default_param(self): | ||
| try: | ||
| op = HITLOperator( | ||
| task_id="wait_for_human", | ||
| subject="Please input data", | ||
| options=["Submit"], | ||
| params={"user_input_data": Param(type="string", description="No default here!")}, | ||
| ) | ||
| except Exception as e: | ||
| pytest.fail(f"Initialization failed with exception: {e}") | ||
|
|
||
| param_obj = op.params.get_param("user_input_data") | ||
| assert isinstance(param_obj, Param) | ||
| assert "user_input_data" in op.params | ||
|
|
||
| def test_validate_options_with_empty_options(self) -> None: | ||
| # validate_options is called during initialization | ||
| with pytest.raises(ValueError, match='"options" cannot be empty.'): | ||
|
|
@@ -138,19 +153,7 @@ def test_validate_options_with_empty_options(self) -> None: | |
|
|
||
| @pytest.mark.parametrize( | ||
| ("params", "exc", "error_msg"), | ||
| ( | ||
| (ParamsDict({"_options": 1}), ValueError, '"_options" is not allowed in params'), | ||
| ( | ||
| ParamsDict({"param": Param("", type="integer")}), | ||
| ParamValidationError, | ||
| ( | ||
| "Invalid input for param param: '' is not of type 'integer'\n\n" | ||
| "Failed validating 'type' in schema:\n" | ||
| " {'type': 'integer'}\n\n" | ||
| "On instance:\n ''" | ||
| ), | ||
| ), | ||
| ), | ||
|
Comment on lines
-144
to
-153
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Thanks for proposing the change. Wonder if this test case is removed. I think it is checking for the situation "when a default value is provided for the param, the default value should be valid for the type". the proposed change seems to make the default value optional, but we should probably keep this test case for the situation that default is provided. |
||
| ((ParamsDict({"_options": 1}), ValueError, '"_options" is not allowed in params'),), | ||
| ) | ||
| def test_validate_params( | ||
| self, params: ParamsDict, exc: type[ValueError | ParamValidationError], error_msg: str | ||
|
|
||
Uh oh!
There was an error while loading. Please reload this page.
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 would like to share an observation that may help understand the things happen behind. When the DAG is executed, the params will be written to the metadata store. The
self.params.validate()include a step checking whether the value is json-serializable.Here, it is called in the
__init__, and the DB write not yet happens, so it may be a little over strict here, but I am interested to understand different views on why we should call this validation here.