Skip to content

Commit 93689d8

Browse files
authored
Introduce file versioning (#663)
* Introduce file versioning * use schema version * use core for schema * fix import * export schema version as well * write schema version in document * lint * try just exporting `SCHEMA_VERSION` * dont need this * fix import * fix import * try importing everything from schema one dir above * fix artifacts name * export schema version too * fix import * import `SCHEMA_VERSION` properly * update example files for SchemaVersion * update test files for SchemaVersion
1 parent 302890e commit 93689d8

39 files changed

+400
-376
lines changed

.gitignore

-1
Original file line numberDiff line numberDiff line change
@@ -133,7 +133,6 @@ jupytergis/_version.py
133133

134134
python/jupytergis_qgis/jupytergis_qgis/labextension/
135135
python/jupytergis_lab/jupytergis_lab/labextension/
136-
python/jupytergis_lab/jupytergis_lab/notebook/objects/_schema
137136

138137
untitled*
139138

examples/buildings.jGIS

+5-4
Original file line numberDiff line numberDiff line change
@@ -28,17 +28,18 @@
2828
"options": {
2929
"bearing": 0.0,
3030
"extent": [
31-
-10032886.560286574,
32-
4927019.041514878,
33-
-9479479.712813895,
34-
5355147.911055009
31+
-9930595.367295777,
32+
4891676.859666935,
33+
-9581770.905804692,
34+
5390490.092902952
3535
],
3636
"latitude": 41.86704023051257,
3737
"longitude": -87.64128426232207,
3838
"pitch": 0.0,
3939
"projection": "EPSG:3857",
4040
"zoom": 8.089610803710057
4141
},
42+
"schemaVersion": "0.5.0",
4243
"sources": {
4344
"7a7ee6fd-c1e2-4c5d-a4e2-a7974db138a4": {
4445
"name": "Vector Tile Source",

examples/earthquakes.jGIS

+5-4
Original file line numberDiff line numberDiff line change
@@ -42,17 +42,18 @@
4242
"options": {
4343
"bearing": 0.0,
4444
"extent": [
45-
-16929878.446871005,
46-
-1778754.1311867516,
47-
274500.73590279557,
48-
10249522.43212788
45+
-15808389.545988183,
46+
-6461894.596411711,
47+
-846988.1649800241,
48+
14932662.897352839
4949
],
5050
"latitude": 35.52446437432016,
5151
"longitude": -74.80890180273175,
5252
"pitch": 0.0,
5353
"projection": "EPSG:3857",
5454
"zoom": 2.6670105136699993
5555
},
56+
"schemaVersion": "0.5.0",
5657
"sources": {
5758
"348d85fa-3a71-447f-8a64-e283ec47cc7c": {
5859
"name": "Custom GeoJSON Layer Source",

examples/europe_geotiff.jGIS

+5-4
Original file line numberDiff line numberDiff line change
@@ -105,17 +105,18 @@
105105
"options": {
106106
"bearing": 0.0,
107107
"extent": [
108-
-1079073.6667191056,
109-
4817841.003706928,
110-
1954326.597956411,
111-
6938613.6815889515
108+
-881337.6895805153,
109+
3992130.329941387,
110+
1756590.6208178208,
111+
7764324.3553544935
112112
],
113113
"latitude": 46.60741102745533,
114114
"longitude": 3.9312654280044197,
115115
"pitch": 0.0,
116116
"projection": "EPSG:3857",
117117
"zoom": 5.170778564449867
118118
},
119+
"schemaVersion": "0.5.0",
119120
"sources": {
120121
"d14dc4d2-48a4-40a6-b6e1-5e77b81acdeb": {
121122
"name": "Custom GeoTiff Source",

examples/france_hiking.jGIS

+5-4
Original file line numberDiff line numberDiff line change
@@ -36,17 +36,18 @@
3636
"options": {
3737
"bearing": 0.0,
3838
"extent": [
39-
-2264128.4165621577,
40-
3815239.0783040468,
41-
2622187.8055447284,
42-
7946508.949507482
39+
-1684031.829892432,
40+
3216726.7269781423,
41+
2042091.2188750028,
42+
8545021.300833387
4343
],
4444
"latitude": 46.623742146769416,
4545
"longitude": 1.6082511087277014,
4646
"pitch": 0.0,
4747
"projection": "EPSG:3857",
4848
"zoom": 4.672508604627439
4949
},
50+
"schemaVersion": "0.5.0",
5051
"sources": {
5152
"52252f5d-3cb7-45a8-a724-5793bf9950ec": {
5253
"name": "NASAGIBS.ModisTerraTrueColorCR",

examples/geotiff.jGIS

+5-4
Original file line numberDiff line numberDiff line change
@@ -156,17 +156,18 @@
156156
"options": {
157157
"bearing": 0.0,
158158
"extent": [
159-
-13920582.07909406,
160-
-1339375.3727731649,
161-
-9144100.770363271,
162-
11083665.925811738
159+
-14711424.927359793,
160+
326108.24145533424,
161+
-8353257.922097538,
162+
9418182.31158324
163163
],
164164
"latitude": 40.042672545275906,
165165
"longitude": -103.59678563518457,
166166
"pitch": 0.0,
167167
"projection": "EPSG:3857",
168168
"zoom": 3.901573011026123
169169
},
170+
"schemaVersion": "0.5.0",
170171
"sources": {
171172
"8b1d4258-5d46-48da-b466-496d376b593d": {
172173
"name": "Custom GeoTiff Source",

examples/hillshade.jGIS

+5-4
Original file line numberDiff line numberDiff line change
@@ -26,17 +26,18 @@
2626
"options": {
2727
"bearing": 0.0,
2828
"extent": [
29-
1250338.0228556562,
30-
5968537.821214878,
31-
1291765.492754431,
32-
6000587.109973536
29+
1257995.4368141007,
30+
5965892.141673056,
31+
1284108.0787959865,
32+
6003232.789515357
3333
],
3434
"latitude": 47.25967099028631,
3535
"longitude": 11.418052209432549,
3636
"pitch": 59.00000000000003,
3737
"projection": "EPSG:3857",
3838
"zoom": 11.829291680317894
3939
},
40+
"schemaVersion": "0.5.0",
4041
"sources": {
4142
"ceef4036-b757-44bf-8a21-42c6c99dab72": {
4243
"name": "OpenStreetMap.Mapnik",

examples/image.jGIS

+3-2
Original file line numberDiff line numberDiff line change
@@ -26,9 +26,9 @@
2626
"options": {
2727
"bearing": 0.0,
2828
"extent": [
29-
-13957340.607405175,
29+
-10835715.64562285,
3030
-4131544.7694810475,
31-
3839728.534463562,
31+
718103.572681238,
3232
12390226.369708324
3333
],
3434
"latitude": 34.74543821495182,
@@ -37,6 +37,7 @@
3737
"projection": "EPSG:3857",
3838
"zoom": 3.0398860010821136
3939
},
40+
"schemaVersion": "0.5.0",
4041
"sources": {
4142
"5f7a1edf-1b76-4f82-893f-540d28998b1d": {
4243
"name": "OpenStreetMap.Mapnik",

examples/local.jGIS

+5-4
Original file line numberDiff line numberDiff line change
@@ -47,17 +47,18 @@
4747
"options": {
4848
"bearing": 0.0,
4949
"extent": [
50-
-8842748.158893239,
51-
4845264.714813821,
52-
-8050108.901912498,
53-
5581105.2228986155
50+
-8703718.385476297,
51+
4845264.714813822,
52+
-8189138.675329441,
53+
5581105.222898616
5454
],
5555
"latitude": 42.34755800727709,
5656
"longitude": -75.87555845084086,
5757
"pitch": 0.0,
5858
"projection": "EPSG:3857",
5959
"zoom": 7.528717444291546
6060
},
61+
"schemaVersion": "0.5.0",
6162
"sources": {
6263
"0e9d027f-56ea-427e-a845-a5ee33427e67": {
6364
"name": "Custom Shapefile Source",

examples/pmtiles-raster.jGIS

+5-4
Original file line numberDiff line numberDiff line change
@@ -26,17 +26,18 @@
2626
"options": {
2727
"bearing": 0.0,
2828
"extent": [
29-
-7516992.806430088,
30-
-5815326.729792749,
31-
7516992.806430088,
32-
5815326.729792747
29+
-4738125.268435165,
30+
-6775441.075785377,
31+
4738125.268435165,
32+
6775441.075785375
3333
],
3434
"latitude": 0.0,
3535
"longitude": 0.0,
3636
"pitch": 0.0,
3737
"projection": "EPSG:3857",
3838
"zoom": 3.3258675805754185
3939
},
40+
"schemaVersion": "0.5.0",
4041
"sources": {
4142
"d3a5ad67-d6fe-4793-a6c5-dd773d76c745": {
4243
"name": "Custom Raster Layer Source",

examples/pmtiles-vector.jGIS

+5-4
Original file line numberDiff line numberDiff line change
@@ -28,17 +28,18 @@
2828
"options": {
2929
"bearing": 0.0,
3030
"extent": [
31-
18050132.8197512,
32-
-5872240.531289864,
33-
20577212.404809494,
34-
-3917230.883451412
31+
18517235.796013273,
32+
-6033627.233762434,
33+
20110109.42854742,
34+
-3755844.1809788416
3535
],
3636
"latitude": -40.197854210907515,
3737
"longitude": 173.4976730009204,
3838
"pitch": 0.0,
3939
"projection": "EPSG:3857",
4040
"zoom": 5.898552104144127
4141
},
42+
"schemaVersion": "0.5.0",
4243
"sources": {
4344
"c42d25fc-ca10-4447-ba00-ba22b0367739": {
4445
"name": "OpenStreetMap.Mapnik",

examples/roads.jGIS

+5-4
Original file line numberDiff line numberDiff line change
@@ -7470,17 +7470,18 @@
74707470
"options": {
74717471
"bearing": 0.0,
74727472
"extent": [
7473-
-24833314.494285844,
7474-
-20037508.34278924,
7475-
-6971903.929818634,
7476-
20037508.34278924
7473+
-26469740.02358401,
7474+
-15110822.972668167,
7475+
-5335478.400520468,
7476+
15110822.972668167
74777477
],
74787478
"latitude": 0.0,
74797479
"longitude": -142.85556912566426,
74807480
"pitch": 0.0,
74817481
"projection": "EPSG:3857",
74827482
"zoom": 2.1686721181322306
74837483
},
7484+
"schemaVersion": "0.5.0",
74847485
"sources": {
74857486
"b9e30ab1-864e-4395-9071-cddb6ac813e5": {
74867487
"name": "Custom GeoJSON Layer Source",

examples/shapefile.jGIS

+5-4
Original file line numberDiff line numberDiff line change
@@ -37,17 +37,18 @@
3737
"options": {
3838
"bearing": 0.0,
3939
"extent": [
40-
-14315907.349273225,
41-
-10963209.615019688,
42-
17506481.70153469,
43-
17005812.446790293
40+
-8150520.166876536,
41+
-10915042.527657213,
42+
11341094.519137997,
43+
16957645.359427817
4444
],
4545
"latitude": 26.179270968888744,
4646
"longitude": 14.330708528781068,
4747
"pitch": 0.0,
4848
"projection": "EPSG:3857",
4949
"zoom": 2.2854022188622487
5050
},
51+
"schemaVersion": "0.5.0",
5152
"sources": {
5253
"780c4234-ba6d-4da2-9731-739f6c4d8033": {
5354
"name": "OpenStreetMap.Mapnik",

examples/test.jGIS

+5-4
Original file line numberDiff line numberDiff line change
@@ -47,17 +47,18 @@
4747
"options": {
4848
"bearing": 0.0,
4949
"extent": [
50-
-9850513.086672578,
51-
-4934066.080007393,
52-
8261047.328330576,
53-
11000448.184101444
50+
-6347115.289224999,
51+
-4906624.321802844,
52+
4757649.530882997,
53+
10973006.425896894
5454
],
5555
"latitude": 26.275081528154047,
5656
"longitude": -7.139206921516233,
5757
"pitch": 0.0,
5858
"projection": "EPSG:3857",
5959
"zoom": 3.097076987914768
6060
},
61+
"schemaVersion": "0.5.0",
6162
"sources": {
6263
"5fd42e3b-4681-4607-b15d-65c3a3e89b32": {
6364
"name": "Open Topo Map",

examples/world.jGIS

+5-4
Original file line numberDiff line numberDiff line change
@@ -122,17 +122,18 @@
122122
"options": {
123123
"bearing": 0.0,
124124
"extent": [
125-
-19065470.770224877,
126-
-18193969.787702393,
127-
21009545.91535361,
128-
20037508.342789244
125+
-12349723.176694198,
126+
-18128129.12502072,
127+
14293798.321822936,
128+
19971667.68010757
129129
],
130130
"latitude": 8.251719751227498,
131131
"longitude": 8.731962081730105,
132132
"pitch": 0.0,
133133
"projection": "EPSG:3857",
134134
"zoom": 1.834471049984222
135135
},
136+
"schemaVersion": "0.5.0",
136137
"sources": {
137138
"5970d6c9-26be-4cc6-84c9-16593dd3edfe": {
138139
"name": "France",

packages/schema/package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@
2828
"build": "jlpm build:schema && jlpm build:lib",
2929
"build:schema": "node ./cacheGeoJSONSchema.js && jlpm build:schema:js && jlpm build:schema:py",
3030
"build:schema:js": "json2ts -i src/schema -o src/_interface --no-unknownAny --unreachableDefinitions --cwd ./src/schema && cd src/schema && node ../../schema.js",
31-
"build:schema:py": "datamodel-codegen --input ./src/schema --output ../../python/jupytergis_lab/jupytergis_lab/notebook/objects/_schema --output-model-type pydantic_v2.BaseModel --input-file-type jsonschema",
31+
"build:schema:py": "datamodel-codegen --input ./src/schema --output ../../python/jupytergis_core/jupytergis_core/schema/interfaces --output-model-type pydantic_v2.BaseModel --input-file-type jsonschema",
3232
"build:prod": "jlpm run clean && jlpm build:schema && jlpm run build:lib",
3333
"build:lib": "tsc -b",
3434
"build:dev": "jlpm run build",

packages/schema/schema.js

+5
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,11 @@ const $RefParser = require("@apidevtools/json-schema-ref-parser");
44
const schemaPath = path.join(__dirname, "src/schema");
55
const allSchema = {};
66

7+
// Add: extract version and write version files
8+
const version = JSON.parse(fs.readFileSync(path.join(schemaPath, "project/jgis.json"))).properties.schemaVersion.default;
9+
fs.writeFileSync(path.join(__dirname, "src/_interface/version.d.ts"), `export declare const SCHEMA_VERSION = '${version}';\n`);
10+
fs.writeFileSync(path.join(__dirname, "src/_interface/version.js"), `export const SCHEMA_VERSION = '${version}';\n`);
11+
712
function getSchemaFiles(dir) {
813
let results = [];
914
const list = fs.readdirSync(dir);

packages/schema/src/doc.ts

+2-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
import { Delta, MapChange, YDocument } from '@jupyter/ydoc';
22
import { JSONExt, JSONObject } from '@lumino/coreutils';
33
import { ISignal, Signal } from '@lumino/signaling';
4+
import { SCHEMA_VERSION } from './_interface/version';
45
import * as Y from 'yjs';
56

67
import {
@@ -97,7 +98,7 @@ export class JupyterGISDoc
9798
}
9899

99100
get version(): string {
100-
return '0.1.0';
101+
return SCHEMA_VERSION;
101102
}
102103

103104
get layers(): IJGISLayers {

packages/schema/src/index.ts

+1
Original file line numberDiff line numberDiff line change
@@ -2,3 +2,4 @@ export * from './interfaces';
22
export * from './model';
33
export * from './token';
44
export * from './doc';
5+
export { SCHEMA_VERSION } from './_interface/version';

packages/schema/src/schema/project/jgis.json

+4
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,10 @@
44
"required": ["layers", "sources"],
55
"additionalProperties": false,
66
"properties": {
7+
"schemaVersion": {
8+
"type": "string",
9+
"default": "0.5.0"
10+
},
711
"layers": {
812
"$ref": "#/definitions/jGISLayers"
913
},

packages/schema/src/types.ts

+1
Original file line numberDiff line numberDiff line change
@@ -32,3 +32,4 @@ export * from './doc';
3232
export * from './interfaces';
3333
export * from './model';
3434
export * from './token';
35+
export * from './index';

python/jupytergis_core/.gitignore

+1
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,3 @@
11
jupytergis_core/labextension
22
jupytergis_core/_version.py
3+
jupytergis_core/schema/interfaces

0 commit comments

Comments
 (0)