Skip to content

Commit 12a8b41

Browse files
authored
Merge pull request #926 from rasmi/fix-schemas
Update schemas manually instead of via GH Actions.
2 parents f5628d5 + a9ddd20 commit 12a8b41

File tree

8 files changed

+176
-194
lines changed

8 files changed

+176
-194
lines changed

.github/workflows/ci.yaml

Lines changed: 0 additions & 74 deletions
Original file line numberDiff line numberDiff line change
@@ -77,77 +77,3 @@ jobs:
7777
- name: Test frontend
7878
working-directory: ./frontend
7979
run: npm test
80-
81-
update-schemas:
82-
name: Update generated schemas
83-
84-
runs-on: ubuntu-latest
85-
86-
# Only run on push to main/master, not on PRs
87-
if: github.event_name == 'push' && (github.ref == 'refs/heads/main' || github.ref == 'refs/heads/master')
88-
89-
permissions:
90-
contents: write
91-
pull-requests: write
92-
93-
steps:
94-
- uses: actions/checkout@v4
95-
with:
96-
token: ${{ secrets.GITHUB_TOKEN }}
97-
98-
- name: Use Node.js 22.x
99-
uses: actions/setup-node@v4
100-
with:
101-
node-version: 22.x
102-
103-
- name: Set up Python
104-
uses: actions/setup-python@v5
105-
with:
106-
python-version: '3.12'
107-
108-
- name: Install uv
109-
uses: astral-sh/setup-uv@v4
110-
111-
- name: Install dependencies
112-
run: |
113-
npm install
114-
cd scripts && uv sync
115-
116-
- name: Build utils
117-
working-directory: ./utils
118-
run: npm run build
119-
120-
- name: Regenerate schemas
121-
run: |
122-
cd utils && npx tsx src/export-schemas.ts
123-
npx prettier --write ../docs/assets/api/schemas.json
124-
cd ../scripts && uv run datamodel-codegen \
125-
--input ../docs/assets/api/schemas.json \
126-
--output deliberate_lab/types.py \
127-
--input-file-type jsonschema \
128-
--reuse-model \
129-
--collapse-root-models \
130-
--use-union-operator \
131-
--use-title-as-name \
132-
--output-model-type pydantic_v2.BaseModel \
133-
--custom-file-header $'# pyright: reportInvalidTypeForm=false\n# pylint: disable=missing-module-docstring,missing-class-docstring,invalid-name,too-few-public-methods'
134-
135-
- name: Format Python files
136-
run: |
137-
cd scripts && uvx black deliberate_lab/
138-
139-
- name: Validate generated Python
140-
run: |
141-
cd scripts && uv run pyright deliberate_lab/
142-
143-
- name: Create PR if schemas changed
144-
uses: peter-evans/create-pull-request@v8
145-
with:
146-
token: ${{ secrets.GITHUB_TOKEN }}
147-
commit-message: "chore: update generated schemas and Python types"
148-
title: "chore: update generated schemas and Python types"
149-
body: "🤖 Auto-generated by GitHub Actions"
150-
branch: auto-update-schemas
151-
add-paths: |
152-
docs/assets/api/schemas.json
153-
scripts/deliberate_lab/

docs/assets/api/schemas.json

Lines changed: 49 additions & 67 deletions
Original file line numberDiff line numberDiff line change
@@ -341,6 +341,9 @@
341341
"items": {
342342
"type": "string"
343343
}
344+
},
345+
"youtubeVideoId": {
346+
"type": "string"
344347
}
345348
},
346349
"required": [
@@ -1005,28 +1008,9 @@
10051008
"type": "string"
10061009
},
10071010
"type": {
1008-
"allOf": [
1009-
{
1010-
"anyOf": [
1011-
{
1012-
"const": "static",
1013-
"type": "string"
1014-
},
1015-
{
1016-
"const": "random_permutation",
1017-
"type": "string"
1018-
},
1019-
{
1020-
"const": "balanced_assignment",
1021-
"type": "string"
1022-
}
1023-
]
1024-
},
1025-
{
1026-
"const": "static",
1027-
"type": "string"
1028-
}
1029-
]
1011+
"default": "static",
1012+
"const": "static",
1013+
"type": "string"
10301014
},
10311015
"scope": {
10321016
"anyOf": [
@@ -1255,28 +1239,9 @@
12551239
"type": "string"
12561240
},
12571241
"type": {
1258-
"allOf": [
1259-
{
1260-
"anyOf": [
1261-
{
1262-
"const": "static",
1263-
"type": "string"
1264-
},
1265-
{
1266-
"const": "random_permutation",
1267-
"type": "string"
1268-
},
1269-
{
1270-
"const": "balanced_assignment",
1271-
"type": "string"
1272-
}
1273-
]
1274-
},
1275-
{
1276-
"const": "random_permutation",
1277-
"type": "string"
1278-
}
1279-
]
1242+
"default": "random_permutation",
1243+
"const": "random_permutation",
1244+
"type": "string"
12801245
},
12811246
"scope": {
12821247
"anyOf": [
@@ -1363,28 +1328,9 @@
13631328
"type": "string"
13641329
},
13651330
"type": {
1366-
"allOf": [
1367-
{
1368-
"anyOf": [
1369-
{
1370-
"const": "static",
1371-
"type": "string"
1372-
},
1373-
{
1374-
"const": "random_permutation",
1375-
"type": "string"
1376-
},
1377-
{
1378-
"const": "balanced_assignment",
1379-
"type": "string"
1380-
}
1381-
]
1382-
},
1383-
{
1384-
"const": "balanced_assignment",
1385-
"type": "string"
1386-
}
1387-
]
1331+
"default": "balanced_assignment",
1332+
"const": "balanced_assignment",
1333+
"type": "string"
13881334
},
13891335
"scope": {
13901336
"anyOf": [
@@ -1894,9 +1840,45 @@
18941840
},
18951841
"progress": {
18961842
"$ref": "#/$defs/StageProgressConfig"
1843+
},
1844+
"timeLimitInMinutes": {
1845+
"anyOf": [
1846+
{
1847+
"type": "number"
1848+
},
1849+
{
1850+
"type": "null"
1851+
}
1852+
]
1853+
},
1854+
"requireFullTime": {
1855+
"type": "boolean"
1856+
},
1857+
"isTurnBasedChat": {
1858+
"type": "boolean"
1859+
},
1860+
"minNumberOfTurns": {
1861+
"type": "number"
1862+
},
1863+
"maxNumberOfTurns": {
1864+
"anyOf": [
1865+
{
1866+
"type": "number"
1867+
},
1868+
{
1869+
"type": "null"
1870+
}
1871+
]
18971872
}
18981873
},
1899-
"required": ["id", "kind", "name", "descriptions", "progress"],
1874+
"required": [
1875+
"id",
1876+
"kind",
1877+
"name",
1878+
"descriptions",
1879+
"progress",
1880+
"timeLimitInMinutes"
1881+
],
19001882
"title": "PrivateChatStageConfig"
19011883
},
19021884
"ProfileStageConfig": {

package.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,8 @@
2525
]
2626
},
2727
"scripts": {
28-
"prepare": "husky"
28+
"prepare": "husky",
29+
"update-schemas": "npm run build --workspace=utils && npx tsx utils/src/export-schemas.ts && npx prettier --write docs/assets/api/schemas.json && cd scripts && uv run datamodel-codegen --input ../docs/assets/api/schemas.json --output deliberate_lab/types.py --input-file-type jsonschema --reuse-model --collapse-root-models --use-union-operator --use-title-as-name --use-one-literal-as-default --output-model-type pydantic_v2.BaseModel --custom-file-header '# pyright: reportInvalidTypeForm=false\n# pylint: disable=missing-module-docstring,missing-class-docstring,invalid-name,too-few-public-methods' && uv run black deliberate_lab/ && uv run pyright deliberate_lab/"
2930
},
3031
"workspaces": [
3132
"frontend",

0 commit comments

Comments
 (0)