Skip to content

Commit c8a9a22

Browse files
committed
Doc cleanup
1 parent dabb26f commit c8a9a22

File tree

2 files changed

+64
-73
lines changed

2 files changed

+64
-73
lines changed

dataikuapi/dss/admin.py

Lines changed: 45 additions & 56 deletions
Original file line numberDiff line numberDiff line change
@@ -30,23 +30,26 @@ def delete(self):
3030
def get_definition(self):
3131
"""
3232
Get the connection's definition (type, name, params, usage restrictions)
33-
3433
Note: this call requires an API key with admin rights
3534
36-
Returns:
37-
the connection definition, as a JSON object
35+
:returns: The connection definition, as a dict.
36+
37+
The exact structure of the returned dict is not documented and depends on the connection
38+
type. Create connections using the DSS UI and call :meth:`get_definition` to see the
39+
fields that are in it.
3840
"""
3941
return self.client._perform_json(
4042
"GET", "/admin/connections/%s" % self.name)
4143

4244
def set_definition(self, description):
4345
"""
4446
Set the connection's definition.
45-
4647
Note: this call requires an API key with admin rights
4748
48-
Args:
49-
definition: the definition for the connection, as a JSON object.
49+
You should only :meth:`set_definition` using an object that you obtained through :meth:`get_definition`,
50+
not create a new dict.
51+
52+
:param dict the definition for the connection, as a dict.
5053
"""
5154
return self.client._perform_json(
5255
"PUT", "/admin/connections/%s" % self.name,
@@ -58,12 +61,11 @@ def set_definition(self, description):
5861

5962
def sync_root_acls(self):
6063
"""
61-
Resync root permissions on this connection path
62-
63-
Returns:
64-
a DSSFuture handle to the task of resynchronizing the permissions
65-
64+
Resync root permissions on this connection path. This is only useful for HDFS connections
65+
when DSS is in multi-user-security mode.
6666
Note: this call requires an API key with admin rights
67+
68+
:returns: a :class:`~dataikuapi.dss.future.DSSFuture` handle to the task of resynchronizing the permissions
6769
"""
6870
future_response = self.client._perform_json(
6971
"POST", "/admin/connections/%s/sync" % self.name,
@@ -72,12 +74,11 @@ def sync_root_acls(self):
7274

7375
def sync_datasets_acls(self):
7476
"""
75-
Resync permissions on datasets in this connection path
76-
77-
Returns:
78-
a DSSFuture handle to the task of resynchronizing the permissions
79-
77+
Resync permissions on datasets in this connection path. This is only useful for HDFS connections
78+
when DSS is in multi-user-security mode.
8079
Note: this call requires an API key with admin rights
80+
81+
:returns: a :class:`~dataikuapi.dss.future.DSSFuture` handle to the task of resynchronizing the permissions
8182
"""
8283
future_response = self.client._perform_json(
8384
"POST", "/admin/connections/%s/sync" % self.name,
@@ -87,7 +88,8 @@ def sync_datasets_acls(self):
8788

8889
class DSSUser(object):
8990
"""
90-
A handle for a user on the DSS instance
91+
A handle for a user on the DSS instance.
92+
Do not create this directly, use :meth:`dataikuapi.DSSClient.get_user`
9193
"""
9294
def __init__(self, client, login):
9395
self.client = client
@@ -100,7 +102,6 @@ def __init__(self, client, login):
100102
def delete(self):
101103
"""
102104
Deletes the user
103-
104105
Note: this call requires an API key with admin rights
105106
"""
106107
return self.client._perform_empty(
@@ -113,7 +114,6 @@ def delete(self):
113114
def get_definition(self):
114115
"""
115116
Get the user's definition (login, type, display name, permissions, ...)
116-
117117
Note: this call requires an API key with admin rights
118118
119119
:return: the user's definition, as a dict
@@ -124,31 +124,29 @@ def get_definition(self):
124124
def set_definition(self, definition):
125125
"""
126126
Set the user's definition.
127-
128127
Note: this call requires an API key with admin rights
129128
130-
:param dict definition: the definition for the user, as a dict. You should
131-
obtain the definition using get_definition, not create one.
132-
The fields that can be changed are:
133-
129+
You should only :meth:`set_definition` using an object that you obtained through :meth:`get_definition`,
130+
not create a new dict.
131+
132+
The fields that may be changed in a user definition are:
133+
134134
* email
135-
136135
* displayName
137-
138136
* groups
139-
140137
* userProfile
141-
142-
* password
138+
* password
143139
140+
:param dict definition: the definition for the user, as a dict
144141
"""
145142
return self.client._perform_json(
146143
"PUT", "/admin/users/%s" % self.login,
147144
body = definition)
148145

149146
class DSSGroup(object):
150147
"""
151-
A group on the DSS instance
148+
A group on the DSS instance.
149+
Do not create this directly, use :meth:`dataikuapi.DSSClient.get_group`
152150
"""
153151
def __init__(self, client, name):
154152
self.client = client
@@ -160,8 +158,7 @@ def __init__(self, client, name):
160158

161159
def delete(self):
162160
"""
163-
Delete the group
164-
161+
Deletes the group
165162
Note: this call requires an API key with admin rights
166163
"""
167164
return self.client._perform_empty(
@@ -175,32 +172,32 @@ def delete(self):
175172
def get_definition(self):
176173
"""
177174
Get the group's definition (name, description, admin abilities, type, ldap name mapping)
178-
179175
Note: this call requires an API key with admin rights
180176
181-
Returns:
182-
the group definition, as a JSON object
177+
:return: the group's definition, as a dict
183178
"""
184179
return self.client._perform_json(
185180
"GET", "/admin/groups/%s" % self.name)
186181

187182
def set_definition(self, definition):
188183
"""
189184
Set the group's definition.
190-
191185
Note: this call requires an API key with admin rights
192-
186+
187+
You should only :meth:`set_definition` using an object that you obtained through :meth:`get_definition`,
188+
not create a new dict.
189+
193190
Args:
194-
definition: the definition for the group, as a JSON object.
191+
definition: the definition for the group, as a dict
195192
"""
196193
return self.client._perform_json(
197194
"PUT", "/admin/groups/%s" % self.name,
198195
body = definition)
199-
200-
196+
201197
class DSSGeneralSettings(object):
202198
"""
203-
The general settings of the DSS instance
199+
The general settings of the DSS instance.
200+
Do not create this directly, use :meth:`dataikuapi.DSSClient.get_general_settings`
204201
"""
205202
def __init__(self, client):
206203
self.client = client
@@ -213,7 +210,6 @@ def __init__(self, client):
213210
def save(self):
214211
"""
215212
Save the changes that were made to the settings on the DSS instance
216-
217213
Note: this call requires an API key with admin rights
218214
"""
219215
return self.client._perform_empty("PUT", "/admin/general-settings", body = self.settings)
@@ -421,7 +417,8 @@ def group_regexp(self, regexp, unix_user, hadoop_user=None):
421417

422418
class DSSCodeEnv(object):
423419
"""
424-
A code env on the DSS instance
420+
A code env on the DSS instance.
421+
Do not create this directly, use :meth:`dataikuapi.DSSClient.get_code_env`
425422
"""
426423
def __init__(self, client, env_lang, env_name):
427424
self.client = client
@@ -434,8 +431,7 @@ def __init__(self, client, env_lang, env_name):
434431

435432
def delete(self):
436433
"""
437-
Delete the connection
438-
434+
Delete the code env
439435
Note: this call requires an API key with admin rights
440436
"""
441437
resp = self.client._perform_json(
@@ -457,16 +453,14 @@ def get_definition(self):
457453
458454
Note: this call requires an API key with admin rights
459455
460-
Returns:
461-
the code env definition, as a JSON object
456+
:returns: the code env definition, as a dict
462457
"""
463458
return self.client._perform_json(
464459
"GET", "/admin/code-envs/%s/%s" % (self.env_lang, self.env_name))
465460

466461
def set_definition(self, env):
467462
"""
468-
Set the code env's definition. The definition should come from a call to the get_definition()
469-
method.
463+
Set the code env's definition. The definition should come from a call to :meth:`get_definition`
470464
471465
Fields that can be updated in design node:
472466
@@ -480,18 +474,13 @@ def set_definition(self, env):
480474
* env.{version}.specCondaEnvironment, env.{version}.specPackageList, env.{version}.externalCondaEnvName,
481475
env.{version}.desc.installCorePackages, env.{version}.desc.installJupyterSupport, env.{version}.desc.yarnPythonBin
482476
483-
484-
485477
Note: this call requires an API key with admin rights
486478
487-
:param data: a code env definition
488-
489-
Returns:
490-
the updated code env definition, as a JSON object
479+
:param dict data: a code env definition
480+
:return: the updated code env definition, as a dict
491481
"""
492482
return self.client._perform_json(
493483
"PUT", "/admin/code-envs/%s/%s" % (self.env_lang, self.env_name), body=env)
494-
495484

496485
########################################################
497486
# Code env actions

dataikuapi/dss/ml.py

Lines changed: 19 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -744,6 +744,25 @@ def ensemble(self, model_ids=[], method=None):
744744
self.wait_train_complete()
745745
return train_ret
746746

747+
748+
def start_train(self, session_name=None, session_description=None):
749+
"""
750+
Starts asynchronously a new train session for this ML Task.
751+
752+
:param str session_name: name for the session
753+
:param str session_description: description for the session
754+
755+
This returns immediately, before train is complete. To wait for train to complete, use ``wait_train_complete()``
756+
"""
757+
session_info = {
758+
"sessionName" : session_name,
759+
"sessionDescription" : session_description
760+
}
761+
762+
return self.client._perform_json(
763+
"POST", "/projects/%s/models/lab/%s/%s/train" % (self.project_key, self.analysis_id, self.mltask_id), body=session_info)
764+
765+
747766
def start_ensembling(self, model_ids=[], method=None):
748767
"""
749768
Creates asynchronously a new ensemble models of a set of models.
@@ -765,23 +784,6 @@ def start_ensembling(self, model_ids=[], method=None):
765784
"POST", "/projects/%s/models/lab/%s/%s/ensemble" % (self.project_key, self.analysis_id, self.mltask_id), body=ensembling_request)['id']
766785

767786

768-
def start_train(self, session_name=None, session_description=None):
769-
"""
770-
Starts asynchronously a new train session for this ML Task.
771-
772-
:param str session_name: name for the session
773-
:param str session_description: description for the session
774-
775-
This returns immediately, before train is complete. To wait for train to complete, use ``wait_train_complete()``
776-
"""
777-
session_info = {
778-
"sessionName" : session_name,
779-
"sessionDescription" : session_description
780-
}
781-
782-
return self.client._perform_json(
783-
"POST", "/projects/%s/models/lab/%s/%s/train" % (self.project_key, self.analysis_id, self.mltask_id), body=session_info)
784-
785787
def wait_train_complete(self):
786788
"""
787789
Waits for train to be complete.

0 commit comments

Comments
 (0)