Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

polytope errors #19

Merged
merged 3 commits into from
Sep 18, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 9 additions & 5 deletions polytope_server/common/datasource/polytope.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,9 +22,9 @@
import logging
import os

from polytope_mars.api import PolytopeMars

import yaml
from polytope.utility.exceptions import PolytopeError
from polytope_mars.api import PolytopeMars

from . import datasource

Expand All @@ -42,7 +42,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 +60,12 @@ 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")
raise e
# logging.info(self.output)
return True

Expand Down
Loading