Conversation
Rename core service file to watson_service.py
* Return None when status_code is 204 (No Content) * Generated Python SDK * Hand-coded changes to create/updateClassifier * Updated tests for generated SDK * Updated examples for generated SDK * Updates from PR review * Update discovery tests * ignore vscode * 💚 ignore personality insights v3 failing test * 🔮 Add travis file to prevent encoding issues * Hand-coded changes to PIV3 profile for text/csv accept type * Fix and re-enable PIV3 test for csv return type * 📝 Documentation changes for v1.0 * Add the Download Times link back * Update examples and pylint errors * Unicode to fix travis issue with python 2.7 * Revert unicode for v2.7
* Generated Python SDK for multiple services * Hand-coded changes to create/updateClassifier * Hand-coded changes to PIV3 profile for text/csv accept type
| global_payload = { | ||
| 'workspace_id': workspace_id, | ||
| 'input': { | ||
| 'text': "I am happy" |
There was a problem hiding this comment.
Line 47 under invokeToneConversation says:
invokeToneConversation calls the the Tone Analyzer service to get the
extra the is not intentional. right?
|
|
||
| ## CHANGELOG | ||
| ## Changes for v4.0 | ||
| Version 4.0 focuses on the move to programmatically-generated code for many of the services. See the [changelog](https://github.com/watson-developer-cloud/python-sdk/wiki/Changelog) for the details. |
There was a problem hiding this comment.
Should this be v1.0 instead of v4.0?
| audio_file, content_type='audio/wav', timestamps=True, | ||
| word_confidence=True), | ||
| indent=2)) | ||
| indent=2)) |
There was a problem hiding this comment.
It doesn't change the meaning, but I suspect this extra indentation wasn't intended.
There was a problem hiding this comment.
This was a pylint complain, so added those indentation
| with open(join(dirname(__file__), | ||
| '../resources/tone-example.json')) as tone_json: | ||
| tone = tone_analyzer.tone(json.load(tone_json)['text'], 'emotion') | ||
| tone = tone_analyzer.tone(json.load(tone_json)['text'], "text/plain") |
There was a problem hiding this comment.
Looks like the tones list was removed. Based on an email thread, though, I think there's a chance it will be reintroduced to maintain backwards compatibility. Not sure if y'all want to hold off on this release until there's a resolution to that discussion.
There was a problem hiding this comment.
Good eye @glennrfisher! The tones parameter was reintroduced but is now optional, so it moved after the content_type parameter. That wouldn't really be backward compatible, but fortunately we don't have to worry about that for a new major release. And happily, this example is still correct even with tones being reintroduced.
@ehdsouza The reordering of the parameters might be worth mentioning in the migration guide.
There was a problem hiding this comment.
Updated the migration guide.
| print(json.dumps(url_result, indent=2)) | ||
|
|
||
| faces_result = visual_recognition.detect_faces(images_url=test_url) | ||
| faces_result = visual_recognition.detect_faces(parameters=json.dumps({'url': test_url})) |
There was a problem hiding this comment.
It's unfortunate that the API for Visual Recognition expects a JSON string. Not sure what can be done to improve that without changing the service interface.
| #file_path = join(dirname(__file__), '../resources/text.png') | ||
| #with open(file_path, 'rb') as image_file: | ||
| # text_results = visual_recognition.recognize_text(images_file=image_file) | ||
| # print(json.dumps(text_results, indent=2)) |
There was a problem hiding this comment.
Was this intended to be commented?
There was a problem hiding this comment.
Yes -- the text recognition methods of VR are deprecated.
| count, | ||
| 'return_fields': | ||
| ",".join(return_fields) | ||
| if isinstance(return_fields, list) else return_fields, |
There was a problem hiding this comment.
This looks awkward, although it seems to work okay. I suspect yapf formatted the code this way.
I made a quick test file, and it works as expected:
# test.py
x = ['1','2','3']
params = {
'list':
','.join(x)
if True else 'hello, world'
}
print(params['list'])> python test.py
1,2,3There was a problem hiding this comment.
I noticed the same thing. It turns out that if any line in the object constructor has to break at the :, then yapf breaks all the lines consistently at the :. It looks awful but it works.
Replace latest_version with named version dates
|
|
||
| discovery = watson_developer_cloud.DiscoveryV1( | ||
| discovery = DiscoveryV1( | ||
| '2016-11-07', |
There was a problem hiding this comment.
Using a latest version here would make more sense.
There was a problem hiding this comment.
Use 2017-10-16
| parallel_corpus_content_type=None, | ||
| parallel_corpus_filename=None, | ||
| monolingual_corpus_content_type=None, | ||
| monolingual_corpus_filename=None): |
There was a problem hiding this comment.
I think we probably do not want the content_types or filename parameters here.
There was a problem hiding this comment.
I see why this happened -- a typo in the annotations in the LT swagger.
| def create_classifier(self, | ||
| metadata, | ||
| training_data, | ||
| training_metadata_filename=None, |
There was a problem hiding this comment.
This parameter should be named metadata_filename.
…slator Eliminate content-type parameters from LT create_model
|
|
||
| def __init__(self, version, url=default_url, **kwargs): | ||
| WatsonDeveloperCloudService.__init__(self, 'conversation', url, | ||
| **kwargs) |
There was a problem hiding this comment.
Should continue to have the logic of **kwargs to support x_watson_learning_opt_out, etc.
def __init__(self, version, url=default_url, **kwargs):
WatsonDeveloperCloudService.__init__(self, 'conversation', url,
**kwargs)
There was a problem hiding this comment.
You can do x_watson_learning_opt_out with the default headers. This was recently added.
@ehdsouza We should make sure this is in the migration guide.
There was a problem hiding this comment.
Also, **kwargs is no longer needed for use_vcap_services, because it defaults to True -- there’s never a case where you want to specify False. Credentials passed in always override vcap services. If you want vcap services, don’t pass credentials.
…-helper Add convert_model helper function and use this in generated code
…les-tests Fix unicode error in examples tests
…xceptions Create custom exception for API errors containing the status code
🔥 enable all commands in tox to build pages 💚 Test documentation deployment Install the library before calling docs/publish.sh
Update codecov and sphinx script
Codecov Report
@@ Coverage Diff @@
## master #286 +/- ##
==========================================
- Coverage 85.29% 38.09% -47.2%
==========================================
Files 24 24
Lines 1231 8187 +6956
==========================================
+ Hits 1050 3119 +2069
- Misses 181 5068 +4887
Continue to review full report at Codecov.
|
Add pylint test
Store datetime properties as Python datetime objects in models
…ding Fix path encoding

Version 1.0 introduces automatically generated service classes for several services.
Services that are not affected in this release:
Services that are affected in this release:
Upon upgrading the SDK, follow the migration guide here.