Skip to content

Commit

Permalink
Ensembler Image Building API (#376)
Browse files Browse the repository at this point in the history
* [wip] list images and build image api

* Fix existing api-test

* Update open api spec

* Generate SDK client

* Fix lint

* Update specs/ensembler-images.yaml

* Implement image building API in SDK

* Pin pytest version

* Revert turing/version.py

* Update api test

* Fix lint api

* Fix lint api
  • Loading branch information
Arief Rahmansyah authored May 7, 2024
1 parent b4bc519 commit 9b21e1b
Show file tree
Hide file tree
Showing 56 changed files with 4,313 additions and 241 deletions.
8 changes: 7 additions & 1 deletion .github/workflows/sdk.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ jobs:
strategy:
matrix:
python-version: ["3.8", "3.9", "3.10"]

defaults:
run:
working-directory: ./sdk
Expand All @@ -53,6 +53,12 @@ jobs:
- name: Run unit tests
run: make test

- uses: codecov/codecov-action@v4
with:
flags: sdk-test-${{ matrix.python-version }}
name: sdk-test-${{ matrix.python-version }}
token: ${{ secrets.CODECOV_TOKEN }}

release-rules:
runs-on: ubuntu-latest
outputs:
Expand Down
7 changes: 7 additions & 0 deletions .github/workflows/turing.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -276,6 +276,13 @@ jobs:
working-directory: api
args: --timeout 3m --verbose

- uses: codecov/codecov-action@v4
with:
flags: api-test
name: api-test
token: ${{ secrets.CODECOV_TOKEN }}
working-directory: api

test-engines-router:
runs-on: ubuntu-latest
defaults:
Expand Down
6 changes: 5 additions & 1 deletion api/api/openapi-sdk.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,10 @@ paths:
"/projects/{project_id}/ensemblers/{ensembler_id}":
$ref: "specs/ensemblers.yaml#/paths/~1projects~1{project_id}~1ensemblers~1{ensembler_id}"

# E N S E M B L E R I M A G E S
"/projects/{project_id}/ensemblers/{ensembler_id}/images":
$ref: "specs/ensembler-images.yaml#/paths/~1projects~1{project_id}~1ensemblers~1{ensembler_id}~1images"

# J O B S
"/projects/{project_id}/jobs":
$ref: "specs/jobs.yaml#/paths/~1projects~1{project_id}~1jobs"
Expand All @@ -40,4 +44,4 @@ paths:
"/projects/{project_id}/routers/{router_id}/events":
$ref: "specs/routers.yaml#/paths/~1projects~1{project_id}~1routers~1{router_id}~1events"
"/projects/{project_id}/router-versions":
$ref: "specs/routers.yaml#/paths/~1projects~1{project_id}~1router-versions"
$ref: "specs/routers.yaml#/paths/~1projects~1{project_id}~1router-versions"
129 changes: 129 additions & 0 deletions api/api/openapi.bundle.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -183,6 +183,77 @@ paths:
summary: Updates existing Ensembler with the data provided in the payload
tags:
- Ensembler
/projects/{project_id}/ensemblers/{ensembler_id}/images:
get:
operationId: ListEnsemblerImages
parameters:
- in: path
name: project_id
required: true
schema:
format: int32
type: integer
- in: path
name: ensembler_id
required: true
schema:
format: int32
type: integer
- in: query
name: runner_type
required: false
schema:
$ref: '#/components/schemas/EnsemblerImageRunnerType'
responses:
"200":
content:
application/json:
schema:
$ref: '#/components/schemas/EnsemblerImages'
description: A JSON object
"400":
description: Invalid request body
"404":
description: Ensembler not found
"500":
description: Unable to list ensembler images
summary: Returns a list of ensembler images that belong to the ensembler
tags:
- Ensembler Images
put:
operationId: CreateEnsemblerImage
parameters:
- in: path
name: project_id
required: true
schema:
format: int32
type: integer
- in: path
name: ensembler_id
required: true
schema:
format: int32
type: integer
requestBody:
content:
application/json:
schema:
$ref: '#/components/schemas/BuildEnsemblerImageRequest'
description: A JSON object containing information about the ensembler
required: true
responses:
"202":
description: Accepted
"400":
description: Invalid request body
"404":
description: Ensembler not found
"500":
description: Unable to build ensembler image
summary: Creates a new ensembler image
tags:
- Ensembler Images
/projects/{project_id}/jobs:
get:
operationId: ListEnsemblingJobs
Expand Down Expand Up @@ -1441,6 +1512,64 @@ components:
Id:
format: int32
type: integer
EnsemblerImages:
items:
$ref: '#/components/schemas/EnsemblerImage'
type: array
EnsemblerImage:
example:
image_ref: image_ref
project_id: 0
image_building_job_status:
message: message
exists: true
ensembler_id: 6
properties:
project_id:
format: int32
type: integer
ensembler_id:
format: int32
type: integer
runner_type:
$ref: '#/components/schemas/EnsemblerImageRunnerType'
image_ref:
type: string
exists:
type: boolean
image_building_job_status:
$ref: '#/components/schemas/ImageBuildingJobStatus'
type: object
EnsemblerImageRunnerType:
enum:
- job
- service
nullable: true
type: string
ImageBuildingJobStatus:
example:
message: message
properties:
state:
$ref: '#/components/schemas/ImageBuildingJobState'
message:
type: string
type: object
ImageBuildingJobState:
enum:
- active
- succeeded
- failed
- unknown
type: string
BuildEnsemblerImageRequest:
example: {}
properties:
runner_type:
$ref: '#/components/schemas/EnsemblerImageRunnerType'
required:
- runner_type
type: object
EnsemblingJobPaginatedResults:
allOf:
- $ref: '#/components/schemas/EnsemblersPaginatedResults_allOf'
Expand Down
4 changes: 4 additions & 0 deletions api/api/openapi.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,10 @@ paths:
"/projects/{project_id}/ensemblers/{ensembler_id}":
$ref: "specs/ensemblers.yaml#/paths/~1projects~1{project_id}~1ensemblers~1{ensembler_id}"

# E N S E M B L E R I M A G E S
"/projects/{project_id}/ensemblers/{ensembler_id}/images":
$ref: "specs/ensembler-images.yaml#/paths/~1projects~1{project_id}~1ensemblers~1{ensembler_id}~1images"

# J O B S
"/projects/{project_id}/jobs":
$ref: "specs/jobs.yaml#/paths/~1projects~1{project_id}~1jobs"
Expand Down
136 changes: 136 additions & 0 deletions api/api/specs/ensembler-images.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,136 @@
openapi: 3.0.3
info:
title: Endpoints and schemas of Turing ensembler images
version: 0.0.1

.tags: &tags
- "Ensembler Images"

.id: &id
type: "integer"
format: "int32"

paths:
"/projects/{project_id}/ensemblers/{ensembler_id}/images":
get:
tags: *tags
operationId: "ListEnsemblerImages"
summary: Returns a list of ensembler images that belong to the ensembler
parameters:
- in: path
name: project_id
schema:
<<: *id
required: true
- in: path
name: ensembler_id
schema:
<<: *id
required: true
- in: query
name: runner_type
schema:
"$ref": "#/components/schemas/EnsemblerImageRunnerType"
required: false
responses:
"200":
description: A JSON object
content:
application/json:
schema:
$ref: "#/components/schemas/EnsemblerImages"
"400":
description: Invalid request body
"404":
description: Ensembler not found
"500":
description: Unable to list ensembler images
put:
tags: *tags
operationId: "CreateEnsemblerImage"
summary: Creates a new ensembler image
parameters:
- in: path
name: project_id
schema:
<<: *id
required: true
- in: path
name: ensembler_id
schema:
<<: *id
required: true
requestBody:
description: A JSON object containing information about the ensembler
required: true
content:
application/json:
schema:
$ref: "#/components/schemas/BuildEnsemblerImageRequest"
responses:
"202":
description: Accepted
"400":
description: Invalid request body
"404":
description: Ensembler not found
"500":
description: Unable to build ensembler image

components:
schemas:
EnsemblerId:
$ref: "./common.yaml#/components/schemas/IdObject"

EnsemblerImages:
type: array
items:
$ref: "#/components/schemas/EnsemblerImage"

EnsemblerImage:
type: object
properties:
project_id:
type: integer
format: int32
ensembler_id:
type: integer
format: int32
runner_type:
"$ref": "#/components/schemas/EnsemblerImageRunnerType"
image_ref:
type: string
exists:
type: boolean
image_building_job_status:
"$ref": "#/components/schemas/ImageBuildingJobStatus"

EnsemblerImageRunnerType:
type: string
nullable: true
enum:
- job
- service

ImageBuildingJobStatus:
type: object
properties:
state:
"$ref": "#/components/schemas/ImageBuildingJobState"
message:
type: string
ImageBuildingJobState:
type: string
enum:
- active
- succeeded
- failed
- unknown

BuildEnsemblerImageRequest:
type: object
properties:
runner_type:
"$ref": "#/components/schemas/EnsemblerImageRunnerType"
required:
- runner_type
1 change: 1 addition & 0 deletions api/go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -137,6 +137,7 @@ require (
github.com/jackc/pgtype v1.12.0 // indirect
github.com/jackc/pgx/v4 v4.17.2 // indirect
github.com/jbenet/go-context v0.0.0-20150711004518-d14ea06fba99 // indirect
github.com/jedib0t/go-pretty/v6 v6.5.3 // indirect
github.com/jinzhu/inflection v1.0.0 // indirect
github.com/jinzhu/now v1.1.5 // indirect
github.com/josharian/intern v1.0.0 // indirect
Expand Down
2 changes: 2 additions & 0 deletions api/go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -453,6 +453,8 @@ github.com/jackc/puddle v1.1.3/go.mod h1:m4B5Dj62Y0fbyuIc15OsIqK0+JU8nkqQjsgx7dv
github.com/jackc/puddle v1.3.0/go.mod h1:m4B5Dj62Y0fbyuIc15OsIqK0+JU8nkqQjsgx7dvjSWk=
github.com/jbenet/go-context v0.0.0-20150711004518-d14ea06fba99 h1:BQSFePA1RWJOlocH6Fxy8MmwDt+yVQYULKfN0RoTN8A=
github.com/jbenet/go-context v0.0.0-20150711004518-d14ea06fba99/go.mod h1:1lJo3i6rXxKeerYnT8Nvf0QmHCRC1n8sfWVwXF2Frvo=
github.com/jedib0t/go-pretty/v6 v6.5.3 h1:GIXn6Er/anHTkVUoufs7ptEvxdD6KIhR7Axa2wYCPF0=
github.com/jedib0t/go-pretty/v6 v6.5.3/go.mod h1:5LQIxa52oJ/DlDSLv0HEkWOFMDGoWkJb9ss5KqPpJBg=
github.com/jessevdk/go-flags v1.5.0/go.mod h1:Fw0T6WPc1dYxT4mKEZRfG5kJhaTDP9pj1c2EWnYs/m4=
github.com/jhump/protoreflect v1.6.0/go.mod h1:eaTn3RZAmMBcV0fifFvlm6VHNz3wSkYyXYWUh7ymB74=
github.com/jhump/protoreflect v1.12.1-0.20220721211354-060cc04fc18b h1:izTof8BKh/nE1wrKOrloNA5q4odOarjf+Xpe+4qow98=
Expand Down
Loading

0 comments on commit 9b21e1b

Please sign in to comment.