Skip to content
This repository was archived by the owner on Sep 9, 2020. It is now read-only.

Commit c17ca96

Browse files
ajbeairstoAxik
authored andcommitted
[PRED-2150] fix verify_ssl argument in api token retrieve (#146)
* fix argument * linter * add change to changelog * fix up changelog * fix up tests * more linter * change enhancement to bugfix in changelog
1 parent 888a2c5 commit c17ca96

File tree

5 files changed

+51
-32
lines changed

5 files changed

+51
-32
lines changed

CHANGES.rst

Lines changed: 29 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -1,26 +1,33 @@
1-
1.15.1 (Unreleased)
2-
===================
1+
1.15.2 (2018 Dec 17)
2+
=====================
3+
4+
Bugfixes
5+
--------
6+
* Fixed bug where retrieving the user's API token would fail when insecure SSL is required
7+
8+
1.15.1 (2018 Dec 4)
9+
====================
310

411
Enhancements
512
------------
613
* Updated `trafaret` dependency to support the same version as https://pypi.org/project/datarobot/ .
714

815
1.15.0 (2018 Nov 23)
9-
===================
16+
====================
1017

1118
Enhancements
1219
------------
1320
* Added new argument ``-max_prediction_explanations`` that allows batch scoring with predictions explanations and adds ``explanation_N_feature`` and ``explanation_N_strength`` to each row in output document (where ``N ∈ (1, max_prediction_explanations)`` )
1421

1522
1.14.2 (2018 Nov 14)
16-
=======================
23+
====================
1724

1825
Bugfixes
1926
--------
2027
* Added check to detect and warn about quoted delimiters during --fast mode with --keep_cols.
2128

2229
Security fixes
23-
--------
30+
--------------
2431
* Update `requests` dependency due to https://nvd.nist.gov/vuln/detail/CVE-2018-18074
2532

2633
1.14.1 (2018 August 30)
@@ -31,7 +38,7 @@ Bugfixes
3138
* Added ``batch_scoring_deployment_aware`` to Windows/Linux/MacOSX assets.
3239

3340
1.14.0 (2018 August 16)
34-
=====================
41+
=======================
3542

3643
Bugfixes
3744
--------
@@ -131,11 +138,11 @@ Bugfixes
131138
* Fix issue when client error message wasn't logged properly.
132139

133140
1.10.2 (2017 May 9)
134-
================
141+
===================
135142
* Set default timeout on server response to infinity.
136143

137144
1.10.1 (2017 April 27)
138-
================
145+
======================
139146

140147
* New semantic routes versioning support
141148

@@ -145,28 +152,28 @@ Bugfixes
145152

146153

147154
1.10.0 (2017 January 27)
148-
=================
155+
========================
149156

150157
* Independent prediction service support for scoring
151158

152159
1.9.1 (2017 January 6)
153-
==================
160+
======================
154161

155162
* switched to supervisor + workers architecture, improving handling of errors and
156163
subprocess lifecycle control.
157164

158165
* Source code split into more mostly isolated modules.
159166

160167
1.9.0 (2016 December 1)
161-
==================
168+
=======================
162169

163170
* added 3rd parallel process which handles post-processing and writing of responses.
164171
This should greatly improve performance.
165172

166173
* add ability to compress data in transit
167174

168175
1.8.8 (2016 November 17)
169-
==================
176+
========================
170177
* --output_delimiter flag to set delimiter for output CSV. "tab" can be used
171178
for tab-delimited output
172179

@@ -182,7 +189,7 @@ Bugfixes
182189
* Run all tests against Windows
183190

184191
1.8.7 (2016 November 1)
185-
==================
192+
=======================
186193
* --pred_name parameter is documented. Potentially backward incompatible change:
187194
Previously, 1.0 class was used as positive result for binary predictions,
188195
now last class in lexical order is used
@@ -196,15 +203,15 @@ Bugfixes
196203
* auto sampler target batch size increased to 2.5M
197204

198205
1.8.6 (2016 August 23)
199-
==================
206+
======================
200207
* improve url parsing. You no longer need to include "/api" in the host argument.
201208

202209
* return more descriptive error messages when there is a problem
203210

204211
* include the version of the batch-scoring script in the user-agent header
205212

206213
1.8.5 (2016 July 28)
207-
==================
214+
====================
208215
* add option to define document encoding
209216

210217
* add option to skip csv dialect detection.
@@ -216,27 +223,27 @@ Bugfixes
216223
* allow "tab" command line arg keyword. e.g. "--delimiter=tab"
217224

218225
1.8.4 (2016 July 11)
219-
==================
226+
====================
220227
* minor performance improvement for nix users
221228

222229
1.8.3 (2016 July 6)
223-
==================
230+
===================
224231
* This release is compatible with Windows
225232

226233
* logs are now sent to two files within the directory where the script is run
227234

228235
1.8.2 (2016 June 16)
229-
==================
236+
====================
230237
* added --auto_sample option to find the n_samples automatically.
231238

232239
1.8.1 (2016 June 15)
233-
==================
240+
====================
234241
* added --auto_sample option to find the n_samples automatically.
235242

236243
* change how csv dialects are passed around in attempt to fix a bug on Windows.
237244

238245
1.8.0 (2016 June 13)
239-
==================
246+
====================
240247
* use chardet module `chardet <https://pypi.python.org/pypi/chardet>`_ to
241248
attempt to detect character encoding
242249

@@ -247,7 +254,7 @@ Bugfixes
247254
* provide a mode for sending all user messages to stdout
248255

249256
1.7.0 (2016 May)
250-
==================
257+
================
251258
* separate process for disk IO and request payload serialization
252259

253260
* avoid codecs.getreader due to IO bottleneck
@@ -260,7 +267,7 @@ Bugfixes
260267

261268

262269
1.6.0 alpha (2016 April 29)
263-
==================
270+
===========================
264271

265272
* Get rid of gevent/asyncio, use thread-based networking
266273

datarobot_batch_scoring/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
__version__ = '1.15.1'
1+
__version__ = '1.15.2'

datarobot_batch_scoring/batch_scoring.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -178,7 +178,8 @@ def run_batch_predictions(base_url, base_headers, user, pwd,
178178
if not (api_token or import_id):
179179
try:
180180
api_token = acquire_api_token(base_url, base_headers, user,
181-
pwd, create_api_token, ui)
181+
pwd, create_api_token, ui,
182+
verify_ssl)
182183
except Exception as e:
183184
ui.fatal(str(e))
184185

datarobot_batch_scoring/utils.py

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -272,7 +272,8 @@ def parse_config_file(file_path):
272272
return config_validator(parsed_dict)
273273

274274

275-
def acquire_api_token(base_url, base_headers, user, pwd, create_api_token, ui):
275+
def acquire_api_token(base_url, base_headers, user, pwd,
276+
create_api_token, ui, verify_ssl):
276277
"""Get the api token.
277278
278279
Either supplied by user or requested from the API with username and pwd.
@@ -286,7 +287,11 @@ def acquire_api_token(base_url, base_headers, user, pwd, create_api_token, ui):
286287
else:
287288
request_meth = requests.get
288289

289-
r = request_meth(base_url + 'api_token', auth=auth, headers=base_headers)
290+
r = request_meth(base_url + 'api_token',
291+
auth=auth,
292+
headers=base_headers,
293+
verify=verify_ssl)
294+
290295
if r.status_code == 401:
291296
raise ValueError('wrong credentials')
292297
elif r.status_code != 200:

tests/test_utils.py

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -252,7 +252,8 @@ def test_auto_small_dataset():
252252
def test_acquire_api_token(live_server):
253253
ui = PickableMock()
254254
base_url = '{webhost}/predApi/v1.0/'.format(webhost=live_server.url())
255-
ret = acquire_api_token(base_url, {}, 'username', 'password', False, ui)
255+
ret = acquire_api_token(base_url, {}, 'username', 'password', False, ui,
256+
False)
256257
assert ret == 'Som3tok3n'
257258
ui.info.assert_called_with('api-token acquired')
258259
ui.debug.assert_called_with('api-token: Som3tok3n')
@@ -262,7 +263,8 @@ def test_acquire_api_token_unauthorized(live_server):
262263
ui = PickableMock()
263264
base_url = '{webhost}/predApi/v1.0/'.format(webhost=live_server.url())
264265
with pytest.raises(ValueError) as ctx:
265-
acquire_api_token(base_url, {}, 'unknown', 'passwd', False, ui)
266+
acquire_api_token(base_url, {}, 'unknown', 'passwd', False, ui,
267+
False)
266268
assert not ui.info.called
267269
assert not ui.debug.called
268270
assert str(ctx.value) == 'wrong credentials'
@@ -272,7 +274,8 @@ def test_acquire_api_token_bad_status(live_server):
272274
ui = PickableMock()
273275
base_url = '{webhost}/predApi/v1.0/'.format(webhost=live_server.url())
274276
with pytest.raises(ValueError) as ctx:
275-
acquire_api_token(base_url, {}, 'bad_status', 'passwd', False, ui)
277+
acquire_api_token(base_url, {}, 'bad_status', 'passwd', False, ui,
278+
False)
276279
assert not ui.info.called
277280
assert not ui.debug.called
278281
assert str(ctx.value) == 'api_token request returned status code 500'
@@ -282,7 +285,8 @@ def test_acquire_api_token_no_token1(live_server):
282285
ui = PickableMock()
283286
base_url = '{webhost}/predApi/v1.0/'.format(webhost=live_server.url())
284287
with pytest.raises(ValueError) as ctx:
285-
acquire_api_token(base_url, {}, 'no_token1', 'passwd', False, ui)
288+
acquire_api_token(base_url, {}, 'no_token1', 'passwd', False, ui,
289+
False)
286290
assert not ui.info.called
287291
assert not ui.debug.called
288292
assert str(ctx.value) == ('no api-token registered; '
@@ -293,7 +297,8 @@ def test_acquire_api_token_no_token2(live_server):
293297
ui = PickableMock()
294298
base_url = '{webhost}/predApi/v1.0/'.format(webhost=live_server.url())
295299
with pytest.raises(ValueError) as ctx:
296-
acquire_api_token(base_url, {}, 'no_token2', 'passwd', False, ui)
300+
acquire_api_token(base_url, {}, 'no_token2', 'passwd', False, ui,
301+
False)
297302
assert not ui.info.called
298303
assert not ui.debug.called
299304
assert str(ctx.value) == ('no api-token registered; '
@@ -303,7 +308,8 @@ def test_acquire_api_token_no_token2(live_server):
303308
def test_create_and_acquire_api_token(live_server):
304309
ui = PickableMock()
305310
base_url = '{webhost}/predApi/v1.0/'.format(webhost=live_server.url())
306-
ret = acquire_api_token(base_url, {}, 'username', 'password', True, ui)
311+
ret = acquire_api_token(base_url, {}, 'username', 'password', True, ui,
312+
False)
307313
assert ret == 'Som3tok3n'
308314
ui.info.assert_called_with('api-token acquired')
309315
ui.debug.assert_called_with('api-token: Som3tok3n')

0 commit comments

Comments
 (0)