-
Notifications
You must be signed in to change notification settings - Fork 29
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
Conversation
@@ -0,0 +1,11 @@ | |||
[bumpversion] | |||
current_version = 0.0.0 |
There was a problem hiding this comment.
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
There was a problem hiding this comment.
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))
There was a problem hiding this 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= |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Will this work?
There was a problem hiding this comment.
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/
There was a problem hiding this 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.
ibm_cloud_sdk_core/api_exception.py
Outdated
self.transactionId = None | ||
self.globalTransactionId = None | ||
if httpResponse is not None: | ||
self.transactionId = httpResponse.headers.get('X-DP-Watson-Tran-ID') |
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
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
ibm_cloud_sdk_core/__init__.py
Outdated
# See the License for the specific language governing permissions and | ||
# limitations under the License. | ||
|
||
from .service import Service |
There was a problem hiding this comment.
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
There was a problem hiding this comment.
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
There was a problem hiding this 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
ibm_cloud_sdk_core/__init__.py
Outdated
# See the License for the specific language governing permissions and | ||
# limitations under the License. | ||
|
||
from .service import Service |
There was a problem hiding this comment.
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
ibm_cloud_sdk_core/api_exception.py
Outdated
self.info = info | ||
self.httpResponse = httpResponse | ||
self.globalTransactionId = None | ||
if httpResponse is not None: |
There was a problem hiding this comment.
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
ibm_cloud_sdk_core/api_exception.py
Outdated
:return: A `dict` containing additional information about the error. | ||
:rtype: dict | ||
""" | ||
info_keys = ['code_description', 'description', 'errors', 'help', |
There was a problem hiding this comment.
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
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
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
ibm_cloud_sdk_core/api_exception.py
Outdated
try: | ||
error_json = response.json() | ||
if 'error' in error_json: | ||
if isinstance(error_json['error'], dict) and 'description' in \ |
There was a problem hiding this comment.
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 Report
@@ Coverage Diff @@
## master #1 +/- ##
=========================================
Coverage ? 95.21%
=========================================
Files ? 7
Lines ? 376
Branches ? 0
=========================================
Hits ? 358
Misses ? 18
Partials ? 0
Continue to review full report at Codecov.
|
ibm_cloud_sdk_core/api_exception.py
Outdated
:return: A `dict` containing additional information about the error. | ||
:rtype: dict | ||
""" | ||
info_keys = ['code_description', 'description', 'errors', 'help', |
There was a problem hiding this comment.
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 |
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
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()) |
There was a problem hiding this comment.
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).
There was a problem hiding this comment.
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
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
🎉 This PR is included in version 0.1.0 🎉 The release is available on GitHub release Your semantic-release bot 📦🚀 |
🎉 This PR is included in version 0.1.0 🎉 The release is available on GitHub release Your semantic-release bot 📦🚀 |
1 similar comment
🎉 This PR is included in version 0.1.0 🎉 The release is available on GitHub release Your semantic-release bot 📦🚀 |
Co-authored-by: Matthew Keezer <[email protected]>
related to https://github.ibm.com/Watson/developer-experience/issues/6179
This PR contains move to a separate core, in addition:
python: 3.7
xenial support in travis_get_error_info
and_get_error_message
in Api_Exception class