Skip to content

Commit c9f06a2

Browse files
committed
Merge branch 'release/7.0' into fterrazzoni/eda-public-api-client
2 parents a51b8a5 + 09c5530 commit c9f06a2

File tree

9 files changed

+524
-6
lines changed

9 files changed

+524
-6
lines changed

README

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11
API client for Dataiku Data Science Studio
22

33
For more information, see:
4-
https://doc.dataiku.com/dss/latest/api/public/client-python/index.html
4+
https://doc.dataiku.com/dss/latest/python-api/rest-api-client/index.html

dataikuapi/dss/dataset.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -337,14 +337,15 @@ def with_store_into(self, connection, type_option_id = None, format_option_id =
337337
self.creation_settings["specificSettings"]["formatOptionId"] = format_option_id
338338
return self
339339

340-
def with_copy_partitioning_from(self, dataset_ref):
340+
def with_copy_partitioning_from(self, dataset_ref, object_type='DATASET'):
341341
"""
342342
Sets the new managed dataset to use the same partitioning as an existing dataset_name
343343
344344
:param str dataset_ref: Name of the dataset to copy partitioning from
345345
:return: self
346346
"""
347-
self.creation_settings["partitioningOptionId"] = "copy:%s" % dataset_ref
347+
code = 'dataset' if object_type == 'DATASET' else 'folder'
348+
self.creation_settings["partitioningOptionId"] = "copy:%s:%s" % (code, dataset_ref)
348349
return self
349350

350351
def create(self):

dataikuapi/dss/ml.py

Lines changed: 472 additions & 0 deletions
Large diffs are not rendered by default.

dataikuapi/dss/project.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -534,7 +534,10 @@ def get_variables(self):
534534
def set_variables(self, obj):
535535
"""
536536
Sets the variables of this project.
537-
@param obj: must be a modified version of the object returned by get_variables
537+
WARNING: if executed from a python recipe, the changes made by `set_variables` will not be "seen" in that recipe.
538+
Use the internal API dataiku.get_custom_variables() instead if this behavior is needed
539+
540+
@param dict obj: must be a modified version of the object returned by get_variables
538541
"""
539542
if not "standard" in obj:
540543
raise ValueError("Missing 'standard' key in argument")

dataikuapi/dss/recipe.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -329,7 +329,7 @@ def with_new_output(self, name, connection_id, typeOptionId=None, format_option_
329329
AVRO, ORC
330330
:param override_sql_schema: schema to force dataset, for SQL dataset. If left empty, will be autodetected
331331
:param str partitioning_option_id: to copy the partitioning schema of an existing dataset 'foo', pass a
332-
value of 'copy:foo'
332+
value of 'copy:dataset:foo'
333333
:param append: whether the recipe should append or overwrite the output when running
334334
(note: not available for all dataset types)
335335
:param str object_type: DATASET or MANAGED_FOLDER

dataikuapi/dss/scenario.py

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -156,6 +156,13 @@ def get_average_duration(self, limit=3):
156156
return None
157157
return sum([run.get_duration() for run in last_runs]) / len(last_runs)
158158

159+
def delete(self):
160+
"""
161+
Deletes this scenario
162+
"""
163+
return self.client._perform_json(
164+
"DELETE", "/projects/%s/scenarios/%s" % (self.project_key, self.id))
165+
159166
########################################################
160167
# Discussions
161168
########################################################

dataikuapi/dss/wiki.py

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -237,6 +237,16 @@ def upload_attachement(self, fp, filename):
237237

238238
self.client._perform_json("POST", "/projects/%s/wiki/%s/upload" % (self.project_key, dku_quote_fn(self.article_id)), files={"file":(clean_filename, fp)})
239239

240+
def get_uploaded_file(self, upload_id):
241+
""""
242+
Download the attachement of an article
243+
244+
:param str upload_id: The attachement upload id
245+
:returns: The requests.Response object
246+
:rtype: :class:`requests.Response`
247+
"""
248+
return self.client._perform_raw("GET", "/projects/%s/wiki/%s/uploads/%s" % (self.project_key, self.article_id, upload_id))
249+
240250
def delete(self):
241251
"""
242252
Delete the article

dataikuapi/utils.py

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -94,3 +94,28 @@ def str_to_bool(s):
9494
doublequote=True):
9595
yield [none_if_throws(caster)(val)
9696
for (caster, val) in dku_zip_longest(casters, uncasted_tuple)]
97+
98+
class DSSInternalDict(object):
99+
"""
100+
Class that provides some helpers and an `_internal_dict` dict field that is the actual holder of the data.
101+
"""
102+
103+
def __init__(self, orig_dict=None):
104+
if orig_dict is None:
105+
self._internal_dict = dict()
106+
else:
107+
self._internal_dict = orig_dict
108+
109+
def get(self, name, default=None):
110+
return self._internal_dict.get(name, default)
111+
112+
def get_raw(self):
113+
"""
114+
Gets the raw dictionary of the actual data
115+
116+
:rtype: dict
117+
"""
118+
return self._internal_dict
119+
120+
def __repr__(self):
121+
return self.__class__.__name__ + "(" + self._internal_dict.__repr__() + ")"

setup.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
from setuptools import setup
44

5-
VERSION = "6.0.0"
5+
VERSION = "7.0.0"
66

77
long_description = (open('README').read() +
88
'\n\n' + open('HISTORY.txt').read())

0 commit comments

Comments
 (0)