From 23973b432d8f66f1311d5625fd8ca54344dd7368 Mon Sep 17 00:00:00 2001 From: alaskowski <alaskowski@ethz.ch> Date: Tue, 28 Feb 2023 10:20:03 +0100 Subject: [PATCH] SSDM-13300: Added destination to download_physical command. Added prints to object/collection get/set commands --- .../src/python/obis/dm/commands/collection.py | 30 +++++++----- .../obis/dm/commands/download_physical.py | 2 +- .../src/python/obis/dm/commands/object.py | 46 +++++++++++-------- 3 files changed, 45 insertions(+), 33 deletions(-) diff --git a/app-openbis-command-line/src/python/obis/dm/commands/collection.py b/app-openbis-command-line/src/python/obis/dm/commands/collection.py index 3a82e8a8e14..2bac8694d4a 100644 --- a/app-openbis-command-line/src/python/obis/dm/commands/collection.py +++ b/app-openbis-command-line/src/python/obis/dm/commands/collection.py @@ -53,11 +53,14 @@ class Collection(OpenbisCommand): for perm_id in dataset_perm_ids: ds = self.get_dataset(perm_id) datasets += [ds] if ds is not None and ds.sample is None else [] - datasets = set(datasets) - for dataset in datasets: - experiment = dataset.experiment - click_echo( - f"Collection: {experiment.permId} '{self.prop}' = {experiment.props[self.prop]}") + if not datasets: + click_echo(f"No parent collections found.") + else: + datasets = set(datasets) + for dataset in datasets: + experiment = dataset.experiment + click_echo( + f"Collection: {experiment.permId} '{self.prop}' = {experiment.props[self.prop]}") return 0 def set(self): @@ -66,13 +69,16 @@ class Collection(OpenbisCommand): for perm_id in dataset_perm_ids: ds = self.get_dataset(perm_id) datasets += [ds] if ds is not None and ds.sample is None else [] - datasets = set(datasets) - for dataset in datasets: - experiment = dataset.experiment - experiment.props[self.prop] = self.value - click_echo( - f"Setting collection: {experiment.permId} property '{self.prop}' to '{experiment.props[self.prop]}'") - experiment.save() + if not datasets: + click_echo(f"No parent collections found.") + else: + datasets = set(datasets) + for dataset in datasets: + experiment = dataset.experiment + experiment.props[self.prop] = self.value + click_echo( + f"Setting collection: {experiment.permId} property '{self.prop}' to '{experiment.props[self.prop]}'") + experiment.save() return 0 def empty_or_split(self): diff --git a/app-openbis-command-line/src/python/obis/dm/commands/download_physical.py b/app-openbis-command-line/src/python/obis/dm/commands/download_physical.py index 43f084b5f3e..4d12d11f838 100644 --- a/app-openbis-command-line/src/python/obis/dm/commands/download_physical.py +++ b/app-openbis-command-line/src/python/obis/dm/commands/download_physical.py @@ -42,5 +42,5 @@ class DownloadPhysical(OpenbisCommand): files = self.files if self.files is not None else data_set.file_list with cd(self.data_mgmt.invocation_path): - target_folder = data_set.download(files) + target_folder = data_set.download(files, destination=self.data_mgmt.invocation_path) return CommandResult(returncode=0, output="Files downloaded to: %s" % target_folder) diff --git a/app-openbis-command-line/src/python/obis/dm/commands/object.py b/app-openbis-command-line/src/python/obis/dm/commands/object.py index 1e6517330b4..72e0691865a 100644 --- a/app-openbis-command-line/src/python/obis/dm/commands/object.py +++ b/app-openbis-command-line/src/python/obis/dm/commands/object.py @@ -53,10 +53,13 @@ class Object(OpenbisCommand): for perm_id in dataset_perm_ids: ds = self.get_dataset(perm_id) datasets += [ds] if ds is not None and ds.sample is not None else [] - datasets = set(datasets) - for dataset in datasets: - sample = dataset.sample - click_echo(f"Object: {sample.permId} '{self.prop}' = {sample.props[self.prop]}") + if not datasets: + click_echo(f"No parent objects found.") + else: + datasets = set(datasets) + for dataset in datasets: + sample = dataset.sample + click_echo(f"Object: {sample.permId} '{self.prop}' = {sample.props[self.prop]}") return 0 def set(self): @@ -65,22 +68,25 @@ class Object(OpenbisCommand): for perm_id in dataset_perm_ids: ds = self.get_dataset(perm_id) datasets += [ds] if ds is not None and ds.sample is not None else [] - datasets = set(datasets) - for dataset in datasets: - sample = dataset.sample - if self.prop == "parents": - sample.parents = self.empty_or_split() - click_echo( - f"Setting object: {sample.permId} parents to {self.empty_or_split()}") - elif self.prop == "children": - sample.children = self.empty_or_split() - click_echo( - f"Setting object: {sample.permId} children to {self.empty_or_split()}") - else: - sample.props[self.prop] = self.value - click_echo( - f"Setting object: {sample.permId} property '{self.prop}' to '{sample.props[self.prop]}'") - sample.save() + if not datasets: + click_echo(f"No parent objects found.") + else: + datasets = set(datasets) + for dataset in datasets: + sample = dataset.sample + if self.prop == "parents": + sample.parents = self.empty_or_split() + click_echo( + f"Setting object: {sample.permId} parents to {self.empty_or_split()}") + elif self.prop == "children": + sample.children = self.empty_or_split() + click_echo( + f"Setting object: {sample.permId} children to {self.empty_or_split()}") + else: + sample.props[self.prop] = self.value + click_echo( + f"Setting object: {sample.permId} property '{self.prop}' to '{sample.props[self.prop]}'") + sample.save() return 0 def empty_or_split(self): -- GitLab