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

feat: Add endpoint for updating job info. #59

Merged
merged 4 commits into from
Nov 19, 2024
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
66 changes: 65 additions & 1 deletion backend/oas/provider/openapi.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -228,6 +228,54 @@ paths:
$ref: '#/components/schemas/error.ConflictError'
example:
detail: The specified job is not in a status thatt allows transition to the requested status.
/jobs/{job_id}/job_info:
patch:
summary: Update selected quantum job's job_info by placing job results
description: |
Used by device to set results or error details in job_info、accompanied by appropriate status updating.
Note that job info descriptor (sampling, estimation, etc) cannot be modified.
operationId: patchJobInfo
security: []
tags:
- jobs
parameters:
- in: path
name: job_id
required: true
description: Job identifier
schema:
type: string
requestBody:
description: Modifications applied to Job info
content:
application/json:
schema:
$ref: '#/components/schemas/jobs.UpdateJobInfoRequest'
responses:
'200':
description: job info updated
content:
application/json:
schema:
$ref: '#/components/schemas/jobs.UpdateJobInfoResponse'
example:
message: Job info updated.
'400':
description: Bad Request
content:
application/json:
schema:
$ref: '#/components/schemas/error.BadRequest'
example:
detail: Bad request malformed input data
'404':
description: Not Found
content:
application/json:
schema:
$ref: '#/components/schemas/error.NotFoundError'
example:
detail: Job not found
components:
schemas:
devices.DeviceStatusUpdate:
Expand Down Expand Up @@ -261,7 +309,7 @@ components:
type: string
example: DeviceCalibrationUpdate
device_info:
description: Calibration_data and n_nodes etc. Make sure that the value is valid JSON format.
description: Calibration_data and n_nodes etc. Make sure that the value is a valid JSON data.
type: string
example: |-
{
Expand Down Expand Up @@ -528,3 +576,19 @@ components:
type: string
required:
- detail
jobs.UpdateJobInfoRequest:
type: object
properties:
transpiled_code:
type: string
result:
type: string
reason:
type: string
jobs.UpdateJobInfoResponse:
type: object
properties:
message:
type: string
required:
- message
131 changes: 89 additions & 42 deletions backend/oas/provider/paths/jobs.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -7,24 +7,24 @@ jobs:
operationId: getjobs
security: []
parameters:
- in: query
name: device_id
required: true
description: "Device identifier"
schema: {type: string, example: "Kawasaki"}
- in: query
name: status
description: "Additional search parameter:<br/> Search jobs with specified status only"
schema:
$ref: "../schemas/jobs.yaml#/jobs.JobStatus"
- in: query
name: max_results
description: "Additional search parameter:<br/> Set max number of quantum jobs to return in single request"
schema: {type: integer, example: 1}
- in: query
name: timestamp
description: "Additional search parameter:<br/> Jobs created after the specified timetsamp"
schema: {type: string, example: '2022-12-15 15:54:46'}
- in: query
name: device_id
required: true
description: "Device identifier"
schema: { type: string, example: "Kawasaki" }
- in: query
name: status
description: "Additional search parameter:<br/> Search jobs with specified status only"
schema:
$ref: "../schemas/jobs.yaml#/jobs.JobStatus"
- in: query
name: max_results
description: "Additional search parameter:<br/> Set max number of quantum jobs to return in single request"
schema: { type: integer, example: 1 }
- in: query
name: timestamp
description: "Additional search parameter:<br/> Jobs created after the specified timetsamp"
schema: { type: string, example: "2022-12-15 15:54:46" }
responses:
"200":
description: "List of jobs for a device"
Expand All @@ -34,20 +34,20 @@ jobs:
type: array
items:
$ref: "../schemas/jobs.yaml#/jobs.JobDef"
'400':
"400":
description: Bad Request
content:
application/json:
schema:
$ref: '../schemas/error.yaml#/error.BadRequest'
$ref: "../schemas/error.yaml#/error.BadRequest"
example:
detail: Bad request malformed input data
'500':
"500":
description: Internal Server Error
content:
application/json:
schema:
$ref: '../schemas/error.yaml#/error.InternalServerError'
$ref: "../schemas/error.yaml#/error.InternalServerError"
example:
detail: Internal server error

Expand All @@ -58,77 +58,124 @@ jobs.jobId:
operationId: getJob
security: []
tags:
- jobs
- jobs
parameters:
- in: path
name: job_id
required: true
description: "Job identifier"
schema: {type: string}
- in: path
name: job_id
required: true
description: "Job identifier"
schema: { type: string }
responses:
"200":
description: "Return quantum job"
content:
application/json:
schema:
$ref: "../schemas/jobs.yaml#/jobs.JobDef"
'400':
"400":
description: Bad Request
content:
application/json:
schema:
$ref: '../schemas/error.yaml#/error.BadRequest'
$ref: "../schemas/error.yaml#/error.BadRequest"
example:
detail: Bad request malformed input data
'404':
"404":
description: Not Found
content:
application/json:
schema:
$ref: '../schemas/error.yaml#/error.NotFoundError'
$ref: "../schemas/error.yaml#/error.NotFoundError"
example:
detail: job not found
patch:
summary: "Modify selected quantum job (update status)."
description: "Used by device to set job status to \"RUNNING\".<br/>Other statuses are set by CloudAPI automatically when result is created"
description: 'Used by device to set job status to "RUNNING".<br/>Other statuses are set by CloudAPI automatically when result is created'
operationId: patchJob
security: []
tags:
- jobs
parameters:
- in: path
name: job_id
required: true
description: "Job identifier"
schema: {type: string}
- in: path
name: job_id
required: true
description: "Job identifier"
schema: { type: string }
requestBody:
description: "New job status. "
content:
application/json:
schema:
$ref: "../schemas/jobs.yaml#/jobs.JobStatusUpdate"
responses:
'200':
"200":
description: job data updated
content:
application/json:
schema:
$ref: '../schemas/jobs.yaml#/jobs.JobStatusUpdateResponse'
$ref: "../schemas/jobs.yaml#/jobs.JobStatusUpdateResponse"
example:
message: job data updated
"404":
description: Not Found
content:
application/json:
schema:
$ref: '../schemas/error.yaml#/error.NotFoundError'
$ref: "../schemas/error.yaml#/error.NotFoundError"
example:
detail: Job not found
"409":
description: Returned when the specified job is not in a status thatt allows transition to the requested status.
content:
application/json:
schema:
$ref: '../schemas/error.yaml#/error.ConflictError'
$ref: "../schemas/error.yaml#/error.ConflictError"
example:
detail: The specified job is not in a status thatt allows transition to the requested status.
jobs.jobInfo:
patch:
summary: "Update selected quantum job's job_info by placing job results"
description: |
Used by device to set results or error details in job_info、accompanied by appropriate status updating.
Note that job info descriptor (sampling, estimation, etc) cannot be modified.
operationId: patchJobInfo
security: []
tags:
- jobs
parameters:
- in: path
name: job_id
required: true
description: "Job identifier"
schema: { type: string }
requestBody:
description: "Modifications applied to Job info"
content:
application/json:
schema:
$ref: "../schemas/jobs.yaml#/jobs.UpdateJobInfoRequest"
responses:
"200":
description: job info updated
content:
application/json:
schema:
$ref: "../schemas/jobs.yaml#/jobs.UpdateJobInfoResponse"
example:
message: Job info updated.
"400":
description: Bad Request
content:
application/json:
schema:
$ref: "../schemas/error.yaml#/error.BadRequest"
example:
detail: Bad request malformed input data
"404":
description: Not Found
content:
application/json:
schema:
$ref: "../schemas/error.yaml#/error.NotFoundError"
example:
detail: Job not found
2 changes: 2 additions & 0 deletions backend/oas/provider/root.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -19,3 +19,5 @@ paths:
$ref: ./paths/jobs.yaml#/jobs
/jobs/{job_id}:
$ref: ./paths/jobs.yaml#/jobs.jobId
/jobs/{job_id}/job_info:
$ref: ./paths/jobs.yaml#/jobs.jobInfo
17 changes: 17 additions & 0 deletions backend/oas/provider/schemas/jobs.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -233,3 +233,20 @@ jobs.JobStatusUpdateResponse:
required:
- message

jobs.UpdateJobInfoRequest:
type: object
properties:
transpiled_code:
type: string
result:
type: string
reason:
type: string

jobs.UpdateJobInfoResponse:
type: object
properties:
message:
type: string
required:
- message
Loading
Loading