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

Add parameter info to argo workflow template annotations #1549

Merged
merged 6 commits into from Oct 12, 2023

Conversation

rohanrebello
Copy link
Contributor

@rohanrebello rohanrebello commented Sep 26, 2023

This PR adds information on which parameters are required, to the annotations section of argo-workflow templates. This can be used to validate the well-formed-ness of workflow submissions before submitting the workflow to argo-workflows. Before this PR the only way to validate parameters was to submit the workflow and wait until metaflow runs within the argo-workflow, only to fail at parameter validation. After this change, we can fail-fast and, in the process, save on compute as well as etcd storage.

Manually tested for the following parameter types both locally and in argo-workflows:

metaflow/plugins/argo/argo_workflows.py Outdated Show resolved Hide resolved
@rohanrebello rohanrebello changed the title Add parameter-required info to template annotations Add parameter info to template annotations Oct 6, 2023
@rohanrebello rohanrebello changed the title Add parameter info to template annotations Add parameter info to argo workflow template annotations Oct 7, 2023
@@ -40,7 +40,7 @@


class JSONTypeClass(click.ParamType):
name = "JSON"
name = __name__ = "JSON"
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Needed to supply the type information in a standardized way across all types. The rest of the types are builtins which already have this field.

@@ -401,6 +401,8 @@ def _process_parameters(self):
)
seen.add(norm)

param_type = str(param.kwargs.get("type").__name__)
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Flatten the type information to a string instead of the type Object (which isn't serializable either). Use just the name of the type rather than the <class '...'> stuff.

parameters[param.name] = dict(
name=param.name,
value=value,
value=default_value,
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 would be nice to rename this in the parameter map too but I didn't want to get too ambitious, especially since it's serialized in the argo workflow template as value again. #ifItAintBroke

obgibson
obgibson previously approved these changes Oct 7, 2023
Copy link
Collaborator

@obgibson obgibson left a comment

Choose a reason for hiding this comment

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

Confirmed UI is getting

"metaflow/parameters": "{\"alpha\": {\"name\": \"alpha\", \"value\": \"0.01\", \"type\": \"float\", \"description\": \"Learning rate\", \"is_required\": false}, \"Booly\": {\"name\": \"Booly\", \"value\": null, \"type\": \"bool\", \"description\": null, \"is_required\": true}}",

saikonen
saikonen previously approved these changes Oct 10, 2023
@rohanrebello rohanrebello dismissed stale reviews from saikonen and obgibson via a46965a October 10, 2023 18:33
Comment on lines +405 to +406
if param.kwargs.get("type") == JSONType or isinstance(
param.kwargs.get("type"), FilePathClass
Copy link
Contributor Author

Choose a reason for hiding this comment

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

@savingoyal should I use isinstance() for both comparisons? For some reason I didn't fully understand, only the FilePathClass required the use of it and it failed with the == comparison.

@@ -574,6 +584,10 @@ def _compile_workflow_template(self):
"metaflow/user": "argo-workflows",
"metaflow/flow_name": self.flow.name,
}

if self.parameters:
annotations.update({"metaflow/parameters": json.dumps(self.parameters)})
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Serialize the parameters dictionary into the metaflow/parameters annotation for consumers to deserialize.

@savingoyal savingoyal merged commit 0c49524 into Netflix:master Oct 12, 2023
18 of 19 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants