From d6a17bc21e493d93ad20ad3839a27b4fcc2068bc Mon Sep 17 00:00:00 2001 From: cortadocodes Date: Fri, 16 Aug 2024 11:35:03 +0100 Subject: [PATCH] FIX: Pass output arguments into `Analysis` and use them --- octue/resources/analysis.py | 7 +++++-- octue/runner.py | 2 ++ 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/octue/resources/analysis.py b/octue/resources/analysis.py index 06f334035..bb2ff3fba 100644 --- a/octue/resources/analysis.py +++ b/octue/resources/analysis.py @@ -86,6 +86,7 @@ def __init__(self, twine, handle_monitor_message=None, **kwargs): # Non-strands. self.output_location = kwargs.pop("output_location", None) + self.use_signed_urls_for_output_datasets = kwargs.pop("use_signed_urls_for_output_datasets", True) self._calculate_strand_hashes(strands=strand_kwargs) self._periodic_monitor_message_sender_threads = [] @@ -136,14 +137,14 @@ def set_up_periodic_monitor_message(self, create_monitor_message, period=60): self._periodic_monitor_message_sender_threads.append(thread) logger.info("Periodic monitor message set up to send every %ss.", period) - def finalise(self, upload_output_datasets_to=None, use_signed_urls=True): + def finalise(self, upload_output_datasets_to=None, use_signed_urls=None): """Validate the output values and output manifest and, if the analysis produced an output manifest, upload its output datasets to a unique subdirectory within the analysis's output location. This output location can be overridden by providing a different cloud path via the `upload_output_datasets_to` parameter. Either way, the dataset paths in the output manifest are replaced with signed URLs for easier, expiring access. :param str|None upload_output_datasets_to: If not provided but an output location was provided at instantiation, upload any output datasets into a unique subdirectory within this output location; if provided, upload into this location instead. The output manifest is updated with the upload locations. - :param bool use_signed_urls: if `True`, use signed URLs instead of cloud URIs for dataset paths in the output manifest + :param bool|None use_signed_urls: if `True`, use signed URLs instead of cloud URIs for dataset paths in the output manifest; if `None`, use the value of `use_signed_urls_for_output_datasets` given at instantiation :return None: """ serialised_strands = {"output_values": None, "output_manifest": None} @@ -163,6 +164,8 @@ def finalise(self, upload_output_datasets_to=None, use_signed_urls=True): if self.output_location and not upload_output_datasets_to: upload_output_datasets_to = storage.path.join(self.output_location, coolname.generate_slug()) + use_signed_urls = use_signed_urls or self.use_signed_urls_for_output_datasets + # If there isn't both an output manifest and upload location, nothing is uploaded. if not (upload_output_datasets_to and hasattr(self, "output_manifest")): return diff --git a/octue/runner.py b/octue/runner.py index c4d4c9ee2..9ec805d12 100644 --- a/octue/runner.py +++ b/octue/runner.py @@ -255,6 +255,8 @@ def run( id=analysis_id, twine=self.twine, handle_monitor_message=handle_monitor_message, + output_location=self.output_location, + use_signed_urls_for_output_datasets=self.use_signed_urls_for_output_datasets, **self.configuration, **inputs, **outputs_and_monitors,