Skip to content

Commit 80cae22

Browse files
committed
Start a generic base class for the settings of taggable objects, with properties for tags/descriptions/custom fields
1 parent e4ca2f7 commit 80cae22

File tree

3 files changed

+50
-3
lines changed

3 files changed

+50
-3
lines changed

dataikuapi/dss/dataset.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
from ..utils import DataikuStreamedHttpUTF8CSVReader
44
from .future import DSSFuture
55
import json, warnings
6-
from .utils import DSSTaggableObjectListItem
6+
from .utils import DSSTaggableObjectListItem, DSSTaggableObjectSettings
77
from .future import DSSFuture
88
from .metrics import ComputedMetrics
99
from .discussion import DSSObjectDiscussions
@@ -603,8 +603,9 @@ def new_recipe(self, type, recipe_name=None):
603603
builder.with_input(self.dataset_name)
604604
return builder
605605

606-
class DSSDatasetSettings(object):
606+
class DSSDatasetSettings(DSSTaggableObjectSettings):
607607
def __init__(self, dataset, settings):
608+
super(DSSDatasetSettings, self).__init__(settings)
608609
self.dataset = dataset
609610
self.settings = settings
610611

dataikuapi/dss/recipe.py

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
from ..utils import DataikuException
2+
from .utils import DSSTaggableObjectSettings
23
from .discussion import DSSObjectDiscussions
34
import json, logging, warnings
45

@@ -16,6 +17,10 @@ def __init__(self, client, project_key, recipe_name):
1617
self.project_key = project_key
1718
self.recipe_name = recipe_name
1819

20+
@property
21+
def name(self):
22+
return self.recipe_name
23+
1924
def compute_schema_updates(self):
2025
"""
2126
Computes which updates are required to the outputs of this recipe.
@@ -238,11 +243,12 @@ def get_status_messages(self):
238243
return self.data["allMessagesForFrontend"]["messages"]
239244

240245

241-
class DSSRecipeSettings(object):
246+
class DSSRecipeSettings(DSSTaggableObjectSettings):
242247
"""
243248
Settings of a recipe. Do not create this directly, use :meth:`DSSRecipe.get_settings`
244249
"""
245250
def __init__(self, recipe, data):
251+
super(DSSRecipeSettings, self).__init__(data["recipe"])
246252
self.recipe = recipe
247253
self.data = data
248254
self.recipe_settings = self.data["recipe"]

dataikuapi/dss/utils.py

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -218,3 +218,43 @@ def __init__(self, data):
218218
@property
219219
def tags(self):
220220
return self._data["tags"]
221+
222+
class DSSTaggableObjectSettings(object):
223+
def __init__(self, taggable_object_data):
224+
self._tod = taggable_object_data
225+
226+
@property
227+
def tags(self):
228+
"""The tags of the object, as a list of strings"""
229+
return self._tod["tags"]
230+
231+
@tags.setter
232+
def tags(self, tags):
233+
self._tod["tags"] = tags
234+
235+
@property
236+
def description(self):
237+
"""The description of the object as a string"""
238+
return self._tod.get("description", None)
239+
240+
@description.setter
241+
def description(self, description):
242+
self._tod["description"] = description
243+
244+
@property
245+
def short_description(self):
246+
"""The short description of the object as a string"""
247+
return self._tod.get("shortDesc", None)
248+
249+
@short_description.setter
250+
def short_description(self, short_description):
251+
self._tod["shortDesc"] = short_description
252+
253+
@property
254+
def custom_fields(self):
255+
"""The custom fields of the object as a dict. Returns None if there are no custom fields"""
256+
return self._tod.get("customFields", None)
257+
258+
@custom_fields.setter
259+
def custom_fields(self, custom_fields):
260+
self._tod["customFields"] = custom_fields

0 commit comments

Comments
 (0)