Skip to content

Commit 544f9e8

Browse files
committed
add calls to sync files for code studios
1 parent dc04057 commit 544f9e8

File tree

1 file changed

+42
-0
lines changed

1 file changed

+42
-0
lines changed

dataikuapi/dss/codestudio.py

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -90,6 +90,37 @@ def restart(self):
9090
ret = self.client._perform_json("POST", "/projects/%s/code-studios/%s/restart" % (self.project_key, self.code_studio_id))
9191
return DSSFuture.from_resp(self.client, ret)
9292

93+
def check_conflicts(self, zone):
94+
"""
95+
Checks whether the files in a zone of the code studio have conflicting changes
96+
with what the DSS instance has
97+
98+
:param str zone: name of the zone to check (see :meth:`dataikuapi.dss.codestudio.DSSCodeStudioObjectStatus.get_zones`)
99+
100+
:returns: a summary of the conflicts that were found
101+
"""
102+
return self.client._perform_json("GET", "/projects/%s/code-studios/%s/conflicts/%s" % (self.project_key, self.code_studio_id, zone))
103+
104+
def pull_from_code_studio(self, zone):
105+
"""
106+
Copies the files from a zone of the code studio to the DSS instance
107+
108+
:param str zone: name of the zone to pull (see :meth:`dataikuapi.dss.codestudio.DSSCodeStudioObjectStatus.get_zones`)
109+
110+
:returns: a dictionary mapping each zone to the changes that were foiund
111+
"""
112+
return self.client._perform_json("GET", "/projects/%s/code-studios/%s/pull/%s" % (self.project_key, self.code_studio_id, zone))
113+
114+
def push_to_code_studio(self, zone):
115+
"""
116+
Copies the files from the DSS instance to a zone of the code studio
117+
118+
:param str zone: name of the zone to push (see :meth:`dataikuapi.dss.codestudio.DSSCodeStudioObjectStatus.get_zones`)
119+
120+
:returns: a dictionary of {count: <number of files copied>, size: <total size copied>}
121+
"""
122+
return self.client._perform_json("GET", "/projects/%s/code-studios/%s/push/%s" % (self.project_key, self.code_studio_id, zone))
123+
93124
class DSSCodeStudioObjectSettings(object):
94125
"""
95126
Settings for the code studio object
@@ -142,3 +173,14 @@ def last_state_change(self):
142173
return datetime.fromtimestamp(ts / 1000)
143174
else:
144175
return None
176+
def get_zones(self, as_type="names"):
177+
"""
178+
Get the list of the zones synchronized inside the code studio
179+
"""
180+
zones = self.status.get("syncedZones", [])
181+
if as_type == 'name' or as_type == 'names':
182+
return [z.get('id') for z in zones]
183+
if as_type == 'object' or as_type == 'objects':
184+
return zones
185+
else:
186+
raise Exception("Only 'names' or 'objects' is supported for as_type")

0 commit comments

Comments
 (0)