Skip to content

Commit b7a5d6b

Browse files
authored
Merge pull request #696 from watson-developer-cloud/final-updates
Python sdk v4.0.0 release
2 parents 70c320c + 04b9055 commit b7a5d6b

File tree

80 files changed

+20238
-15228
lines changed

Some content is hidden

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

80 files changed

+20238
-15228
lines changed

.env.enc

-16 Bytes
Binary file not shown.

.pylintrc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11
# lint Python modules using external checkers.
22
[MASTER]
33
ignore=SVN
4-
disable=R0903,R0912,R0913,R0914,R0915,W0141,C0111,C0103,W0603,W0703,R0911,C0301,C0302,R0902,R0904,W0142,W0212,E1101,E1103,R0201,W0201,W0122,W0232,RP0001,RP0003,RP0101,RP0002,RP0401,RP0701,RP0801,F0401,E0611,R0801,I0011,F0401,E0611,E1004,C0111,I0011,I0012,W0704,W0142,W0212,W0232,W0613,W0702,R0201,W0614,R0914,R0912,R0915,R0913,R0904,R0801,C0301,C0411,R0204,W0622,E1121,inconsistent-return-statements,R0205,C0325
4+
disable=R0903,R0912,R0913,R0914,R0915,W0141,C0111,C0103,W0603,W0703,R0911,C0301,C0302,R0902,R0904,W0142,W0212,E1101,E1103,R0201,W0201,W0122,W0232,RP0001,RP0003,RP0101,RP0002,RP0401,RP0701,RP0801,F0401,E0611,R0801,I0011,F0401,E0611,E1004,C0111,I0011,I0012,W0704,W0142,W0212,W0232,W0613,W0702,R0201,W0614,R0914,R0912,R0915,R0913,R0904,R0801,C0301,C0411,R0204,W0622,E1121,inconsistent-return-statements,R0205,C0325,unsubscriptable-object

.travis.yml

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,10 @@
11
language: python
22
matrix:
33
include:
4-
- python: 2.7
5-
- python: 3.5
6-
- python: 3.6
7-
- python: 3.7
8-
dist: xenial
4+
- python: 3.5
5+
- python: 3.6
6+
- python: 3.7
7+
dist: xenial
98
cache: pip
109
before_install:
1110
- '[ "${TRAVIS_PULL_REQUEST}" = "false" ] && openssl aes-256-cbc -K $encrypted_cebf25e6c525_key

CONTRIBUTING.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ If you want to contribute to the repository, here's a quick guide:
2121
* Only use spaces for indentation.
2222
* Create minimal diffs - disable on save actions like reformat source code or organize imports. If you feel the source code should be reformatted create a separate PR for this change.
2323
* Check for unnecessary whitespace with `git diff --check` before committing.
24-
* Make sure your code supports Python 2.7, 3.4, 3.5 and 3.6. You can use `pyenv` and `tox` for this
24+
* Make sure your code supports Python 3.5, 3.6 and 3.7. You can use `pyenv` and `tox` for this
2525
1. Make the test pass
2626
1. Commit your changes
2727
* Commits should follow the [Angular commit message guidelines](https://github.com/angular/angular/blob/master/CONTRIBUTING.md#-commit-message-guidelines). This is because our release tool uses this format for determining release versions and generating changelogs. To make this easier, we recommend using the [Commitizen CLI](https://github.com/commitizen/cz-cli) with the `cz-conventional-changelog` adapter.

MIGRATION-V4.md

Lines changed: 215 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,215 @@
1+
Here are simple steps to move from `v3.0.0` to `v4.0.0`. Note that `v4.0,0` supports only python `3.5` and above
2+
3+
## AUTHENTICATION MECHANISM
4+
The constructor no longer accepts individual credentials like `iam_apikey`, etc. We initialize authenticators from the [core](https://github.com/IBM/python-sdk-core). The core supports various authentication mechanisms, choose the one appropriate to your instance and use case.
5+
6+
For example, to pass a IAM apikey:
7+
#### Before
8+
```python
9+
from ibm_watson import MyService
10+
11+
service = MyService(
12+
iam_apikey='{apikey}',
13+
url='{url}'
14+
)
15+
```
16+
17+
#### After(V4.0)
18+
```python
19+
from ibm_watson import MyService
20+
from ibm_cloud_sdk_core.authenticators import IAMAuthenticator
21+
22+
authenticator = IAMAuthenticator('{apikey}')
23+
service = MyService(
24+
authenticator=authenticator
25+
)
26+
service.set_service_url('{url}')
27+
```
28+
29+
There are 5 authentication variants supplied in the SDK (shown below), and it's possible now to create your own authentication implementation if you need something specific by implementing the Authenticator implementation.
30+
31+
#### BasicAuthenticator
32+
```python
33+
from ibm_cloud_sdk_core.authenticators import BasicAuthenticator
34+
35+
authenticator = BasicAuthenticator(<your_username>, <your_password>)
36+
service = MyService(authenticator=authenticator)
37+
```
38+
39+
#### BearerTokenAuthenticator
40+
```python
41+
from ibm_cloud_sdk_core.authenticators import BearerTokenAuthenticator
42+
43+
authenticator = BearerTokenAuthenticator(<your_bearer_token>)
44+
service = MyService(authenticator=authenticator)
45+
46+
# can set bearer token
47+
service.get_authenticator().set_bearer_token('xxx');
48+
```
49+
50+
#### CloudPakForDataAuthenticator
51+
```python
52+
from ibm_cloud_sdk_core.authenticators import CloudPakForDataAuthenticator
53+
54+
authenticator = CloudPakForDataAuthenticator(
55+
'my_username',
56+
'my_password',
57+
'https://my-cp4d-url',
58+
disable_ssl_verification=True)
59+
service = MyService(authenticator=authenticator)
60+
```
61+
62+
#### IAMAuthenticator
63+
```python
64+
from ibm_cloud_sdk_core.authenticators import IAMAuthenticator
65+
66+
authenticator = IAMAuthenticator('my_apikey')
67+
service = MyService(authenticator=authenticator)
68+
```
69+
70+
#### NoAuthAuthenticator
71+
```python
72+
from ibm_cloud_sdk_core.authenticators import NoAuthAuthenticator
73+
74+
authenticator = NoAuthAuthenticator()
75+
service = MyService(authenticator=authenticator)
76+
```
77+
78+
#### Creating an Authenticator from Environmental Configuration
79+
```python
80+
from ibm_cloud_sdk_core import get_authenticator_from_environment
81+
82+
authenticator = get_authenticator_from_environment('Assistant')
83+
service = MyService(authenticator=authenticator)
84+
```
85+
86+
## SETTING THE SERVICE URL
87+
We can set the service url using `set_service_url()` or from external configurations.
88+
89+
#### Before
90+
```python
91+
service = MyService(
92+
iam_apikey='{apikey}',
93+
url='{url}' # <= here
94+
)
95+
```
96+
97+
#### After(V4.0)
98+
```python
99+
service = MyService(
100+
authenticator=authenticator,
101+
)
102+
service.set_service_url('{url}')
103+
```
104+
105+
OR, pass from external configurations like environment variable
106+
```bash
107+
export MY_SERVICE_URL="<your url>"
108+
```
109+
110+
## METHOD OPTIONAL PARAM
111+
The method params which are optional would need to be specified by name rather than position. For example
112+
113+
#### Before
114+
The list_workspaces with page_limit as 10 was:
115+
116+
```python
117+
assistant_service.list_workspaces(10)
118+
```
119+
120+
#### After(V4.0)
121+
We need to specify the optional param name:
122+
123+
```python
124+
assistant_service.list_workspaces(page_limit=10)
125+
```
126+
127+
## DISABLING SSL VERIFICATION
128+
#### Before
129+
```python
130+
service.disable_ssl_verification(True)
131+
```
132+
133+
#### After(v4.0)
134+
```python
135+
service.set_disable_ssl_verification(True)
136+
```
137+
138+
## SUPPORT FOR CONSTANTS
139+
Constants for methods and models are shown in the form of Enums
140+
141+
## SUPPORT FOR PYTHON 2.7 and 3.4 AND BELOW DROPPED
142+
The SDK no longer supports Pyhton versions 2.7 and <=3.4.
143+
144+
## SERVICE CHANGES
145+
#### AssistantV1
146+
* `include_count` is no longer a parameter of the list_workspaces() method
147+
* `include_count` is no longer a parameter of the list_intents() method
148+
* `include_count` is no longer a parameter of the list_examples() method
149+
* `include_count` is no longer a parameter of the list_counterexamples() method
150+
* `include_count` is no longer a parameter of the list_entities() method
151+
* `include_count` is no longer a parameter of the list_values() method
152+
* `include_count` is no longer a parameter of the list_synonyms() method
153+
* `include_count` is no longer a parameter of the list_dialog_nodes() method
154+
* `value_type` was renamed to `type` in the create_value() method
155+
* `new_value_type` was renamed to `new_type` in the update_value() method
156+
* `node_type` was renamed to `type` in the create_dialog_node() method
157+
* `new_node_type` was renamed to `new_type` in the update_dialog_node() method
158+
* `value_type` was renamed to `type` in the CreateValue model
159+
* `node_type` was renamed to `type` in the DialogNode model
160+
* `action_type` was renamed to `type` in the DialogNodeAction model
161+
* `query_type` property was added to the DialogNodeOutputGeneric model
162+
* `query` property was added to the DialogNodeOutputGeneric model
163+
* `filter` property was added to the DialogNodeOutputGeneric model
164+
* `discovery_version` property was added to the DialogNodeOutputGeneric model
165+
* LogMessage model no longer has `_additionalProperties`
166+
* `DialogRuntimeResponseGeneric` was renamed to `RuntimeResponseGeneric`
167+
* RuntimeEntity model no longer has `_additionalProperties`
168+
* RuntimeIntent model no longer has `_additionalProperties`
169+
* `value_type` was renamed to `type` in the Value model
170+
171+
#### AssistantV2
172+
* `action_type` was renamed to `type` in the DialogNodeAction model
173+
* DialogRuntimeResponseGeneric was renamed to RuntimeResponseGeneric
174+
175+
#### Compare and Comply
176+
* `convert_to_html()` method does not require a filename parameter
177+
178+
#### DiscoveryV1
179+
* `return_fields` was renamed to `return_` in the query() method
180+
* `logging_opt_out` was renamed to `x_watson_logging_opt_out` in the query() method
181+
* `spelling_suggestions` was added to the query() method
182+
* `collection_ids` is no longer a parameter of the query() method
183+
* `return_fields` was renamed to `return_` in the QueryNotices() method
184+
* `logging_opt_out` was renamed to `x_watson_logging_opt_out` in the federated_query() method
185+
* `collection_ids` is now required in the federated_query() method
186+
* `collection_ids` changed position in the federated_query() method
187+
* `return_fields` was renamed to `return_` in the federated_query() method
188+
* `return_fields` was renamed to `return_` in the federated_query_notices() method
189+
* `enrichment_name` was renamed to `enrichment` in the Enrichment model
190+
* `field_type` was renamed to `type` in the Field model
191+
* `field_name` was renamed to `field` in the Field model
192+
* test_configuration_in_environment() method was removed
193+
* query_entities() method was removed
194+
* query_relations() method was removed
195+
196+
#### Language Translator V3
197+
* `default_models` was renamed to `default` in the list_models() method
198+
* `translation_output` was renamed to `translation` in the Translation model
199+
200+
#### Natural Language Classifier V1
201+
* `metadata` was renamed to `training_metadata` in the `create_classifier()` method
202+
203+
#### Speech to Text V1
204+
* `final_results` was renamed to `final` in the SpeakerLabelsResult model
205+
* `final_results` was renamed to `final` in the SpeechRecognitionResult model
206+
207+
#### Visual Recognition V3
208+
* `detect_faces()` method was removed
209+
* `class_name` was renamed to `class_` in the ClassResult model
210+
* `class_name` was renamed to `class_` in the ModelClass model
211+
212+
#### Visual Recognition V4
213+
* New Service!
214+
215+

MIGRATION.md

Lines changed: 0 additions & 1 deletion
This file was deleted.

0 commit comments

Comments
 (0)