Skip to content

new(core): Creating the core package #1

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 13 commits into from
Mar 18, 2019
Merged

new(core): Creating the core package #1

merged 13 commits into from
Mar 18, 2019

Conversation

ehdsouza
Copy link
Contributor

@ehdsouza ehdsouza commented Mar 13, 2019

related to https://github.ibm.com/Watson/developer-experience/issues/6179

This PR contains move to a separate core, in addition:

  • Added python: 3.7 xenial support in travis
  • Moved _get_error_info and _get_error_message in Api_Exception class

@ehdsouza ehdsouza requested a review from padamstx March 13, 2019 14:29
@@ -0,0 +1,11 @@
[bumpversion]
current_version = 0.0.0
Copy link
Contributor

Choose a reason for hiding this comment

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

We need to make sure we don't use a 1.x version for the core package until we know it's stable

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Created an initial tag: v0.0.0 and ran semantic locally:

# 0.1.0 (https://github.com/IBM/python-sdk-core/compare/v0.0.0...v0.1.0) (2019-03-13)

### Features

    * core: create a separate core for IBM python SDK (2421459 (https://github.com/IBM/python-sdk-core/commit/2421459))

Copy link
Contributor

@germanattanasio germanattanasio left a comment

Choose a reason for hiding this comment

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

I'm going to wait until this PR is ready for review

.travis.yml Outdated
- provider: pypi
user: ehdsouza
password:
secure: eMssjS1Airz5MrmcEDAnKYnTlMLuzinX8JFsh4TB0A4t7GCes2a/mlvcoazAv2QZMQUKQMC++bAXYGGgXtsSQsfOYnRtojW4pRphxOZrlXlWFgCLGz/eHioamNZVbH+/P/OYjbLy5ZKSzp3M3bZxYqHcmGTq0sBeo5A2Ilkzu5P+D865Jqtn52brwh/xYq4XWeJeQN/BSLwdtPEtZYQXhQupAteNDAo2ON0FVyt0amINrjA0Qw+0k35g36wti+CsKn5fhbaHf6jjN0oRj8J8wPZieXLAUMdxscfBjUXJ8AK8E4H/wPI30IsaMus+1r85ekiDKZC5iukO6uqMARFywjX/eTIDbWxwKImQUgvVa2+gncre7GvZrHIFxhIDDkssH1IfC1fcw3mNY4vCO9df/vHStp3Kvi27GvsYJnfsbXXj6fAhokHtsrnrbpXFET6LghGQx3HgOKrlCQ1EI0Fk92Qw7+g15jwMGlkwUE1qMS+PVOe7dQ4ikxJgw4CVrqU6/zaLFHV8LXFfjv166ZSWcOJHJXGgJ2TPuGiooL60+pWp/UYY00hZVlYX0Vlks6zN0h9zJd16kR3EwDrW0muqFnLC2xTuv5WsCjsOATtsTQzmBNEdCbGdOskgF4+0yPe7ps3kEs3UpAooKtYVh1OOJAUkl4vSMyu4Jg1ASyQWt00=
Copy link
Contributor

Choose a reason for hiding this comment

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

Will this work?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@germanattanasio followed these steps for encrypting key: https://docs.travis-ci.com/user/deployment/pypi/

Copy link
Member

@padamstx padamstx 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 a few minor things need to be addressed, and then also try to remove any additional watson-specific things that were copied from the python-sdk that shouldn't really be in a generic core package that will be shared with other SDK implementations.

self.transactionId = None
self.globalTransactionId = None
if httpResponse is not None:
self.transactionId = httpResponse.headers.get('X-DP-Watson-Tran-ID')
Copy link
Contributor Author

Choose a reason for hiding this comment

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

@padamstx @germanattanasio only Watson specific that I see here is this header. Should I remove it?

Copy link
Contributor

Choose a reason for hiding this comment

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

Watson specific code should be in our SDK not the core

# See the License for the specific language governing permissions and
# limitations under the License.

from .service import Service
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Is the name service ok or should I move to base_service? @padamstx @germanattanasio

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 base_service it's better

Copy link
Contributor

@germanattanasio germanattanasio left a comment

Choose a reason for hiding this comment

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

What's the code coverage? I would like to test the core SDK and get it to be ~90% as we did with Node

# See the License for the specific language governing permissions and
# limitations under the License.

from .service import Service
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 base_service it's better

self.info = info
self.httpResponse = httpResponse
self.globalTransactionId = None
if httpResponse is not None:
Copy link
Contributor

Choose a reason for hiding this comment

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

Can you get all the headers from the response in a dictionary? maybe they can access that if they use the httpResponse object

:return: A `dict` containing additional information about the error.
:rtype: dict
"""
info_keys = ['code_description', 'description', 'errors', 'help',
Copy link
Contributor

Choose a reason for hiding this comment

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

@padamstx said that we have a defined list for this

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@padamstx can you let me know if there is a list?

Copy link
Member

Choose a reason for hiding this comment

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

Well, i don't think we have a "defined list" just yet. We need to come up with one.
Related issues:
https://github.ibm.com/Watson/developer-experience/issues/6336
https://github.ibm.com/arf/planning-sdk-squad/issues/818

try:
error_json = response.json()
if 'error' in error_json:
if isinstance(error_json['error'], dict) and 'description' in \
Copy link
Contributor

Choose a reason for hiding this comment

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

@padamstx said that we have a list for this

@codecov
Copy link

codecov bot commented Mar 14, 2019

Codecov Report

❗ No coverage uploaded for pull request base (master@cda4fe5). Click here to learn what that means.
The diff coverage is 95.21%.

Impacted file tree graph

@@            Coverage Diff            @@
##             master       #1   +/-   ##
=========================================
  Coverage          ?   95.21%           
=========================================
  Files             ?        7           
  Lines             ?      376           
  Branches          ?        0           
=========================================
  Hits              ?      358           
  Misses            ?       18           
  Partials          ?        0
Impacted Files Coverage Δ
ibm_cloud_sdk_core/api_exception.py 100% <100%> (ø)
ibm_cloud_sdk_core/version.py 100% <100%> (ø)
ibm_cloud_sdk_core/detailed_response.py 100% <100%> (ø)
ibm_cloud_sdk_core/__init__.py 100% <100%> (ø)
ibm_cloud_sdk_core/base_service.py 93.53% <93.53%> (ø)
ibm_cloud_sdk_core/utils.py 94.73% <94.73%> (ø)
ibm_cloud_sdk_core/iam_token_manager.py 96.96% <96.96%> (ø)

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 cda4fe5...e1df393. Read the comment docs.

:return: A `dict` containing additional information about the error.
:rtype: dict
"""
info_keys = ['code_description', 'description', 'errors', 'help',
Copy link
Member

Choose a reason for hiding this comment

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

Well, i don't think we have a "defined list" just yet. We need to come up with one.
Related issues:
https://github.ibm.com/Watson/developer-experience/issues/6336
https://github.ibm.com/arf/planning-sdk-squad/issues/818

@@ -17,3 +17,4 @@
from .detailed_response import DetailedResponse
from .iam_token_manager import IAMTokenManager
from .api_exception import ApiException
from .utils import datetime_to_string, string_to_datetime
Copy link
Member

Choose a reason for hiding this comment

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

Does this mean that a generated .py file no longer needs to explicitly import these functions as long as it imports the "ibm_cloud_sdk_core" module?

Copy link
Contributor Author

@ehdsouza ehdsouza Mar 15, 2019

Choose a reason for hiding this comment

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

The import would look something like:
from ibm_cloud_sdk_core import string_to_datetime

or if you want to import the entire module

import ibm_cloud_sdk_core

# And then using the module, call the function like this:
ibm_cloud_sdk_core.string_to_datetime()

@@ -81,8 +81,7 @@ def __init__(self, vcap_services_name, url, username=None, password=None,
raise ValueError('The URL shouldn\'t start or end with curly brackets or quotes. '
'Be sure to remove any {} and \" characters surrounding your URL')

user_agent_string = 'ibm-python-sdk-core-' + __version__ + self.get_os_info()
self.user_agent_header = self.set_user_agent_header(user_agent_string)
self.set_user_agent_header(self.build_user_agent())
Copy link
Member

Choose a reason for hiding this comment

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

In general, I think we want the core to add the User-Agent header to the outgoing request ONLY if it hasn't already been added by the service function. (I can't tell from this whether we will unconditionally add the core's User-Agent header or not).

Copy link
Contributor Author

@ehdsouza ehdsouza Mar 15, 2019

Choose a reason for hiding this comment

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

Oh good catch!, I have to make a check in the request function

Copy link
Member

@padamstx padamstx left a comment

Choose a reason for hiding this comment

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

LGTM

@ehdsouza ehdsouza merged commit 5f5ccd9 into master Mar 18, 2019
@watson-github-bot
Copy link

🎉 This PR is included in version 0.1.0 🎉

The release is available on GitHub release

Your semantic-release bot 📦🚀

@watson-github-bot
Copy link

🎉 This PR is included in version 0.1.0 🎉

The release is available on GitHub release

Your semantic-release bot 📦🚀

1 similar comment
@watson-github-bot
Copy link

🎉 This PR is included in version 0.1.0 🎉

The release is available on GitHub release

Your semantic-release bot 📦🚀

@ehdsouza ehdsouza deleted the init branch May 9, 2019 15:29
pyrooka added a commit that referenced this pull request Oct 29, 2021
Co-authored-by: Matthew Keezer <[email protected]>
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.

4 participants