Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
* 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
  • Loading branch information
germanattanasio authored Oct 24, 2017
1 parent 708168c commit db0fc73
Show file tree
Hide file tree
Showing 48 changed files with 18,797 additions and 3,155 deletions.
Binary file modified .env.enc
Binary file not shown.
4 changes: 4 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,8 @@ nosetests.xml
coverage.xml
*,cover

.vscode

# virtual env
venv/
# python 3 virtual env
Expand All @@ -60,3 +62,5 @@ docs/apis
docs/gh-pages
test/__init__.py
*~

.sfdx/tools/apex.db
4 changes: 4 additions & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,10 @@ python:

cache: pip

before_install:
- openssl aes-256-cbc -K $encrypted_6e98b3e8e789_key -iv $encrypted_6e98b3e8e789_iv
-in .env.enc -out .env -d

install: pip install tox-travis
script: tox

Expand Down
1 change: 1 addition & 0 deletions MIGRATION.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Moved to [https://github.com/watson-developer-cloud/python-sdk/wiki/Migration](https://github.com/watson-developer-cloud/python-sdk/wiki/Migration)
7 changes: 4 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
[![Build Status](https://travis-ci.org/watson-developer-cloud/python-sdk.svg)](https://travis-ci.org/watson-developer-cloud/python-sdk)
[![codecov.io](https://codecov.io/github/watson-developer-cloud/python-sdk/coverage.svg?branch=master)](https://codecov.io/github/watson-developer-cloud/python-sdk?branch=master)
[![Latest Stable Version](https://img.shields.io/pypi/v/watson-developer-cloud.svg)](https://pypi.python.org/pypi/watson-developer-cloud)
[![Download Times](https://img.shields.io/pypi/dm/watson-developer-cloud.svg)](https://pypi.python.org/pypi/watson-developer-cloud)

Python client library to quickly get started with the various [Watson Developer Cloud][wdc] services.

Expand Down Expand Up @@ -60,9 +59,11 @@ Copy your credentials from the **Service details** page. To find the the Service

Tested on: Python from 2.7, 3.4, 3.5, and 3.6.

## 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.

See [CHANGELOG](https://github.com/watson-developer-cloud/python-sdk/wiki/Changelog).
## Migration
This version includes many breaking changes as a result of standardizing behavior across the new generated services. Full details on migration from previous versions can be found [here](https://github.com/watson-developer-cloud/python-sdk/wiki/Migration).

## Known Issues

Expand Down
1 change: 1 addition & 0 deletions examples/alchemy_data_news_v1.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
from __future__ import print_function
import json
from watson_developer_cloud import AlchemyDataNewsV1

Expand Down
1 change: 0 additions & 1 deletion examples/alchemy_language_v1.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import json
from os.path import join, dirname
from watson_developer_cloud import AlchemyLanguageV1

alchemy_language = AlchemyLanguageV1(api_key='YOUR API KEY')
Expand Down
2 changes: 1 addition & 1 deletion examples/conversation_tone_analyzer_integration/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ Requirements to run the sample code

Credentials & the Workspace ID can be set in environment properties, a .env file, or directly in the code.

Dependencies provided in
Dependencies provided in
`init.py`

Command to run the sample code
Expand Down
8 changes: 4 additions & 4 deletions examples/conversation_tone_analyzer_integration/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,11 +12,11 @@
# See the License for the specific language governing permissions and
# limitations under the License.

from .watson_developer_cloud_service import WatsonDeveloperCloudService
from .watson_developer_cloud_service import WatsonException
from .watson_developer_cloud_service import WatsonInvalidArgument
from .watson_service import WatsonService
from .watson_service import WatsonException
from .watson_service import WatsonInvalidArgument
from .conversation_v1 import ConversationV1
from .tone_analyzer_v3 import ToneAnalyzerV3


from .version import __version__
from .version import __version__
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
from __future__ import print_function
import json
import os
from dotenv import load_dotenv, find_dotenv
Expand Down Expand Up @@ -29,11 +30,11 @@

# This example stores tone for each user utterance in conversation context.
# Change this to false, if you do not want to maintain history
maintainToneHistoryInContext = True
global_maintainToneHistoryInContext = True

# Payload for the Watson Conversation Service
# user input text required - replace "I am happy" with user input text.
payload = {
global_payload = {
'workspace_id': workspace_id,
'input': {
'text': "I am happy"
Expand All @@ -57,14 +58,14 @@ def invokeToneConversation(payload, maintainToneHistoryInContext):
with application-specific code to process the err or data object
returned by the Conversation Service.
"""
tone = tone_analyzer.tone(text=payload['input']['text'])
tone = tone_analyzer.tone(tone_input=payload['input']['text'])
conversation_payload = tone_detection.\
updateUserTone(payload, tone, maintainToneHistoryInContext)
response = conversation.message(workspace_id=workspace_id,
message_input=conversation_payload['input'],
input=conversation_payload['input'],
context=conversation_payload['context'])
print(json.dumps(response, indent=2))


# synchronous call to conversation with tone included in the context
invokeToneConversation(payload, maintainToneHistoryInContext)
invokeToneConversation(global_payload, global_maintainToneHistoryInContext)
20 changes: 9 additions & 11 deletions examples/conversation_tone_analyzer_integration/tone_detection.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,6 @@
* These thresholds can be adjusted to client/domain requirements.
"""

import json

PRIMARY_EMOTION_SCORE_THRESHOLD = 0.5
WRITING_HIGH_SCORE_THRESHOLD = 0.75
WRITING_NO_SCORE_THRESHOLD = 0.0
Expand Down Expand Up @@ -54,13 +52,13 @@ def updateUserTone(conversationPayload, toneAnalyzerPayload, maintainHistory):

# if there is no context in a
if 'context' not in conversationPayload:
conversationPayload['context'] = {};
conversationPayload['context'] = {}

if 'user' not in conversationPayload['context']:
conversationPayload['context'] = initUser()

# For convenience sake, define a variable for the user object
user = conversationPayload['context']['user'];
user = conversationPayload['context']['user']

# Extract the tones - emotion, writing and social
if toneAnalyzerPayload and toneAnalyzerPayload['document_tone']:
Expand All @@ -79,7 +77,7 @@ def updateUserTone(conversationPayload, toneAnalyzerPayload, maintainHistory):

conversationPayload['context']['user'] = user

return conversationPayload;
return conversationPayload


'''
Expand Down Expand Up @@ -139,7 +137,7 @@ def updateEmotionTone(user, emotionTone, maintainHistory):
primaryEmotionScore = None

# update user emotion tone
user['tone']['emotion']['current'] = primaryEmotion;
user['tone']['emotion']['current'] = primaryEmotion

if maintainHistory:
if 'history' not in user['tone']['emotion']:
Expand All @@ -161,8 +159,8 @@ def updateEmotionTone(user, emotionTone, maintainHistory):


def updateWritingTone(user, writingTone, maintainHistory):
currentWriting = [];
currentWritingObject = [];
currentWriting = []
currentWritingObject = []

# Process each writing tone and determine if it is high or low
for tone in writingTone['tones']:
Expand Down Expand Up @@ -219,7 +217,7 @@ def updateSocialTone(user, socialTone, maintainHistory):
'interpretation': 'likely high'
})
elif tone['score'] <= SOCIAL_LOW_SCORE_THRESHOLD:
currentSocial.append(tone['tone_name'].lower() + '_low');
currentSocial.append(tone['tone_name'].lower() + '_low')
currentSocialObject.append({
'tone_name': tone['tone_name'].lower(),
'score': tone['score'],
Expand All @@ -236,5 +234,5 @@ def updateSocialTone(user, socialTone, maintainHistory):
user['tone']['social']['current'] = currentSocial
if maintainHistory:
if not user['tone']['social']['current']:
user['tone']['social']['current'] = [];
user['tone']['social']['current'].append(currentSocialObject);
user['tone']['social']['current'] = []
user['tone']['social']['current'].append(currentSocialObject)
3 changes: 2 additions & 1 deletion examples/conversation_v1.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
from __future__ import print_function
import json
import os
from watson_developer_cloud import ConversationV1
Expand All @@ -16,7 +17,7 @@
if os.getenv("conversation_workspace_id") is not None:
workspace_id = os.getenv("conversation_workspace_id")

response = conversation.message(workspace_id=workspace_id, message_input={
response = conversation.message(workspace_id=workspace_id, input={
'text': 'What\'s the weather like?'})
print(json.dumps(response, indent=2))

Expand Down
2 changes: 1 addition & 1 deletion examples/dialog_v1.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# coding=utf-8
from __future__ import print_function
import json
from os.path import join, dirname
from watson_developer_cloud import DialogV1

dialog = DialogV1(
Expand Down
146 changes: 0 additions & 146 deletions examples/discovery v1 configuration tasks .ipynb

This file was deleted.

Loading

0 comments on commit db0fc73

Please sign in to comment.