Skip to content

Commit

Permalink
Merge pull request #205 from ecmwf-projects/fix-deleted-requests
Browse files Browse the repository at this point in the history
Fix issue with get jobs and deleted requests
  • Loading branch information
mcucchi9 authored Aug 29, 2024
2 parents 926020d + 4d198bb commit 4960972
Show file tree
Hide file tree
Showing 5 changed files with 17 additions and 6 deletions.
11 changes: 8 additions & 3 deletions cads_processing_api_service/clients.py
Original file line number Diff line number Diff line change
Expand Up @@ -279,9 +279,14 @@ def post_process_execution(
def get_jobs(
self,
processID: list[str] | None = fastapi.Query(None),
status: (
list[ogc_api_processes_fastapi.models.StatusCode] | None
) = fastapi.Query(None),
status: list[models.StatusCode] | None = fastapi.Query(
[
ogc_api_processes_fastapi.models.StatusCode.accepted,
ogc_api_processes_fastapi.models.StatusCode.running,
ogc_api_processes_fastapi.models.StatusCode.successful,
ogc_api_processes_fastapi.models.StatusCode.failed,
]
),
limit: int | None = fastapi.Query(10, ge=1, le=10000),
sortby: utils.JobSortCriterion | None = fastapi.Query(
utils.JobSortCriterion.created_at_desc
Expand Down
8 changes: 8 additions & 0 deletions cads_processing_api_service/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,12 +15,20 @@
# limitations under the License

import datetime
import enum
from typing import Any

import ogc_api_processes_fastapi.models
import pydantic


class StatusCode(str, enum.Enum):
accepted: str = "accepted"
running: str = "running"
successful: str = "successful"
failed: str = "failed"


class StatusInfoMetadata(pydantic.BaseModel):
request: dict[str, Any] | None = None
results: dict[str, Any] | None = None
Expand Down
2 changes: 1 addition & 1 deletion cads_processing_api_service/serializers.py
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ def serialize_process_description(
cds_form = db_model.resource_data.form_data # type: ignore
process_inputs = {}
if cds_form:
process_inputs = translators.translate_cds_form(cds_form) # type: ignore
process_inputs = translators.translate_cds_form(cds_form)
retval = ogc_api_processes_fastapi.models.ProcessDescription(
**process_summary.model_dump(),
inputs=process_inputs,
Expand Down
1 change: 0 additions & 1 deletion cads_processing_api_service/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -232,7 +232,6 @@ def apply_job_filters(
statement = statement.where(
getattr(resource, filter_key).in_(filter_values)
)
statement = statement.where(resource.status != "dismissed")
return statement


Expand Down
1 change: 0 additions & 1 deletion tests/test_30_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,6 @@ def test_apply_job_filters() -> None:
exp_params = {
"process_id_1": ["process"],
"status_1": ["successful", "failed"],
"status_2": "dismissed",
}
exp_substatement = (
"WHERE system_requests.process_id IN (__[POSTCOMPILE_process_id_1]) "
Expand Down

0 comments on commit 4960972

Please sign in to comment.