Skip to content

Commit 4c09a9a

Browse files
committed
feat: added service information in job details
1 parent 1fd06e3 commit 4c09a9a

File tree

6 files changed

+24
-8
lines changed

6 files changed

+24
-8
lines changed

app/schemas/unit_job.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,9 @@ class ProcessingJobSummary(BaseModel):
4242
description="Current status of the processing job",
4343
examples=[ProcessingStatusEnum.RUNNING],
4444
)
45+
service: ServiceDetails = Field(
46+
..., description="Details of the service to be executed"
47+
)
4548
parameters: dict = Field(
4649
...,
4750
description="JSON representing the parameters for the service execution",
@@ -50,9 +53,6 @@ class ProcessingJobSummary(BaseModel):
5053

5154

5255
class ProcessingJobDetails(BaseModel):
53-
service: ServiceDetails = Field(
54-
..., description="Details of the service to be executed"
55-
)
5656
created: datetime = Field(..., description="Creation time of the processing job")
5757
updated: datetime = Field(
5858
...,

app/schemas/upscale_task.py

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,11 @@ class UpscalingTaskSummary(BaseModel):
2626

2727
class UpscalingTaskDetails(BaseModel):
2828
service: ServiceDetails = Field(
29-
..., description="Details of the service to be executed"
29+
...,
30+
description="Details of the service to be executed",
31+
examples=[
32+
ServiceDetails(endpoint="https://platform.eo/", application="my-app")
33+
],
3034
)
3135
created: datetime = Field(..., description="Creation time of the processing job")
3236
updated: datetime = Field(
@@ -44,13 +48,19 @@ class UpscalingTaskDetails(BaseModel):
4448
label=ProcessTypeEnum.OPENEO,
4549
status=ProcessingStatusEnum.FINISHED,
4650
parameters={"param1": "value1", "param2": "value2"},
51+
service=ServiceDetails(
52+
endpoint="https://platform.eo/", application="my-app"
53+
),
4754
),
4855
ProcessingJobSummary(
4956
id=1,
5057
title="Upscaling Job 2",
5158
label=ProcessTypeEnum.OPENEO,
5259
status=ProcessingStatusEnum.RUNNING,
5360
parameters={"param1": "value1", "param2": "value2"},
61+
service=ServiceDetails(
62+
endpoint="https://platform.eo/", application="my-app"
63+
),
5464
),
5565
]
5666
],

app/services/processing.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -67,6 +67,7 @@ def create_processing_job(
6767
label=request.label,
6868
status=record.status,
6969
parameters=request.parameters,
70+
service=request.service,
7071
)
7172

7273

@@ -131,6 +132,7 @@ def get_processing_jobs_by_user_id(
131132
label=record.label,
132133
status=record.status,
133134
parameters=json.loads(record.parameters),
135+
service=ServiceDetails.model_validate_json(record.service or "{}"),
134136
)
135137
)
136138
return jobs

tests/conftest.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -63,14 +63,14 @@ def fake_processing_job_summary():
6363
label=ProcessTypeEnum.OPENEO,
6464
status=ProcessingStatusEnum.CREATED,
6565
parameters={"param1": "value1", "param2": "value2"},
66+
service=ServiceDetails(endpoint="foo", application="bar"),
6667
)
6768

6869

6970
@pytest.fixture
7071
def fake_processing_job(fake_processing_job_summary, fake_processing_job_request):
7172
return ProcessingJob(
7273
**(fake_processing_job_summary.model_dump()),
73-
service=fake_processing_job_request.service,
7474
created=datetime.now(),
7575
updated=datetime.now()
7676
)

tests/services/test_processing.py

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,7 @@ def test_create_processing_job_calls_platform_execute(
6363
label=ProcessTypeEnum.OPENEO,
6464
status=ProcessingStatusEnum.CREATED,
6565
parameters=fake_job.parameters,
66+
service=fake_job.service,
6667
)
6768
fake_record = ProcessingJobRecord(
6869
id=fake_result,
@@ -108,6 +109,7 @@ def test_create_processing_job_calls_platform_execute_failure(
108109
label=ProcessTypeEnum.OPENEO,
109110
status=ProcessingStatusEnum.CREATED,
110111
parameters=fake_job.parameters,
112+
service=fake_job.service,
111113
)
112114
fake_record = ProcessingJobRecord(
113115
id=fake_result,
@@ -166,7 +168,7 @@ def test_get_processing_jobs_with_active_and_inactive_statuses(
166168
title="Finished Job",
167169
status=ProcessingStatusEnum.FAILED,
168170
parameters="{}",
169-
service=json.dumps({"foo": "bar"}),
171+
service=json.dumps({"application": "foo", "endpoint": "bar"}),
170172
)
171173
mock_get_jobs.return_value = [fake_processing_job_record, inactive_job]
172174
mock_get_job_status.return_value = ProcessingStatusEnum.RUNNING
@@ -222,7 +224,7 @@ def test_get_processing_jobs_with_finished_statuses(
222224
label=ProcessTypeEnum.OGC_API_PROCESS,
223225
title="Finished Job",
224226
status=ProcessingStatusEnum.FINISHED,
225-
service=json.dumps({"foo": "bar"}),
227+
service=json.dumps({"application": "foo", "endpoint": "bar"}),
226228
parameters="{}",
227229
)
228230
finished_job_result = ProcessingJobRecord(
@@ -231,7 +233,7 @@ def test_get_processing_jobs_with_finished_statuses(
231233
label=ProcessTypeEnum.OGC_API_PROCESS,
232234
title="Finished Job",
233235
status=ProcessingStatusEnum.FINISHED,
234-
service=json.dumps({"foo": "bar"}),
236+
service=json.dumps({"application": "foo", "endpoint": "bar"}),
235237
parameters="{}",
236238
)
237239
mock_get_jobs.return_value = [finished_job_no_result, finished_job_result]

tests/services/test_upscaling.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
from app.schemas.unit_job import (
77
BaseJobRequest,
88
ProcessingJobSummary,
9+
ServiceDetails,
910
)
1011
from app.services.upscaling import (
1112
_get_upscale_status,
@@ -24,6 +25,7 @@ def make_job(status: ProcessingStatusEnum) -> ProcessingJobSummary:
2425
status=status,
2526
label=ProcessTypeEnum.OPENEO,
2627
parameters={"param1": "value1", "param2": "value2"},
28+
service=ServiceDetails(endpoint="foo.bar", application="my-app"),
2729
)
2830

2931

0 commit comments

Comments
 (0)