-
Notifications
You must be signed in to change notification settings - Fork 3.2k
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
Python SDK - Steps Template not serialized correctly with model_to_dict
#7374
Comments
Do you see any exceptions like in #7293? |
@terrytangyuan I'm not submitting the constructed workflow with the API. At the moment I'm only interested in constructing a valid YAML, so I don't think that should be relevant? |
I see. That's an interesting use case. How are you planning to submit the constructed workflow? K8s Python SDK? |
Or just plain |
This might be an issue with openapi-gen's generated |
@flaviuvadan Any thoughts? |
this makes me slightly nervous because what if there are other Argo objects which need to be hacked like this? |
I would guess other objects are experiencing the same issue. A couple of options:
|
Re 1 and 2 - is there an easy way to generate a list of all Argo objects? So that you can just use the hack in a for loop. Re 3 - I'm up for looking into the logic a bit, and as you said, maybe others have ideas here too. |
You should be able find the list in the models module (with a filtering): https://github.com/argoproj/argo-workflows/blob/master/sdks/python/client/argo_workflows/models/__init__.py#L213-L343 |
This line appears to be the issue: https://github.com/argoproj/argo-workflows/blob/master/sdks/python/client/argo_workflows/model_utils.py#L1658 When the function recursively gets to [{'name': 'mySteps', 'template': 'whalesay'}] As such, it will be captured by the case on L1658, and its I think the fix should be to an additional boolean check to L1658 that ensures that TL;DR This issue should appear anytime we nest anything except a non-iterable primitive under a EDIT: I've revised this post as I believe what I said before was incorrect. It should now be accurate. I have tested my proposed "fix" of adding an additional check to L1658 which seems to work, though I am not 100% confident its full-proof as I am not totally familiar with the inner workings of the SDK. |
Ok so here is an interesting thing I noticed, following up on my previous post: the class EDIT: The docstring for |
this issue appears to be relevant, which explains a uniqueness of ParallelSteps regarding serialization: #2454 |
openapi_types = {
}
attribute_map = {
} The object has a method called "io.argoproj.workflow.v1alpha1.ParallelSteps": {
"type": "array",
"required": [
"steps"
],
"properties": {
"steps": {
"type": "array",
"items": {
"$ref": "#/definitions/io.argoproj.workflow.v1alpha1.WorkflowStep"
}
}
}
} with the original being: "io.argoproj.workflow.v1alpha1.ParallelSteps": {
"type": "array",
"items": {
"$ref": "#/definitions/io.argoproj.workflow.v1alpha1.WorkflowStep"
}
} I generated the SDK and was able to obtain the steps from the template, but now we have a This issue with OpenAPI seems to be the closest to what we have here - an issue with generating an object that "extends"/"overwrites" a primitive. #7363 suggests we downgrade OpenAPI to 4.x so that we (1) merge the PR in a stable way to auto-publish the SDK and (2) fix #7293. Going forward I think there are 2 approaches to fix this, and I'd love to discuss them, but maybe Alex should be involved:
I welcome any feedback on my analysis and proposed ways to move forward! I also played with the |
This would be a breaking change so we probably don't want to do it.
This will take time to get the fix in OpenAPI and require us to use the latest version of OpenAPI, which would introduce the more commonly seen issue #7293 back. @samuelBB Since this is a small use case, I'd recommend that we defer this to OpenAPI-gen itself to fix and use the workaround you found for now. Once this is fixed on OpenAPI-gen, we'll explore upgrading to see if this has been fixed. |
(1) I guess someone should open a new issue with OpenAPI-gen? (2) Regarding using the workaround I found: Perhaps I'm misunderstanding, but I thought that according to what @flaviuvadan commented above, under OpenAPI-4.x (which will be used in #7363), |
@flaviuvadan Anything else we need to/can address here before the v3.3 release? |
I think we need the custom object we discussed for passing to |
This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions. |
Bump. Assigning to @flaviuvadan to migrate the related code from Hera. |
This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions. |
This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. If this is a mentoring request, please provide an update here. Thank you for your contributions. |
This issue has been closed due to inactivity. Feel free to re-open if you still encounter this issue. |
Summary
Version. I am using the Python SDK on
master:latest
which at the moment corresponds to commit22b0326
(though the last commit to actually modify thesdks
folder appears to beaba6599
).Briefly, I am constructing a Workflow using the objects in the Python SDK which includes a
steps
template. When I try to serialize the object using themodel_to_dict
function, it appears that thesteps
template is not properly serialized to adict
but instead remains in its unserialized object form.Reproducible Example
Output:
Hack to temporarily fix the issue
On the other hand, when I add a custom YAML representer to again apply
model_to_dict
whenever the YAML dumper sees a WorkflowStep type, I do get the correct result. To expand, this is just adding the following before theyaml.dump
call:Now output is correct:
Hypotheses Regarding the Issue
While it's possible I am not specifying the Steps/WorkflowSteps correctly, I doubt this, as the type checking valdiation is not producing any error messages from this. I tried fiddling with this (removing the objects from a list, specifying as kwargs instead of args, etc) but to no avail.
As such, my hypothesis is that the recursive serialization in
model_to_dict
fails on the fact that Steps is specified with a nested list, so maybe it bottoms out before actually reaching the nested WorkflowStep object to serialize. Haven't traced exactly how, but thats my guess.Message from the maintainers:
Impacted by this bug? Give it a 👍. We prioritise the issues with the most 👍.
The text was updated successfully, but these errors were encountered: