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

Python model to dict fix #8652

Closed

Conversation

code-lucidal58
Copy link
Contributor

@code-lucidal58 code-lucidal58 commented Feb 9, 2021

Fix #8651

PR checklist

  • Read the contribution guidelines.
  • Pull Request title clearly describes the work in the pull request and Pull Request description provides details about how to validate the work. Missing information here may result in delayed response from the community.
  • Run the following to build the project and update samples:
    ./mvnw clean package 
    ./bin/generate-samples.sh
    ./bin/utils/export_docs_generators.sh
    
    Commit all changed files.
    This is important, as CI jobs will verify all generator outputs of your HEAD commit as it would merge with master.
    These must match the expectations made by your contribution.
    You may regenerate an individual generator by passing the relevant config(s) as an argument to the script, for example ./bin/generate-samples.sh bin/configs/java*.
    For Windows users, please run the script in Git BASH.
  • File the PR against the correct branch: master, 5.1.x, 6.0.x
  • If your PR is targeting a particular programming language, @mention the technical committee members, so they are more likely to review the pull request.

@taxpon (2017/07) @frol (2017/07) @mbohlool (2017/07) @cbornet (2017/09) @kenjones-cisco (2017/11) @tomplus (2018/10) @Jyhess (2019/01) @arun-nalla (2019/11) @spacether (2019/11)

@@ -1217,7 +1217,7 @@ def model_to_dict(model_instance, serialize=True):
elif isinstance(value[0], ModelSimple):
result[attr] = [x.value for x in value]
else:
result[attr] = [model_to_dict(x, serialize=serialize) for x in value]
result[attr] = [model_to_dict(x, serialize=serialize) if hasattr(x, '_data_store') else x for x in value]
Copy link
Contributor

@spacether spacether Feb 9, 2021

Choose a reason for hiding this comment

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

@code-lucidal58 How about adding a test that will fail if this is broken? If that had existed then this bug would not have been introduced. What do you think?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Sure. Will add it

@spacether
Copy link
Contributor

spacether commented Apr 3, 2021

@code-lucidal58 I would like to help finish this PR by adding a schema in the python sample spec and then adding a test of it in the sample python client. Can you add me as a colaborator on your repo? Github is not letting me push to your branch in your repo.
Or do you prefer that I clone your branch into my repo and continue work in a separate new PR?

@code-lucidal58
Copy link
Contributor Author

@spacether It would be better if you clone my branch to your repo. This PR is very old now. Plus I won't be able to add you as a collaborator to CiscoM31 repo (the source repo in this PR) as it is Cisco's GitHub account.

@code-lucidal58
Copy link
Contributor Author

Closing this PR as the issue is resolved here #9153

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[BUG][Python] model_to_dict fails when x is a dictionary in model_utils.py
2 participants