Skip to content
Snippets Groups Projects
Commit b4361e55 authored by LouisGendron's avatar LouisGendron
Browse files

Added 'external_path' to dataset download content/annotations

parent 45dd433e
No related branches found
No related tags found
1 merge request!1Resolve "build filepath on download"
......@@ -132,7 +132,7 @@ class Client:
path = os.path.join(self.url, 'secure/datafiles/download', str(file_id))
r = self.session.get(path, allow_redirects=True)
annotations = self.get_file_annotation(file_id)
if path_key in file_annotation.keys():
if path_key in annotations.keys():
dirs = annotations[path_key].split('/')[0:-1]
os.makedirs(os.path.join(folder_out, '/'.join(dirs)), exist_ok=True)
out_file_path = os.path.join(folder_out, annotations[path_key])
......@@ -167,16 +167,16 @@ class Client:
json.dump(annotations, outfile)
""" Download an entire dataset """
def dwnl_dataset_content(self, dataset_id, folder_out=''):
def dwnl_dataset_content(self, dataset_id, folder_out='', path_key='external_path'):
dataset = self.get_dataset_filelist(dataset_id)
for file_id in np.unique(dataset.file_id):
self.dwnl_file_content(file_id, os.path.join(folder_out, self.datasets.loc[dataset_id].dataset_name))
self.dwnl_file_content(file_id, os.path.join(folder_out, self.datasets.loc[dataset_id].dataset_name), path_key='external_path')
""" Download an entire dataset annotations """
def dwnl_dataset_annotation(self, dataset_id, folder_out=''):
def dwnl_dataset_annotation(self, dataset_id, folder_out='', path_key='external_path'):
dataset = self.get_dataset_filelist(dataset_id)
for file_id in np.unique(dataset.file_id):
self.dwnl_file_annotation(file_id, os.path.join(folder_out, self.datasets.loc[dataset_id].dataset_name))
self.dwnl_file_annotation(file_id, os.path.join(folder_out, self.datasets.loc[dataset_id].dataset_name), path_key='external_path')
""" Check if lab is available """
def _check_lab_exists(self, lab):
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment