-
Notifications
You must be signed in to change notification settings - Fork 1
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
Add JSON schema for top-level config file + use for validation #489
Changes from all commits
b2d3e74
072c5f1
7b8fc9f
c09ccee
dde3892
89b8833
714f6e1
64f5249
f2e849a
4fb3a96
ca5d13d
2f23fa7
2c6e30a
c1dcf33
341d3b4
ee63655
434b170
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
{ | ||
"$schema": "https://json-schema.org/draft/2020-12/schema", | ||
"$id": "https://raw.githubusercontent.com/imperialCHEPI/healthgps/main/schemas/v1/age_range.json", | ||
"type": "array", | ||
"prefixItems": [ | ||
{ | ||
"type": "integer", | ||
"minimum": 0 | ||
}, | ||
{ | ||
"type": "integer", | ||
"minimum": 0 | ||
} | ||
], | ||
"minItems": 2, | ||
"items": false | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
{ | ||
"$schema": "https://json-schema.org/draft/2020-12/schema", | ||
"$id": "https://raw.githubusercontent.com/imperialCHEPI/healthgps/main/schemas/v1/config.json", | ||
"type": "object", | ||
"properties": { | ||
"$schema": { | ||
"type": "string" | ||
}, | ||
"version": { | ||
"const": 2 | ||
}, | ||
"data": { | ||
"$ref": "config/data.json" | ||
}, | ||
"inputs": { | ||
"$ref": "config/inputs.json" | ||
}, | ||
"modelling": { | ||
"$ref": "config/modelling.json" | ||
}, | ||
"running": { | ||
"$ref": "config/running.json" | ||
}, | ||
"output": { | ||
"$ref": "config/output.json" | ||
} | ||
}, | ||
"required": [ | ||
"inputs", | ||
"modelling", | ||
"running", | ||
"output" | ||
], | ||
"additionalProperties": false | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
{ | ||
"$schema": "https://json-schema.org/draft/2020-12/schema", | ||
"$id": "https://raw.githubusercontent.com/imperialCHEPI/healthgps/main/schemas/v1/config/data.json", | ||
"type": "object", | ||
"properties": { | ||
"source": { | ||
"type": "string" | ||
}, | ||
"checksum": { | ||
"type": "string" | ||
} | ||
}, | ||
"required": [ | ||
"source" | ||
], | ||
"additionalProperties": false | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,70 @@ | ||
{ | ||
"$schema": "https://json-schema.org/draft/2020-12/schema", | ||
"$id": "https://raw.githubusercontent.com/imperialCHEPI/healthgps/main/schemas/v1/config/inputs.json", | ||
"type": "object", | ||
"properties": { | ||
"dataset": { | ||
"type": "object", | ||
"properties": { | ||
"name": { | ||
"type": "string" | ||
}, | ||
"format": { | ||
"const": "csv" | ||
}, | ||
"delimiter": { | ||
"type": "string" | ||
}, | ||
"encoding": { | ||
"type": "string" | ||
}, | ||
"columns": { | ||
"type": "object", | ||
"additionalProperties": { | ||
"anyOf": [ | ||
{ | ||
"const": "integer" | ||
}, | ||
{ | ||
"const": "double" | ||
} | ||
] | ||
} | ||
} | ||
}, | ||
"required": [ | ||
"name", | ||
"format", | ||
"delimiter", | ||
"encoding", | ||
"columns" | ||
], | ||
"additionalProperties": false | ||
}, | ||
"settings": { | ||
"type": "object", | ||
"properties": { | ||
"country_code": { | ||
"type": "string" | ||
}, | ||
"size_fraction": { | ||
"type": "number" | ||
}, | ||
"age_range": { | ||
"$ref": "../age_range.json" | ||
} | ||
}, | ||
"required": [ | ||
"country_code", | ||
"size_fraction", | ||
"age_range" | ||
], | ||
"additionalProperties": false | ||
} | ||
}, | ||
"required": [ | ||
"dataset", | ||
"settings" | ||
], | ||
"additionalProperties": false | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,104 @@ | ||
{ | ||
"$schema": "https://json-schema.org/draft/2020-12/schema", | ||
"$id": "https://raw.githubusercontent.com/imperialCHEPI/healthgps/main/schemas/v1/config/interventions.json", | ||
"type": "object", | ||
"properties": { | ||
"active_type_id": { | ||
"anyOf": [ | ||
{ | ||
"type": "string" | ||
}, | ||
{ | ||
"type": "null" | ||
} | ||
] | ||
}, | ||
"types": { | ||
"type": "object", | ||
"additionalProperties": { | ||
"type": "object", | ||
"properties": { | ||
"active_period": { | ||
"type": "object", | ||
"properties": { | ||
"start_time": { | ||
"type": "integer" | ||
}, | ||
"finish_time": { | ||
"anyOf": [ | ||
{ | ||
"type": "integer" | ||
}, | ||
{ | ||
"type": "null" | ||
} | ||
] | ||
} | ||
}, | ||
"required": [ | ||
"start_time", | ||
"finish_time" | ||
], | ||
"additionalProperties": false | ||
}, | ||
"impacts": { | ||
"type": "array" | ||
}, | ||
"impact_type": { | ||
"type": "string" | ||
}, | ||
"dynamics": { | ||
"type": "array", | ||
"items": { | ||
"type": "number" | ||
} | ||
}, | ||
"coefficients": { | ||
"type": "array", | ||
"items": { | ||
"type": "number" | ||
} | ||
}, | ||
"coverage_rates": { | ||
"type": "array", | ||
"items": { | ||
"type": "number" | ||
} | ||
}, | ||
"coverage_cutoff_time": { | ||
"type": "integer", | ||
"minimum": 0 | ||
}, | ||
"child_cutoff_age": { | ||
"type": "integer", | ||
"minimum": 0 | ||
}, | ||
"adjustments": { | ||
"type": "array", | ||
"items": { | ||
"type": "object", | ||
"properties": { | ||
"risk_factor": { | ||
"type": "string" | ||
}, | ||
"value": { | ||
"type": "number" | ||
} | ||
} | ||
} | ||
} | ||
}, | ||
"required": [ | ||
"active_period", | ||
"impacts" | ||
], | ||
"additionalProperties": false | ||
} | ||
} | ||
}, | ||
"required": [ | ||
"active_type_id", | ||
"types" | ||
], | ||
"additionalProperties": false | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,112 @@ | ||
{ | ||
"$schema": "https://json-schema.org/draft/2020-12/schema", | ||
"$id": "https://raw.githubusercontent.com/imperialCHEPI/healthgps/main/schemas/v1/config/modelling.json", | ||
"type": "object", | ||
"properties": { | ||
"ses_model": { | ||
"type": "object", | ||
"properties": { | ||
"function_name": { | ||
"type": "string" | ||
}, | ||
"function_parameters": { | ||
"type": "array", | ||
"items": { | ||
"type": "number" | ||
} | ||
Comment on lines
+12
to
+16
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Just checking this array doesn't require a minimum number of values? Same applies for other arrays in this schema I guess. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I'm not sure... @jamesturner246? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think these depend on the SES model -- e.g. normal has mean, std. Maybe there are other models that have none? Never uses the SES module. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Hmm... ok. I'll leave as is for now. We can always add extra constraints in future if needed. |
||
} | ||
}, | ||
"required": [ | ||
"function_name", | ||
"function_parameters" | ||
], | ||
"additionalProperties": false | ||
}, | ||
"risk_factors": { | ||
"type": "array", | ||
"items": { | ||
"type": "object", | ||
"properties": { | ||
"name": { | ||
"type": "string" | ||
}, | ||
"level": { | ||
"type": "integer" | ||
}, | ||
"range": { | ||
"type": "array", | ||
"items": { | ||
"type": "number" | ||
} | ||
} | ||
}, | ||
"required": [ | ||
"name", | ||
"level", | ||
"range" | ||
], | ||
"additionalProperties": false | ||
} | ||
}, | ||
"risk_factor_models": { | ||
"type": "object", | ||
"properties": { | ||
"static": { | ||
"type": "string" | ||
}, | ||
"dynamic": { | ||
"type": "string" | ||
} | ||
}, | ||
"required": [ | ||
"static", | ||
"dynamic" | ||
], | ||
"additionalProperties": false | ||
}, | ||
"baseline_adjustments": { | ||
"type": "object", | ||
"properties": { | ||
"format": { | ||
"const": "csv" | ||
}, | ||
"delimiter": { | ||
"type": "string" | ||
}, | ||
"encoding": { | ||
"type": "string" | ||
}, | ||
"file_names": { | ||
"type": "object", | ||
"properties": { | ||
"factorsmean_male": { | ||
"type": "string" | ||
}, | ||
"factorsmean_female": { | ||
"type": "string" | ||
} | ||
}, | ||
"required": [ | ||
"factorsmean_male", | ||
"factorsmean_female" | ||
], | ||
"additionalProperties": false | ||
} | ||
}, | ||
"required": [ | ||
"format", | ||
"delimiter", | ||
"encoding", | ||
"file_names" | ||
], | ||
"additionalProperties": false | ||
} | ||
}, | ||
"required": [ | ||
"ses_model", | ||
"risk_factors", | ||
"risk_factor_models", | ||
"baseline_adjustments" | ||
], | ||
"additionalProperties": false | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
{ | ||
"$schema": "https://json-schema.org/draft/2020-12/schema", | ||
"$id": "https://raw.githubusercontent.com/imperialCHEPI/healthgps/main/schemas/v1/config.json", | ||
"type": "object", | ||
"properties": { | ||
"comorbidities": { | ||
"type": "integer" | ||
}, | ||
"folder": { | ||
"type": "string" | ||
}, | ||
"file_name": { | ||
"type": "string" | ||
} | ||
}, | ||
"required": [ | ||
"comorbidities", | ||
"folder", | ||
"file_name" | ||
], | ||
"additionalProperties": false | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do any of the string types here require a
minLength
to ensure they are not empty?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That's a good idea. I don't know whether I can be bothered to put
minLength
s all over the place though, but maybe I'm just being lazy 😆.What do you think @jamesturner246? How pedantic do we want to be?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I won't push you -- one would hope users know not to put empty string fields... Certainly won't hurt though.