Skip to content

Commit 3c429e9

Browse files
sstruziksambles
andauthored
OED Settings merger (#146)
* add Settings class * remote backup * add settings handler * retro compatible schema setting * pep8 * pep8 comment * pep8 * fix backport interface * revert * add test, fix schema * pep8 * fix if computation_settings_json is None * branches renamed in OED repo (#172) * fixup test * Add computaion settings to analyses settings schema --------- Co-authored-by: sambles <sambles@users.noreply.github.com> Co-authored-by: Sam Gamble <hexadessa@gmail.com>
1 parent a717fae commit 3c429e9

12 files changed

+2284
-1207
lines changed

ods_tools/data/analysis_settings_schema.json

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -353,6 +353,24 @@
353353
"title": "User set quantile points",
354354
"description": "List of quantiles as float values '[0.0, 0.2, 0.4 .. etc]'"
355355
},
356+
"computation_settings": {
357+
"type": "object",
358+
"title": "Computation setting options",
359+
"description": "List of oasislmf package settings, options are dependent on the package version. To see these look at releases 2.4.0 and up (https://github.com/OasisLMF/OasisLMF/releases)",
360+
"patternProperties": {
361+
"^.*$": {
362+
"anyOf": [
363+
{ "type": "integer" },
364+
{ "type": "string" },
365+
{ "type": "boolean" },
366+
{ "type": "object" },
367+
{ "type": "number" },
368+
{ "type": "array" }
369+
]
370+
}
371+
},
372+
"additionalProperties": true
373+
},
356374
"model_settings": {
357375
"type": "object",
358376
"title": "Model settings",

ods_tools/data/model_settings_schema.json

Lines changed: 1308 additions & 1201 deletions
Large diffs are not rendered by default.

ods_tools/oed/__init__.py

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,8 @@
11
from .exposure import OedExposure
22
from .oed_schema import OedSchema
3-
from .setting_schema import ModelSettingSchema, AnalysisSettingSchema
43
from .source import OedSource
4+
from .settings import Settings, SettingHandler, AnalysisSettingHandler, ModelSettingHandler
5+
from .setting_schema import ModelSettingSchema, AnalysisSettingSchema
56
from .common import (
67
OdsException, PANDAS_COMPRESSION_MAP, PANDAS_DEFAULT_NULL_VALUES, USUAL_FILE_NAME, OED_TYPE_TO_NAME,
78
OED_NAME_TO_TYPE, OED_IDENTIFIER_FIELDS, VALIDATOR_ON_ERROR_ACTION, DEFAULT_VALIDATION_CONFIG, OED_PERIL_COLUMNS, fill_empty,
@@ -10,8 +11,9 @@
1011

1112

1213
__all__ = [
13-
'OedExposure', 'OedSchema', 'OedSource', 'ModelSettingSchema', 'AnalysisSettingSchema',
14+
'OedExposure', 'OedSchema', 'OedSource', 'Settings', 'SettingHandler',
15+
'AnalysisSettingHandler', 'ModelSettingHandler', 'ModelSettingSchema', 'AnalysisSettingSchema',
1416
'OdsException', 'PANDAS_COMPRESSION_MAP', 'PANDAS_DEFAULT_NULL_VALUES', 'USUAL_FILE_NAME', 'OED_TYPE_TO_NAME',
1517
'OED_NAME_TO_TYPE', 'OED_IDENTIFIER_FIELDS', 'VALIDATOR_ON_ERROR_ACTION', 'DEFAULT_VALIDATION_CONFIG', 'OED_PERIL_COLUMNS', 'fill_empty',
16-
'UnknownColumnSaveOption', 'BLANK_VALUES', 'is_empty'
17-
]
18+
'UnknownColumnSaveOption', 'BLANK_VALUES', 'is_empty',
19+
] # this is necessary for flake8 to pass, otherwise you get an unused import error

ods_tools/oed/setting_schema.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -255,7 +255,8 @@ def get(self, settings_fp, key=None, validate=True):
255255
The entire settings data as a dictionary if key is None, otherwise the value for the given key.
256256
"""
257257
settings_data = self.load(settings_fp)
258-
self.validate(settings_data, raise_error=True)
258+
if validate:
259+
self.validate(settings_data, raise_error=True)
259260
return settings_data if not key else settings_data.get(key)
260261

261262

0 commit comments

Comments
 (0)