Skip to content
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

[SDK] Adds consistent parameter validation #158

Merged
merged 5 commits into from
Jun 29, 2022

Conversation

kenxu95
Copy link
Contributor

@kenxu95 kenxu95 commented Jun 29, 2022

Describe your changes and why you are making these changes

Both get() and trigger() allow for execution of flows with different parameters. This pipes any user-defined dictionary of overriding parameters through the check_overwriting_parameters_are_valid() helper, which validates that the new parameter values in the dictionary can be used on the dag.

get() uses the dag of the artifact. trigger() now uses the latest run of the flow. If there isn't a run of the flow yet, it'll throw an exception.

Related issue number (if any)

ENG-1144

Checklist before requesting a review

  • [x ] I have performed a self-review of my code.
  • If this is a new feature, I have added unit tests and integration tests.
  • I have manually run the integration tests and they are passing.
  • [ N/A] All features on the UI continue to work correctly.

Copy link
Contributor Author

@kenxu95 kenxu95 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Designating @likawind as lead reviewer but tagged the other two in a question.

sdk/aqueduct/aqueduct_client.py Show resolved Hide resolved
), "New spec has a different type."

self.operators[str(op.id)].spec = spec
self.operator_by_name[op.name].spec = spec
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This seemed safer than the blind replace of operators we currently have. Plus, we can add additional validation on the operation.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What's the main downside of direct replacement?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's just bit uglier from the callers side, since editing an operator always requirements a fetch and replace. With this we can just construct the new spec from scratch. Replacing an operator fully might be better in the long term though, not sure.

@vsreekanti
Copy link
Contributor

I'll let @likawind do a more thorough review, but this looks good to me.

@kenxu95, I just realized we haven't discussed triggering with parameters from the UI. Shouldn't be hard to implement but let's talk about it in stand up this morning.

@vsreekanti vsreekanti closed this Jun 29, 2022
@vsreekanti vsreekanti reopened this Jun 29, 2022

if any(not isinstance(name, str) for name in self.parameters):
raise InvalidUserArgumentException("Parameters must be keyed by strings.")
check_overwriting_parameters_are_valid(dag, self.parameters)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

maybe validate_overwriting_parameters ?

Copy link
Contributor

@likawind likawind left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Great! I think this type of checking could be generalized to ensure all operator inputs are properly typed (e.g. you shouldn't pass a string params to an df function), but that's not immediate.

@kenxu95 kenxu95 added run_integration_test Triggers integration tests labels Jun 29, 2022
@kenxu95 kenxu95 merged commit eb0f0a2 into main Jun 29, 2022
@kenxu95 kenxu95 deleted the eng-1144-catch-bad-parameter-values-earlier-on-in branch June 29, 2022 23:19
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
run_integration_test Triggers integration tests
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants