diff --git a/CHANGELOG.md b/CHANGELOG.md index 0972b4c5..fbf0fa78 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,8 @@ +## [Version 1.6.2] - 2023-10-17 + +- Fixed a bug in `BatchDownloadPipeline` where the evalscript was not read correctly. + + ## [Version 1.6.1] - 2023-10-11 - Pipelines can now save EOPatches in Zarr format diff --git a/eogrow/__init__.py b/eogrow/__init__.py index a41e9c5a..9b8fb294 100644 --- a/eogrow/__init__.py +++ b/eogrow/__init__.py @@ -1,3 +1,3 @@ """The main module of the eo-grow package.""" -__version__ = "1.6.1" +__version__ = "1.6.2" diff --git a/eogrow/pipelines/download.py b/eogrow/pipelines/download.py index 06244b80..df1da2a9 100644 --- a/eogrow/pipelines/download.py +++ b/eogrow/pipelines/download.py @@ -301,11 +301,7 @@ def _get_output_features(self) -> list[Feature]: return self.config.features def _get_download_node(self, session_loader: SessionLoaderType) -> EONode: - evalscript_path = fs.path.join( - self.storage.get_folder(self.config.evalscript_folder_key), self.config.evalscript_path - ) - with self.storage.filesystem.open(evalscript_path) as evalscript_file: - evalscript = evalscript_file.read() + evalscript = self._get_evalscript() time_diff = None if self.config.time_difference is None else dt.timedelta(minutes=self.config.time_difference) @@ -326,6 +322,13 @@ def _get_download_node(self, session_loader: SessionLoaderType) -> EONode: ) return EONode(download_task) + def _get_evalscript(self) -> str: + evalscript_path = fs.path.join( + self.storage.get_folder(self.config.evalscript_folder_key), self.config.evalscript_path + ) + with self.storage.filesystem.open(evalscript_path) as evalscript_file: + return evalscript_file.read() + class DownloadTimelessPipeline(BaseDownloadPipeline): """Pipeline to download timeless data""" diff --git a/eogrow/pipelines/download_batch.py b/eogrow/pipelines/download_batch.py index 58d54d1d..296ce415 100644 --- a/eogrow/pipelines/download_batch.py +++ b/eogrow/pipelines/download_batch.py @@ -21,7 +21,6 @@ SentinelHubRequest, monitor_batch_analysis, monitor_batch_job, - read_data, ) from ..core.area.batch import BatchAreaManager @@ -198,15 +197,8 @@ def _create_new_batch_request(self) -> BatchRequest: if self.config.save_userdata: responses.append(SentinelHubRequest.output_response("userdata", MimeType.JSON)) - evalscript_path = fs.path.join( - self.storage.get_folder(self.config.evalscript_folder_key), self.config.evalscript_path - ) - with self.storage.filesystem.open(evalscript_path) as evalscript_file: - evalscript = evalscript_file.read() - evalscript = (read_data(self.config.evalscript_path, data_format=MimeType.TXT),) - sentinelhub_request = SentinelHubRequest( - evalscript=evalscript, + evalscript=self._get_evalscript(), input_data=[ SentinelHubRequest.input_data( data_collection=input_config.data_collection, @@ -240,6 +232,13 @@ def _create_new_batch_request(self) -> BatchRequest: description=f"eo-grow - {self.__class__.__name__} pipeline with ID {self.pipeline_id}", ) + def _get_evalscript(self) -> str: + evalscript_path = fs.path.join( + self.storage.get_folder(self.config.evalscript_folder_key), self.config.evalscript_path + ) + with self.storage.filesystem.open(evalscript_path) as evalscript_file: + return evalscript_file.read() + def _trigger_user_action(self, batch_request: BatchRequest) -> BatchUserAction: """According to status and configuration parameters decide what kind of user action to perform.""" if self.config.analysis_only: diff --git a/eogrow/utils/testing.py b/eogrow/utils/testing.py index 074ef32b..9d920ef1 100644 --- a/eogrow/utils/testing.py +++ b/eogrow/utils/testing.py @@ -256,6 +256,7 @@ def run_config( *, output_folder_key: str | None = None, reset_output_folder: bool = True, + check_logs: bool = True, ) -> str | None: """Runs a pipeline (or multiple) and checks the logs that all the executions were successful. Returns the full path of the output folder (if there is one) so it can be inspected further. In case of chain configs, the output folder @@ -264,6 +265,8 @@ def run_config( :param config_path: A path to the config file :param output_folder_key: Type of the folder containing results of the pipeline, inferred from config if None :param reset_output_folder: Delete the content of the results folder before running the pipeline + :param check_logs: If pipeline logs should be checked after the run completes. If EOWorkflows were used, the + function fails if there were unsuccessful executions. """ crude_configs = collect_configs_from_path(config_path) raw_configs = [interpret_config_from_dict(config) for config in crude_configs] @@ -281,7 +284,8 @@ def run_config( pipeline.run() - check_pipeline_logs(pipeline) + if check_logs: + check_pipeline_logs(pipeline) return pipeline.storage.get_folder(output_folder_key, full_path=True) if output_folder_key else None