Skip to content

Model conversion #23

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

Merged
merged 3 commits into from
Sep 4, 2019
Merged

Model conversion #23

merged 3 commits into from
Sep 4, 2019

Conversation

ehdsouza
Copy link
Contributor

Now since the x-alternate-name is not present in the api definitions of major release, we can remove the _from_dict step to avoid potential errors received especially in import/ export workspace

@codecov
Copy link

codecov bot commented Aug 30, 2019

Codecov Report

Merging #23 into next will increase coverage by 0.18%.
The diff coverage is 100%.

Impacted file tree graph

@@            Coverage Diff             @@
##             next      #23      +/-   ##
==========================================
+ Coverage   97.99%   98.18%   +0.18%     
==========================================
  Files          16       16              
  Lines         498      495       -3     
==========================================
- Hits          488      486       -2     
+ Misses         10        9       -1
Impacted Files Coverage Δ
ibm_cloud_sdk_core/base_service.py 97.5% <100%> (+0.75%) ⬆️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update a76903e...fbdf3d4. Read the comment docs.

Copy link
Contributor

@mkistler mkistler left a comment

Choose a reason for hiding this comment

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

I think this could be simpler.

if isinstance(val, str):
val = json_import.loads(val)
val = classname._from_dict(dict(val))
if hasattr(val, "_to_dict"):
return val._to_dict()
return val
Copy link
Contributor

Choose a reason for hiding this comment

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

I think this method could be even simpler, since there is no longer any need for the classname parameter:

    def _convert_model(val):
        if isinstance(val, str):
            val = json_import.loads(val)
        if hasattr(val, "_to_dict"):
            return val._to_dict()
        return val

Copy link
Contributor

@mkistler mkistler left a comment

Choose a reason for hiding this comment

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

Looks good! 👍

@ehdsouza ehdsouza merged commit 771c8fe into next Sep 4, 2019
@ehdsouza ehdsouza deleted the model-conversion branch September 4, 2019 13:55
@watson-github-bot
Copy link

🎉 This PR is included in version 1.0.0 🎉

The release is available on GitHub release

Your semantic-release bot 📦🚀

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.

3 participants