Skip to content

Commit 6e566d0

Browse files
committed
doc(migration): Add migration guide
2 parents d78b1b0 + 785b0ee commit 6e566d0

File tree

9 files changed

+214
-9
lines changed

9 files changed

+214
-9
lines changed

.bumpversion.cfg

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
[bumpversion]
2-
current_version = 4.0.0rc1
2+
current_version = 3.4.1
33
commit = True
44

55
[bumpversion:file:ibm_watson/version.py]

MIGRATION-V4.md

Lines changed: 204 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,204 @@
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+
## SUPPORT FOR CONSTANTS
128+
Constants for methods and models are shown in the form of Enums
129+
130+
## SUPPORT FOR PYTHON 2.7 and 3.4 AND BELOW DROPPED
131+
The SDK no longer supports Pyhton versions 2.7 and <=3.4.
132+
133+
## SERVICE CHANGES
134+
#### AssistantV1
135+
* `include_count` is no longer a parameter of the list_workspaces() method
136+
* `include_count` is no longer a parameter of the list_intents() method
137+
* `include_count` is no longer a parameter of the list_examples() method
138+
* `include_count` is no longer a parameter of the list_counterexamples() method
139+
* `include_count` is no longer a parameter of the list_entities() method
140+
* `include_count` is no longer a parameter of the list_values() method
141+
* `include_count` is no longer a parameter of the list_synonyms() method
142+
* `include_count` is no longer a parameter of the list_dialog_nodes() method
143+
* `value_type` was renamed to `type` in the create_value() method
144+
* `new_value_type` was renamed to `new_type` in the update_value() method
145+
* `node_type` was renamed to `type` in the create_dialog_node() method
146+
* `new_node_type` was renamed to `new_type` in the update_dialog_node() method
147+
* `value_type` was renamed to `type` in the CreateValue model
148+
* `node_type` was renamed to `type` in the DialogNode model
149+
* `action_type` was renamed to `type` in the DialogNodeAction model
150+
* `query_type` property was added to the DialogNodeOutputGeneric model
151+
* `query` property was added to the DialogNodeOutputGeneric model
152+
* `filter` property was added to the DialogNodeOutputGeneric model
153+
* `discovery_version` property was added to the DialogNodeOutputGeneric model
154+
* LogMessage model no longer has `_additionalProperties`
155+
* `DialogRuntimeResponseGeneric` was renamed to `RuntimeResponseGeneric`
156+
* RuntimeEntity model no longer has `_additionalProperties`
157+
* RuntimeIntent model no longer has `_additionalProperties`
158+
* `value_type` was renamed to `type` in the Value model
159+
160+
#### AssistantV2
161+
* `action_type` was renamed to `type` in the DialogNodeAction model
162+
* DialogRuntimeResponseGeneric was renamed to RuntimeResponseGeneric
163+
164+
#### Compare and Comply
165+
* `convert_to_html()` method does not require a filename parameter
166+
167+
#### DiscoveryV1
168+
* `return_fields` was renamed to `return_` in the query() method
169+
* `logging_opt_out` was renamed to `x_watson_logging_opt_out` in the query() method
170+
* `spelling_suggestions` was added to the query() method
171+
* `collection_ids` is no longer a parameter of the query() method
172+
* `return_fields` was renamed to `return_` in the QueryNotices() method
173+
* `logging_opt_out` was renamed to `x_watson_logging_opt_out` in the federated_query() method
174+
* `collection_ids` is now required in the federated_query() method
175+
* `collection_ids` changed position in the federated_query() method
176+
* `return_fields` was renamed to `return_` in the federated_query() method
177+
* `return_fields` was renamed to `return_` in the federated_query_notices() method
178+
* `enrichment_name` was renamed to `enrichment` in the Enrichment model
179+
* `field_type` was renamed to `type` in the Field model
180+
* `field_name` was renamed to `field` in the Field model
181+
* test_configuration_in_environment() method was removed
182+
* query_entities() method was removed
183+
* query_relations() method was removed
184+
185+
#### Language Translator V3
186+
* `default_models` was renamed to `default` in the list_models() method
187+
* `translation_output` was renamed to `translation` in the Translation model
188+
189+
#### Natural Language Classifier V1
190+
* `metadata` was renamed to `training_metadata` in the `create_classifier()` method
191+
192+
#### Speech to Text V1
193+
* `final_results` was renamed to `final` in the SpeakerLabelsResult model
194+
* `final_results` was renamed to `final` in the SpeechRecognitionResult model
195+
196+
#### Visual Recognition V3
197+
* `detect_faces()` method was removed
198+
* `class_name` was renamed to `class_` in the ClassResult model
199+
* `class_name` was renamed to `class_` in the ModelClass model
200+
201+
#### Visual Recognition V4
202+
* New Service!
203+
204+

MIGRATION.md

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

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -446,7 +446,7 @@ HTTPConnection.debuglevel = 1
446446
* [responses] for testing
447447
* Following for web sockets support in speech to text
448448
* `websocket-client` 0.48.0
449-
* `ibm_cloud_sdk_core` >= 1.0.0rc9
449+
* `ibm_cloud_sdk_core` == 1.0.0
450450

451451
## Contributing
452452

ibm_watson/speech_to_text_v1_adapter.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -221,7 +221,6 @@ def recognize_using_websocket(self,
221221
'model': model,
222222
'customization_id': customization_id,
223223
'acoustic_customization_id': acoustic_customization_id,
224-
'customization_weight': customization_weight,
225224
'base_model_version': base_model_version,
226225
'language_customization_id': language_customization_id
227226
}
@@ -230,6 +229,7 @@ def recognize_using_websocket(self,
230229
request['url'] = url
231230

232231
options = {
232+
'customization_weight': customization_weight,
233233
'content_type': content_type,
234234
'inactivity_timeout': inactivity_timeout,
235235
'interim_results': interim_results,

ibm_watson/version.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1,2 @@
1-
__version__ = '4.0.0rc1'
1+
__version__ = '3.4.1'
2+

requirements-dev.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ python_dotenv>=0.1.5;python_version!='3.2'
55
pylint>=1.4.4
66
tox>=2.9.1
77
pytest-rerunfailures>=3.1
8-
ibm_cloud_sdk_core==1.0.0rc9
8+
ibm_cloud_sdk_core==1.0.0
99

1010
# code coverage
1111
coverage<5

requirements.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11
requests>=2.0,<3.0
22
python_dateutil>=2.5.3
33
websocket-client==0.48.0
4-
ibm_cloud_sdk_core==1.0.0rc9
4+
ibm_cloud_sdk_core==1.0.0

setup.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,8 @@
1818
import os
1919
import sys
2020

21-
__version__ = '4.0.0rc1'
21+
__version__ = '3.4.1'
22+
2223

2324
if sys.argv[-1] == 'publish':
2425
# test server
@@ -63,7 +64,7 @@ def run_tests(self):
6364
version=__version__,
6465
description='Client library to use the IBM Watson Services',
6566
license='Apache 2.0',
66-
install_requires=['requests>=2.0, <3.0', 'python_dateutil>=2.5.3', 'websocket-client==0.48.0', 'ibm_cloud_sdk_core==1.0.0rc9'],
67+
install_requires=['requests>=2.0, <3.0', 'python_dateutil>=2.5.3', 'websocket-client==0.48.0', 'ibm_cloud_sdk_core==1.0.0'],
6768
tests_require=['responses', 'pytest', 'python_dotenv', 'pytest-rerunfailures', 'tox'],
6869
cmdclass={'test': PyTest},
6970
author='IBM Watson',

0 commit comments

Comments
 (0)