Skip to content

add json schema for model config #48

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

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
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
7 changes: 7 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
.PHONY: validate-examples
validate-examples: ## validate examples in the specification markdown files
go test ./schema/example_test.go

.PHONY: test
test:
go test ./...
2 changes: 1 addition & 1 deletion docs/config.md
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,7 @@ The following terms are used in this section:

Here is an example model artifact configuration JSON document:

```json
```json,title=Model%20Config%20JSON&mediatype=application/vnd.cnai.model.config.v1%2Bjson
{
"descriptor": {
"createdAt": "2025-01-01T00:00:00Z",
Expand Down
6 changes: 5 additions & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,8 @@ module github.com/CloudNativeAI/model-spec

go 1.23.1

require github.com/opencontainers/go-digest v1.0.0
require (
github.com/opencontainers/go-digest v1.0.0
github.com/russross/blackfriday v1.6.0
github.com/santhosh-tekuri/jsonschema/v5 v5.3.1
)
4 changes: 4 additions & 0 deletions go.sum
Original file line number Diff line number Diff line change
@@ -1,2 +1,6 @@
github.com/opencontainers/go-digest v1.0.0 h1:apOUWs51W5PlhuyGyz9FCeeBIOUDA/6nW8Oi/yOhh5U=
github.com/opencontainers/go-digest v1.0.0/go.mod h1:0JzlMkj0TRzQZfJkVvzbP0HBR3IKzErnv2BNG4W4MAM=
github.com/russross/blackfriday v1.6.0 h1:KqfZb0pUVN2lYqZUYRddxF4OR8ZMURnJIG5Y3VRLtww=
github.com/russross/blackfriday v1.6.0/go.mod h1:ti0ldHuxg49ri4ksnFxlkCfN+hvslNlmVHqNRXXJNAY=
github.com/santhosh-tekuri/jsonschema/v5 v5.3.1 h1:lZUw3E0/J3roVtGQ+SCrUrg3ON6NgVqpn3+iol9aGu4=
github.com/santhosh-tekuri/jsonschema/v5 v5.3.1/go.mod h1:uToXkOrWAZ6/Oc07xWQrPOhJotwFIyu2bBVN41fcDUY=
117 changes: 117 additions & 0 deletions schema/config-schema.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,117 @@
{
"description": "Model Artifact Configuration Schema",
"$schema": "http://json-schema.org/draft-04/schema#",
"$id": "https://github.com/CloudNativeAI/model-spec/config",
"type": "object",
"properties": {
"descriptor": {
"$ref": "#/$defs/ModelDescriptor"
},
"modelfs": {
"$ref": "#/$defs/ModelFS"
},
"config": {
"$ref": "#/$defs/ModelConfig"
}
},
"additionalProperties": false,
"required": [
"descriptor",
"config",
"modelfs"
],
"$defs": {
"ModelConfig": {
"type": "object",
"properties": {
"architecture": {
"type": "string"
},
"format": {
"type": "string"
},
"paramSize": {
"type": "string"
},
"precision": {
"type": "string"
},
"quantization": {
"type": "string"
}
},
"additionalProperties": false
},
"ModelDescriptor": {
"type": "object",
"properties": {
"createdAt": {
"type": "string",
"format": "date-time"
},
"authors": {
"type": "array",
"items": {
"type": "string"
}
},
"family": {
"type": "string"
},
"name": {
"type": "string",
"minLength": 1
},
"docURL": {
"type": "string"
},
"sourceURL": {
"type": "string"
},
"version": {
"type": "string"
},
"revision": {
"type": "string"
},
"vendor": {
"type": "string"
},
"licenses": {
"type": "array",
"items": {
"type": "string"
}
},
"title": {
"type": "string"
},
"description": {
"type": "string"
}
},
"additionalProperties": false
},
"ModelFS": {
"type": "object",
"properties": {
"type": {
"type": "string",
"enum": ["layers"]
},
"diff_ids": {
"type": "array",
"items": {
"type": "string"
},
"minItems": 1
}
},
"additionalProperties": false,
"required": [
"type",
"diff_ids"
]
}
}
}
Loading