Skip to content

Commit ae0c667

Browse files
committed
black and lint
1 parent ea8e6f4 commit ae0c667

File tree

2 files changed

+23
-18
lines changed

2 files changed

+23
-18
lines changed

gateway/api/repositories/jobs.py

+7
Original file line numberDiff line numberDiff line change
@@ -112,4 +112,11 @@ def update_job_sub_status(self, job: Job, sub_status: Optional[str]) -> bool:
112112
updated = Job.objects.filter(id=job.id, status=Job.RUNNING).update(
113113
sub_status=sub_status
114114
)
115+
if not updated:
116+
logger.warning(
117+
"Job[%s].sub_status cannot be updated because "
118+
"it is not in RUNNING state or id doesn't exist",
119+
job.id,
120+
)
121+
115122
return updated == 1

gateway/api/v1/views/jobs.py

+16-18
Original file line numberDiff line numberDiff line change
@@ -76,10 +76,8 @@ def result(self, request, pk=None):
7676
request_body=openapi.Schema(
7777
type=openapi.TYPE_OBJECT,
7878
required=["sub_status"],
79-
properties={
80-
"sub_status": openapi.Schema(type=openapi.TYPE_STRING)
81-
},
82-
description="Value to populate the sub-status of a Job"
79+
properties={"sub_status": openapi.Schema(type=openapi.TYPE_STRING)},
80+
description="Value to populate the sub-status of a Job",
8381
),
8482
responses={
8583
status.HTTP_200_OK: openapi.Response(
@@ -89,10 +87,10 @@ def result(self, request, pk=None):
8987
properties={
9088
"message": openapi.Schema(
9189
type=openapi.TYPE_STRING,
92-
example="Sub status updated correctly"
90+
example="Sub status updated correctly",
9391
)
94-
}
95-
)
92+
},
93+
),
9694
),
9795
status.HTTP_400_BAD_REQUEST: openapi.Response(
9896
description="In case your request doesnt have a valid 'sub_status'.",
@@ -101,10 +99,10 @@ def result(self, request, pk=None):
10199
properties={
102100
"message": openapi.Schema(
103101
type=openapi.TYPE_STRING,
104-
example="'sub_status' not provided or is not valid"
102+
example="'sub_status' not provided or is not valid",
105103
)
106-
}
107-
)
104+
},
105+
),
108106
),
109107
status.HTTP_403_FORBIDDEN: openapi.Response(
110108
description="In case you cannot change the sub_status.",
@@ -113,23 +111,23 @@ def result(self, request, pk=None):
113111
properties={
114112
"message": openapi.Schema(
115113
type=openapi.TYPE_STRING,
116-
example="Cannot update 'sub_status' when is not in RUNNING status. (Currently PENDING)"
114+
example="Cannot update 'sub_status' when "
115+
"is not in RUNNING status. (Currently PENDING)",
117116
)
118-
}
119-
)
117+
},
118+
),
120119
),
121120
status.HTTP_404_NOT_FOUND: openapi.Response(
122121
description="In case the job doesnt exist or you dont have access to it.",
123122
schema=openapi.Schema(
124123
type=openapi.TYPE_OBJECT,
125124
properties={
126125
"message": openapi.Schema(
127-
type=openapi.TYPE_STRING,
128-
example="Job [XXXX] not found"
126+
type=openapi.TYPE_STRING, example="Job [XXXX] not found"
129127
)
130-
}
131-
)
132-
)
128+
},
129+
),
130+
),
133131
},
134132
)
135133
@action(methods=["POST"], detail=True)

0 commit comments

Comments
 (0)