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

Dedicated exception product processing #729

Merged
merged 2 commits into from
Jan 14, 2025
Merged
Show file tree
Hide file tree
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
6 changes: 6 additions & 0 deletions cdci_data_analysis/analysis/exceptions.py
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,12 @@ class RequestNotUnderstood(BadRequest):
"""


class ProductProcessingError(RuntimeError):
"""
For an error in the post-processing, caused by the user's request.
"""


class RequestNotAuthorized(BadRequest):
def __init__(self, message, debug_message=''):
self.debug_message = debug_message
Expand Down
6 changes: 5 additions & 1 deletion cdci_data_analysis/analysis/instrument.py
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@
from .queries import ProductQuery, SourceQuery, InstrumentQuery
from .io_helper import upload_file, upload_files_request

from .exceptions import RequestNotUnderstood, RequestNotAuthorized, InternalError
from .exceptions import RequestNotUnderstood, RequestNotAuthorized, InternalError, ProductProcessingError
from ..flask_app.sentry import sentry

from oda_api.api import DispatcherAPI, RemoteException, Unauthorized, DispatcherException, DispatcherNotAvailable, UnexpectedDispatcherStatusCode, RequestNotUnderstood as RequestNotUnderstoodOdaApi
Expand Down Expand Up @@ -480,6 +480,10 @@
except RequestNotUnderstood as e:
logger.warning("bad request from user, passing through: %s", e)
raise
except ProductProcessingError as e:
logger.warning("error in the post processing of the products to fail, passing through: %s", e)
query_out.set_status(1, message="Error during the products post processing",

Check warning on line 485 in cdci_data_analysis/analysis/instrument.py

View check run for this annotation

Codecov / codecov/patch

cdci_data_analysis/analysis/instrument.py#L484-L485

Added lines #L484 - L485 were not covered by tests
error_message=str(e))
except InternalError as e:
if hasattr(e, 'message') and e.message is not None:
message = e.message
Expand Down
6 changes: 5 additions & 1 deletion cdci_data_analysis/analysis/queries.py
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@
)
from .products import SpectralFitProduct, QueryOutput, QueryProductList, ImageProduct
from .io_helper import FilePath
from .exceptions import RequestNotUnderstood, InternalError
from .exceptions import RequestNotUnderstood, InternalError, ProductProcessingError

logger = logging.getLogger(__name__)

Expand Down Expand Up @@ -614,6 +614,10 @@
logger.error("passing request issue: %s", e)
raise

except ProductProcessingError as e:
logger.error("product processing error: %s", e)
raise

Check warning on line 619 in cdci_data_analysis/analysis/queries.py

View check run for this annotation

Codecov / codecov/patch

cdci_data_analysis/analysis/queries.py#L618-L619

Added lines #L618 - L619 were not covered by tests

except Exception as e:
logger.exception("failed to get query products")
internal_error_message = "Error when getting query products"
Expand Down
Loading