Skip to content

Commit

Permalink
polytope errors
Browse files Browse the repository at this point in the history
  • Loading branch information
peshence committed Sep 18, 2024
1 parent ff5179b commit 491947d
Showing 1 changed file with 8 additions and 3 deletions.
11 changes: 8 additions & 3 deletions polytope_server/common/datasource/polytope.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,8 @@

import yaml

from polytope.utility.exceptions import PolytopeError

from . import datasource


Expand All @@ -42,7 +44,7 @@ def __init__(self, config):
self.config_file = "/tmp/gribjump.yaml"
with open(self.config_file, "w") as f:
f.write(yaml.dump(self.config["gribjump_config"]))
self.config['datacube']['config'] = self.config_file
self.config["datacube"]["config"] = self.config_file
os.environ["GRIBJUMP_CONFIG_FILE"] = self.config_file

self.polytope_options = self.config.get("polytope-options", {})
Expand All @@ -60,8 +62,11 @@ def retrieve(self, request):
r = yaml.safe_load(request.user_request)
logging.info(r)

self.output = self.polytope_mars.extract(r)
self.output = json.dumps(self.output).encode("utf-8")
try:
self.output = self.polytope_mars.extract(r)
self.output = json.dumps(self.output).encode("utf-8")
except PolytopeError as e:
self.output = json.dumps({"error": str(e)}).encode("utf-8")
# logging.info(self.output)
return True

Expand Down

0 comments on commit 491947d

Please sign in to comment.