Skip to content

Commit 8439266

Browse files
committed
more PR feedback
1 parent 25d14d7 commit 8439266

File tree

3 files changed

+51
-21
lines changed

3 files changed

+51
-21
lines changed

dataikuapi/dss/admin.py

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1576,3 +1576,33 @@ def get_raw(self):
15761576
"""
15771577
return self.settings
15781578

1579+
def get_built_for_all_container_confs(self):
1580+
"""
1581+
Return whether the template an image for each container config
1582+
"""
1583+
return self.settings.get("allContainerConfs", False)
1584+
1585+
def get_built_container_confs(self):
1586+
"""
1587+
Return the list of container configs for which the template builds an image (if not all)
1588+
"""
1589+
return self.settings.get("containerConfs", [])
1590+
1591+
def set_built_container_confs(self, *configs, **kwargs):
1592+
"""
1593+
Set the list of container configs for which the template builds an image
1594+
1595+
:param boolean all: if True, an image is built for each config
1596+
:param list configs: list of configuration names to build images for
1597+
"""
1598+
all = kwargs.get("all", False)
1599+
self.settings['allContainerConfs'] = all
1600+
if not all:
1601+
self.settings['containerConfs'] = configs
1602+
1603+
def save(self):
1604+
"""
1605+
Saves the settings of the code studio template
1606+
"""
1607+
self.client._perform_empty("PUT", "/admin/code-studios/%s" % (self.template_id), body=self.settings)
1608+

dataikuapi/dss/codestudio.py

Lines changed: 16 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -3,13 +3,13 @@
33
from datetime import datetime
44

55
class DSSCodeStudioObjectListItem(object):
6-
"""An item in a list of code studios. Do not instantiate this class, use :meth:`dataikuapi.dss.project.DSSProject.list_code_studio_objects`"""
6+
"""An item in a list of code studios. Do not instantiate this class, use :meth:`dataikuapi.dss.project.DSSProject.list_code_studios`"""
77
def __init__(self, client, project_key, data):
88
self.client = client
99
self.project_key = project_key
1010
self._data = data
1111

12-
def to_code_studio_object(self):
12+
def to_code_studio(self):
1313
"""Gets the :class:`DSSCodeStudioObject` corresponding to this code studio object """
1414
return DSSCodeStudioObject(self.client, self.project_key, self._data["id"])
1515

@@ -37,17 +37,17 @@ class DSSCodeStudioObject(object):
3737
"""
3838
A handle to manage a code studio object of a project
3939
"""
40-
def __init__(self, client, project_key, code_studio_object_id):
41-
"""Do not call directly, use :meth:`dataikuapi.dss.project.DSSProject.get_code_studio_object`"""
40+
def __init__(self, client, project_key, code_studio_id):
41+
"""Do not call directly, use :meth:`dataikuapi.dss.project.DSSProject.get_code_studio`"""
4242
self.client = client
4343
self.project_key = project_key
44-
self.code_studio_object_id = code_studio_object_id
44+
self.code_studio_id = code_studio_id
4545

4646
def delete(self):
4747
"""
4848
Delete the code studio
4949
"""
50-
self.client._perform_empty("DELETE", "/projects/%s/code-studios/%s" % (self.project_key, self.code_studio_object_id))
50+
self.client._perform_empty("DELETE", "/projects/%s/code-studios/%s" % (self.project_key, self.code_studio_id))
5151

5252
def get_settings(self):
5353
"""
@@ -56,8 +56,8 @@ def get_settings(self):
5656
:returns: a handle to manage the code studio definition
5757
:rtype: :class:`dataikuapi.dss.codestudio.DSSCodeStudioObjectSettings`
5858
"""
59-
settings = self.client._perform_json("GET", "/projects/%s/code-studios/%s" % (self.project_key, self.code_studio_object_id))
60-
return DSSCodeStudioObjectSettings(self.client, self.project_key, self.code_studio_object_id, settings)
59+
settings = self.client._perform_json("GET", "/projects/%s/code-studios/%s" % (self.project_key, self.code_studio_id))
60+
return DSSCodeStudioObjectSettings(self.client, self.project_key, self.code_studio_id, settings)
6161

6262
def get_status(self):
6363
"""
@@ -66,8 +66,8 @@ def get_status(self):
6666
:returns: a handle to inspect the code studio state
6767
:rtype: :class:`dataikuapi.dss.codestudio.DSSCodeStudioObjectStatus`
6868
"""
69-
status = self.client._perform_json("GET", "/projects/%s/code-studios/%s/status" % (self.project_key, self.code_studio_object_id))
70-
return DSSCodeStudioObjectStatus(self.client, self.project_key, self.code_studio_object_id, status)
69+
status = self.client._perform_json("GET", "/projects/%s/code-studios/%s/status" % (self.project_key, self.code_studio_id))
70+
return DSSCodeStudioObjectStatus(self.client, self.project_key, self.code_studio_id, status)
7171

7272
def stop(self):
7373
"""
@@ -76,7 +76,7 @@ def stop(self):
7676
:returns: a future to wait on the stop, or None if already stopped
7777
:rtype: :class:`dataikuapi.dss.future.DSSFuture`
7878
"""
79-
ret = self.client._perform_json("POST", "/projects/%s/code-studios/%s/stop" % (self.project_key, self.code_studio_object_id))
79+
ret = self.client._perform_json("POST", "/projects/%s/code-studios/%s/stop" % (self.project_key, self.code_studio_id))
8080
return DSSFuture.from_resp(self.client, ret)
8181

8282
def restart(self):
@@ -86,18 +86,18 @@ def restart(self):
8686
:returns: a future to wait on the start
8787
:rtype: :class:`dataikuapi.dss.future.DSSFuture`
8888
"""
89-
ret = self.client._perform_json("POST", "/projects/%s/code-studios/%s/restart" % (self.project_key, self.code_studio_object_id))
89+
ret = self.client._perform_json("POST", "/projects/%s/code-studios/%s/restart" % (self.project_key, self.code_studio_id))
9090
return DSSFuture.from_resp(self.client, ret)
9191

9292
class DSSCodeStudioObjectSettings(object):
9393
"""
9494
Settings for the code studio object
9595
"""
96-
def __init__(self, client, project_key, code_studio_object_id, settings):
96+
def __init__(self, client, project_key, code_studio_id, settings):
9797
"""Do not call directly, use :meth:`dataikuapi.dss.codestudio.DSSCodeStudioObject.get_settings`"""
9898
self.client = client
9999
self.project_key = project_key
100-
self.code_studio_object_id = code_studio_object_id
100+
self.code_studio_id = code_studio_id
101101
self.settings = settings
102102

103103
def get_raw(self):
@@ -118,11 +118,11 @@ class DSSCodeStudioObjectStatus(object):
118118
"""
119119
Status of a code studio object
120120
"""
121-
def __init__(self, client, project_key, code_studio_object_id, status):
121+
def __init__(self, client, project_key, code_studio_id, status):
122122
"""Do not call directly, use :meth:`dataikuapi.dss.codestudio.DSSCodeStudioObject.get_state`"""
123123
self.client = client
124124
self.project_key = project_key
125-
self.code_studio_object_id = code_studio_object_id
125+
self.code_studio_id = code_studio_id
126126
self.status = status
127127

128128
def get_raw(self):

dataikuapi/dss/project.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1649,15 +1649,15 @@ def list_code_studios(self, as_type="listitems"):
16491649
else:
16501650
raise ValueError("Unknown as_type")
16511651

1652-
def get_code_studio(self, code_studio_object_id):
1652+
def get_code_studio(self, code_studio_id):
16531653
"""
16541654
Get a handle to interact with a specific code studio object
16551655
1656-
:param str code_studio_object_id: the identifier of the desired code studio object
1656+
:param str code_studio_id: the identifier of the desired code studio object
16571657
16581658
:returns: A :class:`dataikuapi.dss.codestudio.DSSCodeStudioObject` code studio object handle
16591659
"""
1660-
return DSSCodeStudioObject(self.client, self.project_key, code_studio_object_id)
1660+
return DSSCodeStudioObject(self.client, self.project_key, code_studio_id)
16611661

16621662
def create_code_studio(self, name, template_id):
16631663
"""
@@ -1673,8 +1673,8 @@ def create_code_studio(self, name, template_id):
16731673
"templateId" : template_id
16741674
}
16751675
res = self.client._perform_json("POST", "/projects/%s/code-studios/" % self.project_key, body = obj)
1676-
code_studio_object_id = res['codeStudio']['id']
1677-
return DSSCodeStudioObject(self.client, self.project_key, code_studio_object_id)
1676+
code_studio_id = res['codeStudio']['id']
1677+
return DSSCodeStudioObject(self.client, self.project_key, code_studio_id)
16781678

16791679

16801680

0 commit comments

Comments
 (0)