Skip to content

Commit 02c59d5

Browse files
committed
More helpers
1 parent 4f1f3d3 commit 02c59d5

4 files changed

Lines changed: 42 additions & 0 deletions

File tree

dataikuapi/dss/dataset.py

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -526,6 +526,16 @@ def get_zone(self):
526526
"""
527527
return self.project.get_flow().get_zone_of_object(self)
528528

529+
def move_to_zone(self, zone):
530+
"""
531+
Moves this object to a flow zone
532+
533+
:param object zone: a :class:`dataikuapi.dss.flow.DSSFlowZone` where to move the object
534+
"""
535+
if isinstance(zone, basestring):
536+
zone = self.project.get_flow().get_zone(zone)
537+
zone.add_item(self)
538+
529539
def get_usages(self):
530540
"""
531541
Get the recipes or analyses referencing this dataset

dataikuapi/dss/flow.py

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,19 @@ def get_graph(self):
1515
data = self.client._perform_json("GET", "/projects/%s/flow/graph/" % (self.project.project_key))
1616
return DSSProjectFlowGraph(self, data)
1717

18+
def create_zone(self, name, color="#2ab1ac"):
19+
"""
20+
Creates a new flow zone
21+
22+
:returns the newly created zone
23+
:rtype: :class:`DSSFlowZone`
24+
"""
25+
data = self.client._perform_json("POST", "/projects/%s/flow/zones" % (self.project.project_key), body={
26+
"name": name,
27+
"color":color
28+
})
29+
return DSSFlowZone(self, data)
30+
1831
def get_zone(self, id):
1932
"""
2033
Gets a single Flow zone by id

dataikuapi/dss/managedfolder.py

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -167,6 +167,15 @@ def get_zone(self):
167167
"""
168168
return self.project.get_flow().get_zone_of_object(self)
169169

170+
def move_to_zone(self, zone):
171+
"""
172+
Moves this object to a flow zone
173+
174+
:param object zone: a :class:`dataikuapi.dss.flow.DSSFlowZone` where to move the object
175+
"""
176+
if isinstance(zone, basestring):
177+
zone = self.project.get_flow().get_zone(zone)
178+
zone.add_item(self)
170179

171180
def get_usages(self):
172181
"""

dataikuapi/dss/savedmodel.py

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -117,6 +117,16 @@ def get_zone(self):
117117
"""
118118
return self.project.get_flow().get_zone_of_object(self)
119119

120+
def move_to_zone(self, zone):
121+
"""
122+
Moves this object to a flow zone
123+
124+
:param object zone: a :class:`dataikuapi.dss.flow.DSSFlowZone` where to move the object
125+
"""
126+
if isinstance(zone, basestring):
127+
zone = self.project.get_flow().get_zone(zone)
128+
zone.add_item(self)
129+
120130
def get_usages(self):
121131
"""
122132
Get the recipes referencing this model

0 commit comments

Comments
 (0)