Skip to content

Commit 1472405

Browse files
AutorestCIlmazuel
authored andcommitted
[AutoPR cognitiveservices/data-plane/CustomVision/Training/cognitiveservices/data-plane/CustomVision/Prediction] Customvision v2.2 (#3549)
* Generated from 9c6a4f523a839eb390d86bbcf4d9cb87daa0a4e1 Swagger Updates for V2.2 * Packaging update of azure-cognitiveservices-vision-customvision * Generated from 99ef383d02240f23a5b6d06f88f9334c53126121 Update config * Generated from 1e99b3021e28327423348ff667d7a4b69c55f1bb Add more descriptions * Packaging update of azure-cognitiveservices-vision-customvision * Update HISTORY.rst * Update version.py * Update sdk_packaging.toml * Packaging update of azure-cognitiveservices-vision-customvision
1 parent 77f90d5 commit 1472405

Some content is hidden

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

45 files changed

+1082
-955
lines changed

azure-cognitiveservices-vision-customvision/HISTORY.rst

+8
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,14 @@
33
Release History
44
===============
55

6+
0.4.0 (2018-11-13)
7+
++++++++++++++++++
8+
9+
- The API client name was changed from TrainingAPI to CustomVisionTrainingClient, in keeping with other Azure SDKs.
10+
- The way the Azure region is specfied has changed. Specifically, the AzureRegion property was dropped in favor of an Endpoint property. If you were previously specifying an AzureRegion value, you should now specify Endpoint='https://{AzureRegion}.api.cognitive.microsoft.com' instead. This change ensures better global coverage.
11+
- Added ONNX 1.2 as an export option
12+
- Added negative tag support.
13+
614
0.3.0 (2018-07-12)
715
++++++++++++++++++
816

Original file line numberDiff line numberDiff line change
@@ -1 +1,5 @@
11
include *.rst
2+
include azure/__init__.py
3+
include azure/cognitiveservices/__init__.py
4+
include azure/cognitiveservices/vision/__init__.py
5+

azure-cognitiveservices-vision-customvision/azure/cognitiveservices/vision/customvision/prediction/__init__.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -9,10 +9,10 @@
99
# regenerated.
1010
# --------------------------------------------------------------------------
1111

12-
from .prediction_endpoint import PredictionEndpoint
12+
from .custom_vision_prediction_client import CustomVisionPredictionClient
1313
from .version import VERSION
1414

15-
__all__ = ['PredictionEndpoint']
15+
__all__ = ['CustomVisionPredictionClient']
1616

1717
__version__ = VERSION
1818

+34-26
Original file line numberDiff line numberDiff line change
@@ -17,47 +17,51 @@
1717
from . import models
1818

1919

20-
class PredictionEndpointConfiguration(Configuration):
21-
"""Configuration for PredictionEndpoint
20+
class CustomVisionPredictionClientConfiguration(Configuration):
21+
"""Configuration for CustomVisionPredictionClient
2222
Note that all parameters used to create this instance are saved as instance
2323
attributes.
2424
2525
:param api_key:
2626
:type api_key: str
27-
:param str base_url: Service URL
27+
:param endpoint: Supported Cognitive Services endpoints
28+
:type endpoint: str
2829
"""
2930

3031
def __init__(
31-
self, api_key, base_url=None):
32+
self, api_key, endpoint):
3233

3334
if api_key is None:
3435
raise ValueError("Parameter 'api_key' must not be None.")
35-
if not base_url:
36-
base_url = 'https://southcentralus.api.cognitive.microsoft.com/customvision/v2.0/Prediction'
36+
if endpoint is None:
37+
raise ValueError("Parameter 'endpoint' must not be None.")
38+
base_url = '{Endpoint}/customvision/v2.0/Prediction'
3739

38-
super(PredictionEndpointConfiguration, self).__init__(base_url)
40+
super(CustomVisionPredictionClientConfiguration, self).__init__(base_url)
3941

4042
self.add_user_agent('azure-cognitiveservices-vision-customvision/{}'.format(VERSION))
4143

4244
self.api_key = api_key
45+
self.endpoint = endpoint
4346

4447

45-
class PredictionEndpoint(SDKClient):
46-
"""PredictionEndpoint
48+
class CustomVisionPredictionClient(SDKClient):
49+
"""CustomVisionPredictionClient
4750
4851
:ivar config: Configuration for client.
49-
:vartype config: PredictionEndpointConfiguration
52+
:vartype config: CustomVisionPredictionClientConfiguration
5053
5154
:param api_key:
5255
:type api_key: str
53-
:param str base_url: Service URL
56+
:param endpoint: Supported Cognitive Services endpoints
57+
:type endpoint: str
5458
"""
5559

5660
def __init__(
57-
self, api_key, base_url=None):
61+
self, api_key, endpoint):
5862

59-
self.config = PredictionEndpointConfiguration(api_key, base_url)
60-
super(PredictionEndpoint, self).__init__(None, self.config)
63+
self.config = CustomVisionPredictionClientConfiguration(api_key, endpoint)
64+
super(CustomVisionPredictionClient, self).__init__(None, self.config)
6165

6266
client_models = {k: v for k, v in models.__dict__.items() if isinstance(v, type)}
6367
self.api_version = '2.0'
@@ -97,6 +101,7 @@ def predict_image_url(
97101
# Construct URL
98102
url = self.predict_image_url.metadata['url']
99103
path_format_arguments = {
104+
'Endpoint': self._serialize.url("self.config.endpoint", self.config.endpoint, 'str', skip_quote=True),
100105
'projectId': self._serialize.url("project_id", project_id, 'str')
101106
}
102107
url = self._client.format_url(url, **path_format_arguments)
@@ -110,6 +115,7 @@ def predict_image_url(
110115

111116
# Construct headers
112117
header_parameters = {}
118+
header_parameters['Accept'] = 'application/json'
113119
header_parameters['Content-Type'] = 'application/json; charset=utf-8'
114120
if custom_headers:
115121
header_parameters.update(custom_headers)
@@ -119,9 +125,8 @@ def predict_image_url(
119125
body_content = self._serialize.body(image_url, 'ImageUrl')
120126

121127
# Construct and send request
122-
request = self._client.post(url, query_parameters)
123-
response = self._client.send(
124-
request, header_parameters, body_content, stream=False, **operation_config)
128+
request = self._client.post(url, query_parameters, header_parameters, body_content)
129+
response = self._client.send(request, stream=False, **operation_config)
125130

126131
if response.status_code not in [200]:
127132
raise HttpOperationError(self._deserialize, response)
@@ -168,6 +173,7 @@ def predict_image(
168173
# Construct URL
169174
url = self.predict_image.metadata['url']
170175
path_format_arguments = {
176+
'Endpoint': self._serialize.url("self.config.endpoint", self.config.endpoint, 'str', skip_quote=True),
171177
'projectId': self._serialize.url("project_id", project_id, 'str')
172178
}
173179
url = self._client.format_url(url, **path_format_arguments)
@@ -181,6 +187,7 @@ def predict_image(
181187

182188
# Construct headers
183189
header_parameters = {}
190+
header_parameters['Accept'] = 'application/json'
184191
header_parameters['Content-Type'] = 'multipart/form-data'
185192
if custom_headers:
186193
header_parameters.update(custom_headers)
@@ -192,9 +199,8 @@ def predict_image(
192199
}
193200

194201
# Construct and send request
195-
request = self._client.post(url, query_parameters)
196-
response = self._client.send_formdata(
197-
request, header_parameters, form_data_content, stream=False, **operation_config)
202+
request = self._client.post(url, query_parameters, header_parameters, form_content=form_data_content)
203+
response = self._client.send(request, stream=False, **operation_config)
198204

199205
if response.status_code not in [200]:
200206
raise HttpOperationError(self._deserialize, response)
@@ -243,6 +249,7 @@ def predict_image_url_with_no_store(
243249
# Construct URL
244250
url = self.predict_image_url_with_no_store.metadata['url']
245251
path_format_arguments = {
252+
'Endpoint': self._serialize.url("self.config.endpoint", self.config.endpoint, 'str', skip_quote=True),
246253
'projectId': self._serialize.url("project_id", project_id, 'str')
247254
}
248255
url = self._client.format_url(url, **path_format_arguments)
@@ -256,6 +263,7 @@ def predict_image_url_with_no_store(
256263

257264
# Construct headers
258265
header_parameters = {}
266+
header_parameters['Accept'] = 'application/json'
259267
header_parameters['Content-Type'] = 'application/json; charset=utf-8'
260268
if custom_headers:
261269
header_parameters.update(custom_headers)
@@ -265,9 +273,8 @@ def predict_image_url_with_no_store(
265273
body_content = self._serialize.body(image_url, 'ImageUrl')
266274

267275
# Construct and send request
268-
request = self._client.post(url, query_parameters)
269-
response = self._client.send(
270-
request, header_parameters, body_content, stream=False, **operation_config)
276+
request = self._client.post(url, query_parameters, header_parameters, body_content)
277+
response = self._client.send(request, stream=False, **operation_config)
271278

272279
if response.status_code not in [200]:
273280
raise HttpOperationError(self._deserialize, response)
@@ -314,6 +321,7 @@ def predict_image_with_no_store(
314321
# Construct URL
315322
url = self.predict_image_with_no_store.metadata['url']
316323
path_format_arguments = {
324+
'Endpoint': self._serialize.url("self.config.endpoint", self.config.endpoint, 'str', skip_quote=True),
317325
'projectId': self._serialize.url("project_id", project_id, 'str')
318326
}
319327
url = self._client.format_url(url, **path_format_arguments)
@@ -327,6 +335,7 @@ def predict_image_with_no_store(
327335

328336
# Construct headers
329337
header_parameters = {}
338+
header_parameters['Accept'] = 'application/json'
330339
header_parameters['Content-Type'] = 'multipart/form-data'
331340
if custom_headers:
332341
header_parameters.update(custom_headers)
@@ -338,9 +347,8 @@ def predict_image_with_no_store(
338347
}
339348

340349
# Construct and send request
341-
request = self._client.post(url, query_parameters)
342-
response = self._client.send_formdata(
343-
request, header_parameters, form_data_content, stream=False, **operation_config)
350+
request = self._client.post(url, query_parameters, header_parameters, form_content=form_data_content)
351+
response = self._client.send(request, stream=False, **operation_config)
344352

345353
if response.status_code not in [200]:
346354
raise HttpOperationError(self._deserialize, response)

azure-cognitiveservices-vision-customvision/azure/cognitiveservices/vision/customvision/training/__init__.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -9,10 +9,10 @@
99
# regenerated.
1010
# --------------------------------------------------------------------------
1111

12-
from .training_api import TrainingApi
12+
from .custom_vision_training_client import CustomVisionTrainingClient
1313
from .version import VERSION
1414

15-
__all__ = ['TrainingApi']
15+
__all__ = ['CustomVisionTrainingClient']
1616

1717
__version__ = VERSION
1818

0 commit comments

Comments
 (0)