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 3a82e8a8e14f36ad1e4f8ff4dfb23050b5a7f0c7..2bac8694d4adc6046707a8242191d036fb041313 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 43f084b5f3eefed1f5006cdaded57b06ec6394ad..4d12d11f838c49923383f9ddd95566abe8cbe24c 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 1e6517330b44d0a0e9d34472fe3a7a7d6f17b830..72e0691865a4708f55d16b48433e97eed04a9a81 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):