From 20884868bdb08408ef74d27b276734eaa60e7214 Mon Sep 17 00:00:00 2001 From: Alex Leith Date: Tue, 2 Jan 2024 16:31:27 +1100 Subject: [PATCH 1/2] Add a simple logging area/task runner --- dep_tools/task.py | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/dep_tools/task.py b/dep_tools/task.py index 285ecb0..bdeef20 100644 --- a/dep_tools/task.py +++ b/dep_tools/task.py @@ -82,3 +82,20 @@ def run(self): self.logger.debug([self.id, "complete", paths]) return paths + + +class SimpleLoggingAreaTask(AreaTask): + def run(self): + self.logger.info("Preparing to load data") + input_data = self.loader.load(self.area) + self.logger.info(f"Found {len(input_data.time)} timesteps to load") + + self.logger.info("Preparing to process data") + output_data = self.processor.process(input_data) + self.logger.info(f"Processed data will have a result of shape: {[output_data.dims[d] for d in ['x', 'y']]}") + + self.logger.info("Processing and writing data...") + paths = self.writer.write(output_data, self.id) + self.logger.info(f"Succesfully wrote data to {len(paths)} paths") + + return paths From c7ed77b8e4f4b0853168dc8c15a9ad48e787c88e Mon Sep 17 00:00:00 2001 From: Alex Leith Date: Thu, 4 Jan 2024 09:11:29 +1100 Subject: [PATCH 2/2] Add send_area_to_processor to simple task --- dep_tools/task.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/dep_tools/task.py b/dep_tools/task.py index bdeef20..7fe3809 100644 --- a/dep_tools/task.py +++ b/dep_tools/task.py @@ -91,7 +91,10 @@ def run(self): self.logger.info(f"Found {len(input_data.time)} timesteps to load") self.logger.info("Preparing to process data") - output_data = self.processor.process(input_data) + processor_kwargs = {} + if self.processor.send_area_to_processor: + processor_kwargs["area"] = self.area + output_data = self.processor.process(input_data, **processor_kwargs) self.logger.info(f"Processed data will have a result of shape: {[output_data.dims[d] for d in ['x', 'y']]}") self.logger.info("Processing and writing data...")