Skip to content

Commit

Permalink
add origin to job status metadata
Browse files Browse the repository at this point in the history
  • Loading branch information
mcucchi9 committed Nov 12, 2024
1 parent 64778f7 commit 98e1848
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 10 deletions.
1 change: 1 addition & 0 deletions cads_processing_api_service/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ class StatusInfoMetadata(pydantic.BaseModel):
datasetMetadata: dict[str, Any] | None = None
qos: dict[str, Any] | None = None
log: list[tuple[str, str]] | None = None
origin: str | None = None


class StatusInfo(ogc_api_processes_fastapi.models.StatusInfo):
Expand Down
18 changes: 8 additions & 10 deletions cads_processing_api_service/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -641,14 +641,12 @@ def make_status_info(
finished=job["finished_at"],
updated=job["updated_at"],
)
if any(
field is not None for field in [request, results, dataset_metadata, qos, log]
):
status_info.metadata = models.StatusInfoMetadata(
request=request,
results=results,
datasetMetadata=dataset_metadata,
qos=qos,
log=log,
)
status_info.metadata = models.StatusInfoMetadata(
origin=job.get("origin", None),
request=request,
results=results,
datasetMetadata=dataset_metadata,
qos=qos,
log=log,
)
return status_info
2 changes: 2 additions & 0 deletions tests/test_30_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -322,6 +322,7 @@ def test_make_status_info() -> None:
"finished_at": "2023-01-01T16:20:12.175021",
"updated_at": "2023-01-01T16:20:12.175021",
"request_body": {"request": {"product_type": ["reanalysis"]}},
"origin": "api",
}
status_info = utils.make_status_info(job)
exp_status_info = models.StatusInfo(
Expand All @@ -333,5 +334,6 @@ def test_make_status_info() -> None:
started=job["started_at"],
finished=job["finished_at"],
updated=job["updated_at"],
metadata={"origin": "api"},
)
assert status_info == exp_status_info

0 comments on commit 98e1848

Please sign in to comment.