Skip to content

Commit cfda449

Browse files
authored
Merge branch 'master' into feature-asoc
2 parents e628bc8 + fe42f7a commit cfda449

65 files changed

Lines changed: 2546 additions & 3880 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

.bumpversion.cfg

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
[bumpversion]
2-
current_version = 1.7.1
2+
current_version = 2.0.1
33
commit = True
4+
message = [skip ci] Bump version: {current_version} -> {new_version}
45

56
[bumpversion:file:watson_developer_cloud/version.py]
67
search = __version__ = '{current_version}'

README.md

Lines changed: 28 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -20,9 +20,9 @@ Python client library to quickly get started with the various [Watson APIs][wdc]
2020
* [IAM](#iam)
2121
* [Username and password](#username-and-password)
2222
* [API key](#api-key)
23-
* [Deprecation notice](#deprecation-notice)
2423
* [Python version](#python-version)
2524
* [Changes for v1.0](#changes-for-v10)
25+
* [Changes for v2.0](#changes-for-v20)
2626
* [Migration](#migration)
2727
* [Configuring the http client](#configuring-the-http-client-supported-from-v110)
2828
* [Sending request headers](#sending-request-headers)
@@ -107,14 +107,14 @@ You supply either an IAM service **API key** or an **access token**:
107107
```python
108108
# In the constructor, letting the SDK manage the IAM token
109109
discovery = DiscoveryV1(version='2017-10-16',
110-
iam_api_key='<iam_api_key>',
110+
iam_apikey='<iam_apikey>',
111111
iam_url='<iam_url>') # optional - the default value is https://iam.bluemix.net/identity/token
112112
```
113113

114114
```python
115115
# after instantiation, letting the SDK manage the IAM token
116116
discovery = DiscoveryV1(version='2017-10-16')
117-
discovery.set_iam_api_key('<iam_api_key>')
117+
discovery.set_iam_apikey('<iam_apikey>')
118118
```
119119

120120
#### Supplying the access token
@@ -159,16 +159,30 @@ visual_recognition = VisualRecognitionV3(version='2018-05-22')
159159
visual_recognition.set_api_key('<api_key>')
160160
```
161161

162-
## Deprecation notice
163-
Language Translator v3 is now available. The v2 Language Translator API will no longer be available after July 31, 2018. To take advantage of the latest service enhancements, migrate to the v3 API. View the [Migrating to Language Translator v3](https://console.bluemix.net/docs/services/language-translator/migrating.html) page for more information.
164-
165162
## Python version
166163

167164
Tested on Python 2.7, 3.4, 3.5, and 3.6.
168165

169166
## Changes for v1.0
170167
Version 1.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.
171168

169+
## Changes for v2.0
170+
`DetailedResponse` which contains the result, headers and HTTP status code is now the default response for all methods.
171+
```python
172+
from watson_developer_cloud import AssistantV1
173+
174+
assistant = AssistantV1(
175+
username='xxx',
176+
password='yyy',
177+
version='2017-04-21')
178+
179+
response = assistant.list_workspaces(headers={'Custom-Header': 'custom_value'})
180+
print(response.get_result())
181+
print(response.get_headers())
182+
print(response.get_status_code())
183+
```
184+
See the [changelog](https://github.com/watson-developer-cloud/python-sdk/wiki/Changelog) for the details.
185+
172186
## Migration
173187
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).
174188

@@ -185,7 +199,7 @@ assistant = AssistantV1(
185199

186200
assistant.set_http_config({'timeout': 100})
187201
response = assistant.message(workspace_id=workspace_id, input={
188-
'text': 'What\'s the weather like?'})
202+
'text': 'What\'s the weather like?'}).get_result()
189203
print(json.dumps(response, indent=2))
190204
```
191205

@@ -206,11 +220,11 @@ assistant = AssistantV1(
206220
password='yyy',
207221
version='2017-04-21')
208222

209-
response = assistant.list_workspaces(headers={'Custom-Header': 'custom_value'})
223+
response = assistant.list_workspaces(headers={'Custom-Header': 'custom_value'}).get_result()
210224
```
211225

212226
## Parsing HTTP response info
213-
If you would like access to some HTTP response information along with the response model, you can set the `set_detailed_response()` to `True`
227+
If you would like access to some HTTP response information along with the response model, you can set the `set_detailed_response()` to `True`. Since Python SDK `v2.0`, it is set to `True`
214228
```python
215229
from watson_developer_cloud import AssistantV1
216230

@@ -220,29 +234,27 @@ assistant = AssistantV1(
220234
version='2017-04-21')
221235

222236
assistant.set_detailed_response(True)
223-
response = assistant.list_workspaces(headers={'Custom-Header': 'custom_value'})
237+
response = assistant.list_workspaces(headers={'Custom-Header': 'custom_value'}).get_result()
224238
print(response)
225239
```
226240

227241
This would give an output of `DetailedResponse` having the structure:
228242
```python
229243
{
230244
'result': <response returned by service>,
231-
'headers': { <http response headers> }
245+
'headers': { <http response headers> },
246+
'status_code': <http status code>
232247
}
233248
```
234-
You can use the `get_result()` and `get_headers()` to return the result and headers respectively.
249+
You can use the `get_result()`, `get_headers()` and get_status_code() to return the result, headers and status code respectively.
235250

236251
## Dependencies
237252

238253
* [requests]
239254
* `python_dateutil` >= 2.5.3
240255
* [responses] for testing
241256
* Following for web sockets support in speech to text
242-
* `autobahn` >= 0.10.9
243-
* `Twisted` >= 13.2.0
244-
* `pyOpenSSL` >= 16.2.0
245-
* `service-identity` >= 17.0.0
257+
* `websocket-client` 0.47.0
246258

247259
## Contributing
248260

appveyor.yml

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
environment:
2+
3+
matrix:
4+
5+
- PYTHON: "C:\\Python35"
6+
- PYTHON: "C:\\Python27-x64"
7+
- PYTHON: "C:\\Python36-x64"
8+
9+
install:
10+
11+
# Install Python (from the official .msi of https://python.org) and pip when
12+
# not already installed.
13+
- ps: if (-not(Test-Path($env:PYTHON))) { & appveyor\install.ps1 }
14+
15+
# Prepend newly installed Python to the PATH of this build
16+
- "SET PATH=%PYTHON%;%PYTHON%\\Scripts;%PATH%"
17+
18+
- "python -m pip install --upgrade pip"
19+
20+
- "pip install --editable ."
21+
22+
- "pip install -r requirements-dev.txt"
23+
24+
build: off
25+
26+
test_script:
27+
28+
- ps: py.test --reruns 3 --cov=watson_developer_cloud
29+
30+
deploy: off
31+
32+
matrix:
33+
fast_finish: true
34+

examples/README.md

Lines changed: 4 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,6 @@
11
## Examples
2-
To run the examples, you will need a `username`, `password`, and `url`. To get your service credentials, follow these steps:
3-
1. Log in to IBM Cloud at https://console.bluemix.net.
2+
To run the examples, you will need the appropriate service instance
43

5-
1. Create an instance of the service:
6-
1. In the IBM Cloud **Catalog**, select the Natural Language Classifier service.
7-
1. Click **Create**.
8-
9-
1. Copy your credentials:
10-
1. On the left side of the page, click **Service Credentials** to view your service credentials.
11-
1. Copy `username`, `password`, and `url` from these service credentials.
12-
13-
## Deprecation notice
14-
Language Translator v3 is now available. The v2 Language Translator API will no longer be available after July 31, 2018. To take advantage of the latest service enhancements, migrate to the v3 API. View the [Migrating to Language Translator v3](https://console.bluemix.net/docs/services/language-translator/migrating.html) page for more information.
4+
1. Go to the IBM Cloud [Dashboard](https://console.bluemix.net/dashboard/apps?category=ai) page.
5+
1. Either click an existing Watson service instance or click [**Create resource > AI**](https://console.bluemix.net/catalog/?category=ai) and create a service instance.
6+
1. Copy the `url` and either `apikey` or `username` and `password`. Click **Show** if the credentials are masked.

0 commit comments

Comments
 (0)