Add model management methods to Natural Language Understanding#209
Add model management methods to Natural Language Understanding#209
Conversation
| """ | ||
| Deletes a custom model | ||
| :param model_id: The ID of the model to delete | ||
| :return: dict of analyzed text |
There was a problem hiding this comment.
Model deletion really runs a dict of analyzed text?
kognate
left a comment
There was a problem hiding this comment.
ok, a couple of more that I should have included in the first pass.
| params={"version": self.version}, | ||
| accept_json=True) | ||
|
|
||
| def deleteModel(self, model_id=None): |
There was a problem hiding this comment.
You indicate that model_id can be None by making it's default value none. I'd remove the default value and the model_id check later. The service call will error on the None and by making it required the users know it should be there.
There was a problem hiding this comment.
I was mirroring how the features parameter is checked by the SDK in the analyze method. Does the new commit fix things?
| if model_id is None: | ||
| raise ValueError("Missing parameter 'model_id'") | ||
|
|
||
| return self.request(method='DELETE', url='/v1/models/'+model_id, |
There was a problem hiding this comment.
Format strings '/v1/models/{0}'.format(model_id) are preferred over string concatenation.
|
It does.
The difference is that params are optional in the analye method. One of
them is required, and they are mutually exclusive. In the listmodels
method the model_id is really required and isn't part of a set.
…On Tue, May 23, 2017 at 1:21 PM Garrett May ***@***.***> wrote:
***@***.**** commented on this pull request.
------------------------------
In watson_developer_cloud/natural_language_understanding_v1.py
<#209 (comment)>
:
> @@ -82,3 +82,24 @@ def analyze(self, features, text=None, url=None, html=None,
headers={'content-type': 'application/json'},
json=body,
accept_json=True)
+ def listModels(self):
+ """
+ Lists the custom models available for your service instance
+ :return: dict of available custom models
+ """
+ return self.request(method='GET', url='/v1/models',
+ params={"version": self.version},
+ accept_json=True)
+
+ def deleteModel(self, model_id=None):
I was just mirroring how the features parameter is checked by the SDK in
the analyze endpoint. Does the new commit fix things?
—
You are receiving this because you commented.
Reply to this email directly, view it on GitHub
<#209 (comment)>,
or mute the thread
<https://github.com/notifications/unsubscribe-auth/AAB8wjaYp1dNch89NoUR2xMn9blQ_OP1ks5r8xWBgaJpZM4Njzyc>
.
|
Codecov Report
@@ Coverage Diff @@
## master #209 +/- ##
==========================================
+ Coverage 84.18% 84.23% +0.05%
==========================================
Files 24 24
Lines 1157 1161 +4
==========================================
+ Hits 974 978 +4
Misses 183 183
Continue to review full report at Codecov.
|
Successfully listed a custom model from my own service instance and deleted it with these methods.