From 80521a4bbed97853c5cd0540073cef4b704f0dfb Mon Sep 17 00:00:00 2001 From: mathleur Date: Mon, 4 Nov 2024 20:27:37 +0100 Subject: [PATCH 1/5] move context passs to polytope --- polytope_mars/api.py | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/polytope_mars/api.py b/polytope_mars/api.py index 76e75d9..8986651 100644 --- a/polytope_mars/api.py +++ b/polytope_mars/api.py @@ -114,10 +114,13 @@ def extract(self, request): f"Datacube type '{self.conf.datacube.type}' not found" ) # noqa: E501 slicer = HullSlicer() + + logging.debug(f"Send log_context to polytope: {self.log_context}") self.api = Polytope( datacube=fdbdatacube, engine=slicer, options=self.conf.options.model_dump(), + context=self.log_context ) end = time.time() @@ -131,11 +134,7 @@ def extract(self, request): start = time.time() logging.info(f"{self.id}: Polytope time start: {start}") # noqa: E501 - if self.log_context: - logging.debug(f"Send log_context to polytope: {self.log_context}") - result = self.api.retrieve(preq, context=self.log_context) - else: - result = self.api.retrieve(preq) + result = self.api.retrieve(preq) end = time.time() delta = end - start From 98ab56ed588b6200631c5caa34ef4a4ef182812a Mon Sep 17 00:00:00 2001 From: mathleur Date: Mon, 4 Nov 2024 20:31:42 +0100 Subject: [PATCH 2/5] black --- polytope_mars/api.py | 2 +- polytope_mars/config.py | 2 -- polytope_mars/features/timeseries.py | 6 +++--- polytope_mars/features/verticalprofile.py | 6 +++--- 4 files changed, 7 insertions(+), 9 deletions(-) diff --git a/polytope_mars/api.py b/polytope_mars/api.py index 8986651..1e444c0 100644 --- a/polytope_mars/api.py +++ b/polytope_mars/api.py @@ -120,7 +120,7 @@ def extract(self, request): datacube=fdbdatacube, engine=slicer, options=self.conf.options.model_dump(), - context=self.log_context + context=self.log_context, ) end = time.time() diff --git a/polytope_mars/config.py b/polytope_mars/config.py index 059daf8..3bb8ea7 100644 --- a/polytope_mars/config.py +++ b/polytope_mars/config.py @@ -3,7 +3,6 @@ class DatacubeConfig(ConfigModel): - type: str = "gribjump" config: str = "config.yaml" uri: str = "http://localhost:8000" @@ -23,7 +22,6 @@ class PolygonRulesConfig(ConfigModel): class PolytopeMarsConfig(ConfigModel): - datacube: DatacubeConfig = DatacubeConfig() options: Config = Config() coverageconfig: CovjsonKitConfig = CovjsonKitConfig() diff --git a/polytope_mars/features/timeseries.py b/polytope_mars/features/timeseries.py index ca34109..d326215 100644 --- a/polytope_mars/features/timeseries.py +++ b/polytope_mars/features/timeseries.py @@ -64,9 +64,9 @@ def parse(self, request, feature_config): raise ValueError("Timeseries axes is underspecified in request") if "range" in feature_config: if isinstance(feature_config["range"], dict): - request[feature_config["axis"]] = ( - f"{feature_config['range']['start']}/to/{feature_config['range']['end']}" # noqa: E501 - ) + request[ + feature_config["axis"] + ] = f"{feature_config['range']['start']}/to/{feature_config['range']['end']}" # noqa: E501 if "interval" in feature_config["range"]: request[ feature_config["axis"] diff --git a/polytope_mars/features/verticalprofile.py b/polytope_mars/features/verticalprofile.py index 595e602..757e9da 100644 --- a/polytope_mars/features/verticalprofile.py +++ b/polytope_mars/features/verticalprofile.py @@ -69,9 +69,9 @@ def parse(self, request, feature_config): ) # noqa: E501 if "range" in feature_config: if isinstance(feature_config["range"], dict): - request[feature_config["axis"]] = ( - f"{feature_config['range']['start']}/to/{feature_config['range']['end']}" # noqa: E501 - ) + request[ + feature_config["axis"] + ] = f"{feature_config['range']['start']}/to/{feature_config['range']['end']}" # noqa: E501 if "interval" in feature_config["range"]: request[ feature_config["axis"] From 226714809ffa9162de20ee093760781e13a11535 Mon Sep 17 00:00:00 2001 From: awarde96 Date: Tue, 5 Nov 2024 08:56:40 +0000 Subject: [PATCH 3/5] Fix formatting --- polytope_mars/features/timeseries.py | 6 +++--- polytope_mars/features/verticalprofile.py | 6 +++--- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/polytope_mars/features/timeseries.py b/polytope_mars/features/timeseries.py index d326215..ca34109 100644 --- a/polytope_mars/features/timeseries.py +++ b/polytope_mars/features/timeseries.py @@ -64,9 +64,9 @@ def parse(self, request, feature_config): raise ValueError("Timeseries axes is underspecified in request") if "range" in feature_config: if isinstance(feature_config["range"], dict): - request[ - feature_config["axis"] - ] = f"{feature_config['range']['start']}/to/{feature_config['range']['end']}" # noqa: E501 + request[feature_config["axis"]] = ( + f"{feature_config['range']['start']}/to/{feature_config['range']['end']}" # noqa: E501 + ) if "interval" in feature_config["range"]: request[ feature_config["axis"] diff --git a/polytope_mars/features/verticalprofile.py b/polytope_mars/features/verticalprofile.py index 757e9da..595e602 100644 --- a/polytope_mars/features/verticalprofile.py +++ b/polytope_mars/features/verticalprofile.py @@ -69,9 +69,9 @@ def parse(self, request, feature_config): ) # noqa: E501 if "range" in feature_config: if isinstance(feature_config["range"], dict): - request[ - feature_config["axis"] - ] = f"{feature_config['range']['start']}/to/{feature_config['range']['end']}" # noqa: E501 + request[feature_config["axis"]] = ( + f"{feature_config['range']['start']}/to/{feature_config['range']['end']}" # noqa: E501 + ) if "interval" in feature_config["range"]: request[ feature_config["axis"] From b68377bd0d59f0240ea0c6ce852afa38d8a6bdc9 Mon Sep 17 00:00:00 2001 From: awarde96 Date: Tue, 5 Nov 2024 13:35:24 +0000 Subject: [PATCH 4/5] Bump version --- polytope_mars/version.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/polytope_mars/version.py b/polytope_mars/version.py index 3dc1f76..485f44a 100644 --- a/polytope_mars/version.py +++ b/polytope_mars/version.py @@ -1 +1 @@ -__version__ = "0.1.0" +__version__ = "0.1.1" From d3d8827bb6aa0f1bdb0266c18da95c34bf4d82aa Mon Sep 17 00:00:00 2001 From: awarde96 Date: Tue, 5 Nov 2024 13:59:25 +0000 Subject: [PATCH 5/5] polytope_mars/api.py --- polytope_mars/api.py | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/polytope_mars/api.py b/polytope_mars/api.py index 1e444c0..00ea509 100644 --- a/polytope_mars/api.py +++ b/polytope_mars/api.py @@ -96,8 +96,12 @@ def extract(self, request): feature.validate(request) + logging.debug("Unparsed request: %s", request) + request = feature.parse(request, feature_config_copy) + logging.debug("Parsed request: %s", request) + shapes = self._create_base_shapes(request) shapes.extend(feature.get_shapes())