Skip to content

Commit

Permalink
feat: remove model instance (#320)
Browse files Browse the repository at this point in the history
Because

- remove model instance concept

This commit

- use only the model concept to replace the model instance
- INS-335
  • Loading branch information
Phelan164 committed Apr 4, 2023
1 parent 64b4fd0 commit 15e1b62
Show file tree
Hide file tree
Showing 71 changed files with 4,553 additions and 5,644 deletions.
2 changes: 2 additions & 0 deletions Dockerfile.dev
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,8 @@ COPY . .
RUN chown -R nobody:nogroup /go
RUN chown -R nobody:nogroup /tmp
RUN mkdir /.cache && chown -R nobody:nogroup /.cache
# Need permission of /nonexistent folder for HuggingFace internal process.
RUN mkdir /nonexistent > /dev/null && chown -R nobody:nogroup /nonexistent

ENV GOCACHE /go/.cache/go-build
ENV GOENV /go/.config/go/env
Expand Down
2 changes: 0 additions & 2 deletions cmd/init/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@ import (

func createModelDefinition(db *gorm.DB, modelDef *modelPB.ModelDefinition) error {
modelSpecBytes, _ := json.Marshal(modelDef.GetModelSpec())
modelInstanceSpecBytes, _ := json.Marshal(modelDef.GetModelInstanceSpec())
if err := databaseInit.CreateModelDefinitionRecord(
db,
modelDef.GetId(),
Expand All @@ -26,7 +25,6 @@ func createModelDefinition(db *gorm.DB, modelDef *modelPB.ModelDefinition) error
modelDef.GetDocumentationUrl(),
modelDef.GetIcon(),
modelSpecBytes,
modelInstanceSpecBytes,
datamodel.ReleaseStage(modelDef.GetReleaseStage()),
); err != nil {
return err
Expand Down
8 changes: 4 additions & 4 deletions cmd/main/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -183,13 +183,13 @@ func main() {
}),
)

// Register custom route for POST /v1alpha/models/{name=models/*/instances/*}/test-multipart which makes model inference for REST multiple-part form-data
if err := publicGwS.HandlePath("POST", "/v1alpha/{name=models/*/instances/*}/test-multipart", middleware.AppendCustomHeaderMiddleware(handler.HandleTestModelInstanceByUpload)); err != nil {
// Register custom route for POST /v1alpha/models/{name=models/*}/test-multipart which makes model inference for REST multiple-part form-data
if err := publicGwS.HandlePath("POST", "/v1alpha/{name=models/*}/test-multipart", middleware.AppendCustomHeaderMiddleware(handler.HandleTestModelByUpload)); err != nil {
panic(err)
}

// Register custom route for POST /v1alpha/models/{name=models/*/instances/*}/trigger-multipart which makes model inference for REST multiple-part form-data
if err := publicGwS.HandlePath("POST", "/v1alpha/{name=models/*/instances/*}/trigger-multipart", middleware.AppendCustomHeaderMiddleware(handler.HandleTriggerModelInstanceByUpload)); err != nil {
// Register custom route for POST /v1alpha/models/{name=models/*}/trigger-multipart which makes model inference for REST multiple-part form-data
if err := publicGwS.HandlePath("POST", "/v1alpha/{name=models/*}/trigger-multipart", middleware.AppendCustomHeaderMiddleware(handler.HandleTriggerModelByUpload)); err != nil {
panic(err)
}

Expand Down
2 changes: 1 addition & 1 deletion config/config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ cache:
redis:
redisoptions:
addr: redis:6379
model: true
model: false
usageserver:
tlsenabled: true
host: usage.instill.tech
Expand Down
163 changes: 32 additions & 131 deletions config/init/instill/seed/model_definitions.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -8,41 +8,6 @@
$schema: "http://json-schema.org/draft-07/schema#"
title: "GitHub spec for model"
type: "object"
required:
- "repository"
additionalProperties: false
minProperties: 1
maxProperties: 2
properties:
repository:
type: "string"
title: "GitHub repository"
description: "The name of a public GitHub repository, e.g. `instill-ai/model-yolov7`."
examples:
- "instill-ai/model-yolov7"
- "instill-ai/model-mobilenetv2"
ui_order: 0
ui_component: "text"
minLength: 0
maxLength: 1023
html_url:
type: "string"
title: "Github repository URL"
description: "The URL of the GitHub repository, e.g. `https://github.com/instill-ai/model-yolov7`."
examples:
- "https://github.com/instill-ai/model-yolov7"
- "https://github.com/instill-ai/model-mobilenetv2"
readOnly: true
ui_order: 1
ui_hidden: true
ui_disabled: true
ui_component: "text"
minLength: 0
maxLength: 1023
modelInstanceSpec:
$schema: "http://json-schema.org/draft-07/schema#"
title: "GitHub spec for model instance"
type: "object"
required:
- "repository"
- "tag"
Expand All @@ -57,9 +22,7 @@
examples:
- "instill-ai/model-yolov7"
- "instill-ai/model-mobilenetv2"
readOnly: true
ui_order: 0
ui_disabled: true
ui_component: "text"
minLength: 0
maxLength: 1023
Expand All @@ -75,16 +38,17 @@
ui_disabled: true
ui_component: "text"
minLength: 0
maxLength: 200
maxLength: 200
html_url:
type: "string"
title: "Github repository tag URL"
description: "The tag URL of the GitHub repository, e.g., `https://github.com/instill-ai/model-yolov7/tree/v1.0-cpu`."
title: "Github repository URL"
description: "The URL of the GitHub repository, e.g. `https://github.com/instill-ai/model-yolov7`."
examples:
- "https://github.com/instill-ai/model-yolov7/tree/v1.0-cpu"
- "https://github.com/instill-ai/model-mobilenetv2/tree/v1.0-cpu"
- "https://github.com/instill-ai/model-yolov7"
- "https://github.com/instill-ai/model-mobilenetv2"
readOnly: true
ui_order: 2
ui_hidden: true
ui_disabled: true
ui_component: "text"
minLength: 0
Expand All @@ -103,41 +67,27 @@
- "content"
additionalProperties: false
minProperties: 1
maxProperties: 1
maxProperties: 2
properties:
content:
type: "string"
contentMediaType: "application/zip"
title: "Upload a .zip file"
description: "Create and upload a zip file that contains all the model files from your computer. We recommend you add a README.md file in the root directory to describe the model in details."
ui_order: 1
ui_order: 0
ui_disabled: true
ui_hidden: true
ui_component: "file"
minLength: 0
maxLength: 1023
modelInstanceSpec:
$schema: "http://json-schema.org/draft-07/schema#"
title: "Local spec for model instance"
type: "object"
required:
- "content"
additionalProperties: false
minProperties: 1
maxProperties: 1
properties:
content:
tag:
type: "string"
contentMediaType: "application/zip"
title: "Upload a .zip file"
description: "Create and upload a zip file that contains all the model files from your computer. We recommend you add a README.md file in the root directory to describe the model in details."
readOnly: true
title: "Model tag"
description: "The tag of the model"
ui_order: 1
ui_hidden: true
ui_disabled: true
ui_component: "file"
ui_component: "text"
minLength: 0
maxLength: 1023
maxLength: 200
- id: artivc
uid: "53c5a6de-2a33-4bf0-bef3-4de8cade2a93"
title: ArtiVC
Expand All @@ -148,41 +98,12 @@
$schema: "http://json-schema.org/draft-07/schema#"
title: "ArtiVC spec for model"
type: "object"
required:
- "url"
additionalProperties: false
minProperties: 1
maxProperties: 2
properties:
url:
type: "string"
title: "GCS bucket path"
description: "The bucket path of Google Cloud Storage (GCS), e.g. `gs://mybucket/path/to/mymodel/`."
examples:
- "gs://public-europe-west2-c-artifacts/vdp/public-models/yolov4"
readOnly: true
ui_order: 1
ui_component: "text"
minLength: 0
maxLength: 1023
credential:
type: "object"
title: "Credentials JSON"
description: "If the GCS bucket path is private, please provide the Google Cloud Application Default credential or service account credential in its JSON format to get access to the model. See [ArtiVC Google Cloud Storage setup guide](https://artivc.io/backends/gcs/)."
readOnly: true
ui_order: 2
minProperties: 0
maxProperties: 10
modelInstanceSpec:
$schema: "http://json-schema.org/draft-07/schema#"
title: "ArtiVC spec for model instance"
type: "object"
required:
- "url"
- "tag"
additionalProperties: false
minProperties: 2
maxProperties: 2
maxProperties: 3
properties:
url:
type: "string"
Expand All @@ -207,7 +128,15 @@
ui_disabled: true
ui_component: "text"
minLength: 0
maxLength: 200
maxLength: 200
credential:
type: "object"
title: "Credentials JSON"
description: "If the GCS bucket path is private, please provide the Google Cloud Application Default credential or service account credential in its JSON format to get access to the model. See [ArtiVC Google Cloud Storage setup guide](https://artivc.io/backends/gcs/)."
readOnly: true
ui_order: 2
minProperties: 0
maxProperties: 10
- id: "huggingface"
uid: "5b2e1d10-1fab-462d-9d6a-ba41f4b4d816"
title: "Hugging Face"
Expand Down Expand Up @@ -236,6 +165,14 @@
ui_component: "text"
minLength: 0
maxLength: 1023
tag:
type: "string"
title: "Model tag"
description: "The tag of the model"
ui_order: 1
ui_component: "text"
minLength: 0
maxLength: 200
html_url:
type: "string"
title: "Hugging Face repository URL"
Expand All @@ -251,40 +188,4 @@
ui_component: "text"
minLength: 0
maxLength: 1023
modelInstanceSpec:
$schema: "http://json-schema.org/draft-07/schema#"
title: "Hugging Face spec for model instance"
type: "object"
required:
- "repo_id"
additionalProperties: false
minProperties: 1
maxProperties: 2
properties:
repo_id:
type: "string"
title: "Hugging Face repository"
description: "The name of a public Hugging Face repository, e.g. `google/vit-base-patch16-224`. Currently, we only support importing repositories tagged with `Image Classification`."
examples:
- "google/vit-base-patch16-224"
- "microsoft/resnet-50"
- "facebook/convnext-tiny-224"
ui_order: 0
ui_component: "text"
minLength: 0
maxLength: 1023
html_url:
type: "string"
title: "Hugging Face repository main branch URL"
description: "The main branch URL of the Hugging Face repository, e.g. `https://huggingface.co/google/vit-base-patch16-224/tree/main`."
examples:
- "https://huggingface.co/google/vit-base-patch16-224/tree/main"
- "https://huggingface.co/microsoft/resnet-50/tree/main"
- "https://huggingface.co/facebook/convnext-tiny-224/tree/main"
readOnly: true
ui_order: 1
ui_hidden: true
ui_disabled: true
ui_component: "text"
minLength: 0
maxLength: 1023

31 changes: 31 additions & 0 deletions config/model/model.json
Original file line number Diff line number Diff line change
Expand Up @@ -106,6 +106,37 @@
"ui_disabled": true,
"ui_component": "text"
},
"state": {
"type": "string",
"title": "State",
"description": "The model state",
"enum": [
"STATE_UNSPECIFIED",
"STATE_OFFLINE",
"STATE_ONLINE",
"STATE_ERROR"
],
"default": "STATE_UNSPECIFIED",
"readOnly": true,
"ui_order": 3,
"ui_hidden": true,
"ui_disabled": true,
"ui_component": "select",
"ui_enum": ["", "Offline", "Online", "Error"]
},
"task": {
"type": "string",
"title": "Task",
"description": "The model task",
"enum": ["TASK_UNSPECIFIED", "TASK_CLASSIFICATION", "TASK_DETECTION"],
"default": "TASK_UNSPECIFIED",
"readOnly": true,
"ui_order": 4,
"ui_hidden": true,
"ui_disabled": true,
"ui_component": "select",
"ui_enum": ["", "Image classification", "Object detection"]
},
"create_time": {
"type": "string",
"format": "date-time",
Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
{
"$schema": "https://json-schema.org/draft-07/schema",
"$id": "https://github.com/instill-ai/model-backend/blob/main/config/models/model_instance_card.json",
"$id": "https://github.com/instill-ai/model-backend/blob/main/config/models/model_card.json",
"type": "object",
"title": "Model instance card",
"description": "The model instance README card",
"title": "Model card",
"description": "The model README card",
"additionalProperties": false,
"required": ["type", "content", "encoding"],
"properties": {
Expand Down Expand Up @@ -41,7 +41,7 @@
"content": {
"type": "string",
"title": "README",
"description": "README to describe a model instance",
"description": "README to describe a model",
"readOnly": true,
"ui_order": 3,
"ui_disabled": true,
Expand Down

0 comments on commit 15e1b62

Please sign in to comment.