Skip to content
This repository was archived by the owner on Sep 9, 2025. It is now read-only.

Commit 77a1f5e

Browse files
authored
schema: Move schema files into a versioned folder (#636)
To prepare for future updates to the schema, we use a versioned folder. Then downstream users, such as cli, can use the schema file from the versioned folder(s) which the user understands. This will also allow users to support and validate documents from older schema versions. We also add the version property to the schema. This is supported by cli from instructlab/instructlab#417. The version property is not required for version 1. --------- Signed-off-by: BJ Hargrave <hargrave@us.ibm.com>
1 parent f42b9a5 commit 77a1f5e

File tree

5 files changed

+25
-8
lines changed

5 files changed

+25
-8
lines changed

.github/schemas/compositional_skills.json renamed to .github/schemas/v1/compositional_skills.json

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,12 +2,13 @@
22
"title": "Compositional Skill",
33
"description": "A compositional skill.",
44
"type": "object",
5+
"$ref": "./version.json",
56
"required": [
67
"created_by",
78
"task_description",
89
"seed_examples"
910
],
10-
"additionalProperties": false,
11+
"unevaluatedProperties": false,
1112
"properties": {
1213
"created_by": {
1314
"description": "The GitHub username of the contributor.",
@@ -30,7 +31,7 @@
3031
"question",
3132
"answer"
3233
],
33-
"additionalProperties": false,
34+
"unevaluatedProperties": false,
3435
"properties": {
3536
"context": {
3637
"description": "Information that the model is expected to take into account during processing. This is different from knowledge, where the model is expected to gain facts and background knowledge from the tuning process.",

.github/schemas/knowledge.json renamed to .github/schemas/v1/knowledge.json

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,13 +2,14 @@
22
"title": "Knowledge",
33
"description": "A knowledge skill.",
44
"type": "object",
5+
"$ref": "./version.json",
56
"required": [
67
"created_by",
78
"domain",
89
"task_description",
910
"seed_examples"
1011
],
11-
"additionalProperties": false,
12+
"unevaluatedProperties": false,
1213
"properties": {
1314
"created_by": {
1415
"description": "The GitHub username of the contributor.",
@@ -36,7 +37,7 @@
3637
"question",
3738
"answer"
3839
],
39-
"additionalProperties": false,
40+
"unevaluatedProperties": false,
4041
"properties": {
4142
"question": {
4243
"description": "A question used for synthetic data generation.",

.github/schemas/metadata.json renamed to .github/schemas/v1/metadata.json

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,11 @@
22
"title": "Taxonomy metadata",
33
"description": "Accompanying metadata for a peer taxonomy file.",
44
"type": "object",
5+
"$ref": "./version.json",
56
"required": [
67
"seed_examples"
78
],
8-
"additionalProperties": false,
9+
"unevaluatedProperties": false,
910
"properties": {
1011
"seed_examples": {
1112
"description": "An array of metadata for the seed examples in the peer taxonomy file.",
@@ -17,7 +18,7 @@
1718
"source",
1819
"license"
1920
],
20-
"additionalProperties": false,
21+
"unevaluatedProperties": false,
2122
"properties": {
2223
"source": {
2324
"title": "Attribution Source",

.github/schemas/v1/version.json

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
{
2+
"title": "Taxonomy Document Schema Version",
3+
"type": "object",
4+
"$comment": "After version 1, the 'version' property must become required.",
5+
"properties": {
6+
"version": {
7+
"description": "The schema version of the taxonomy document.",
8+
"type": "integer",
9+
"$comment": "This value must match the number in the containing folder.",
10+
"const": 1
11+
}
12+
}
13+
}

.github/scripts/check-yaml.sh

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,15 +18,16 @@ if [ $# -lt 1 ]; then
1818
exit 1
1919
fi
2020

21-
SCHEMAS="$(dirname ${BASH_SOURCE[0]})/../schemas"
21+
SCHEMA_VERSION=1
22+
SCHEMAS="$(dirname ${BASH_SOURCE[0]})/../schemas/v${SCHEMA_VERSION}"
2223
CHANGED_FILES="$@"
2324
ERR=0
2425
error() { printf "ERROR: %s: %s \"%s\"\n" "$1" "$2" "$3" 1>&2; ERR=1; }
2526
warn() { printf "WARN: %s: %s \"%s\"\n" "$1" "$2" "$3" 1>&2; }
2627
for file in ${CHANGED_FILES}; do
2728
case $file in
2829
compositional_skills/*/qna.yaml)
29-
eval "$(check-jsonschema --schemafile $SCHEMAS/compositional_skills.json -o JSON $file | jq -r '.errors[] | (.path | ltrimstr("$")) as $path | "\($path)|line" as $yqline | @sh "$(yq \($yqline) \(.filename))" as $yqcmd | @sh "\(.message[-200:])" as $message | "error \"\(.filename):\($yqcmd):1\" \"\($path)\" \($message)"')"
30+
eval "$(check-jsonschema --schemafile $SCHEMAS/compositional_skills.json -o JSON $file | jq -r '.errors[] | (.path | ltrimstr("$") | select(. != "") // ".") as $path | "\($path)|line" as $yqline | @sh "$(yq \($yqline) \(.filename))" as $yqcmd | @sh "\(.message[-200:])" as $message | "error \"\(.filename):\($yqcmd):1\" \"\($path)\" \($message)"')"
3031
;;
3132
knowledge/*)
3233
error "$file:1:1" "." "We do not accept knowledge PRs at this time"

0 commit comments

Comments
 (0)