Skip to content

Commit 6a4b2df

Browse files
author
kgued
committed
create and delete analysis from DSSDataset
1 parent 4680b60 commit 6a4b2df

File tree

1 file changed

+28
-0
lines changed

1 file changed

+28
-0
lines changed

dataikuapi/dss/dataset.py

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -499,6 +499,34 @@ def new_grouping_recipe(self, first_group_by, recipe_name=None):
499499
builder.with_group_key(first_group_by)
500500
return builder
501501

502+
########################################################
503+
# Creation of analyses
504+
########################################################
505+
506+
def new_analysis(self):
507+
analysis = self.project.create_analysis(self.name)
508+
return analysis
509+
510+
def list_analyses(self):
511+
"""Returns a list of json short description description of analysis that has this dataset as inputDataset
512+
513+
:return: list of dict with keys {'analysisId', 'analysisName', 'inputDataset'}
514+
515+
"""
516+
project_analysis_desc_list = self.project.list_analyses()
517+
return [desc for desc in project_analysis_desc_list if self.name == desc.get('inputDataset')]
518+
519+
def delete_analyses(self, drop_data=False):
520+
"""Deletes all analyses that have this dataset as inputDataset
521+
522+
:param: bool drop_data: will drop analysis data if True. Default is False
523+
"""
524+
525+
desc_list = self.list_analyses()
526+
dss_analysis_list = [self.project.get_analysis(desc['analysisId']) for desc in desc_list]
527+
return [analysis.delete(drop_data=drop_data) for analysis in dss_analysis_list]
528+
529+
502530
class DSSDatasetSettings(object):
503531
def __init__(self, dataset, settings):
504532
self.dataset = dataset

0 commit comments

Comments
 (0)