Skip to content
Snippets Groups Projects

Resolve "Hierarchy as a set of annotation"

Merged LouisGendron requested to merge 6-hierarchy-as-a-set-of-annotation into master
+ 10
7
@@ -163,21 +163,24 @@ class Client:
self.dwnl_file_annotation(file_id, os.path.join(folder_out, datasetname))
""" Download an entire dataset following the specified hierarchy """
def dwnl_hierarchy(self, dataset_id, hierarchy=[], folder_out=''):
def dwnl_hierarchy(self, dataset_id, hierarchy=[], folder_out='', backup_folder=None):
dataset = self.get_dataset_filelist(dataset_id)
for file_id in dataset.file_id:
annotations = self.get_file_annotation(file_id)
if not annotations is None :
if not annotations is None:
folder_path = None
if all(key in annotations.keys() for key in hierarchy):
full_path='/'.join([annotations[key] for key in hierarchy])
full_path = '/'.join([annotations[key] for key in hierarchy])
loc = full_path.rsplit('/', 1)[0]
folder_path = os.path.join(folder_out, loc)
filename = full_path.rsplit('/', 1)[-1]
else:
folder_path = folder_out
elif not backup_folder is None:
folder_path = os.path.join(folder_out, backup_folder)
filename = self.get_file_metadata(file_id)['filename']
self.dwnl_file_content(file_id, folder_path, filename)
self.dwnl_file_annotation(file_id, folder_path, filename)
if not folder_path is None:
self.dwnl_file_content(file_id, folder_path, filename)
self.dwnl_file_annotation(file_id, folder_path, filename)
#def _check_dataset_annotation(self, dataset_id, annotation=[]):
Loading