Skip to content

Commit

Permalink
OED Settings merger (#146)
Browse files Browse the repository at this point in the history
* 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 <[email protected]>
Co-authored-by: Sam Gamble <[email protected]>
  • Loading branch information
3 people authored Jan 28, 2025
1 parent a717fae commit 3c429e9
Show file tree
Hide file tree
Showing 12 changed files with 2,284 additions and 1,207 deletions.
18 changes: 18 additions & 0 deletions ods_tools/data/analysis_settings_schema.json
Original file line number Diff line number Diff line change
Expand Up @@ -353,6 +353,24 @@
"title": "User set quantile points",
"description": "List of quantiles as float values '[0.0, 0.2, 0.4 .. etc]'"
},
"computation_settings": {
"type": "object",
"title": "Computation setting options",
"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)",
"patternProperties": {
"^.*$": {
"anyOf": [
{ "type": "integer" },
{ "type": "string" },
{ "type": "boolean" },
{ "type": "object" },
{ "type": "number" },
{ "type": "array" }
]
}
},
"additionalProperties": true
},
"model_settings": {
"type": "object",
"title": "Model settings",
Expand Down
2,509 changes: 1,308 additions & 1,201 deletions ods_tools/data/model_settings_schema.json

Large diffs are not rendered by default.

10 changes: 6 additions & 4 deletions ods_tools/oed/__init__.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
from .exposure import OedExposure
from .oed_schema import OedSchema
from .setting_schema import ModelSettingSchema, AnalysisSettingSchema
from .source import OedSource
from .settings import Settings, SettingHandler, AnalysisSettingHandler, ModelSettingHandler
from .setting_schema import ModelSettingSchema, AnalysisSettingSchema
from .common import (
OdsException, PANDAS_COMPRESSION_MAP, PANDAS_DEFAULT_NULL_VALUES, USUAL_FILE_NAME, OED_TYPE_TO_NAME,
OED_NAME_TO_TYPE, OED_IDENTIFIER_FIELDS, VALIDATOR_ON_ERROR_ACTION, DEFAULT_VALIDATION_CONFIG, OED_PERIL_COLUMNS, fill_empty,
Expand All @@ -10,8 +11,9 @@


__all__ = [
'OedExposure', 'OedSchema', 'OedSource', 'ModelSettingSchema', 'AnalysisSettingSchema',
'OedExposure', 'OedSchema', 'OedSource', 'Settings', 'SettingHandler',
'AnalysisSettingHandler', 'ModelSettingHandler', 'ModelSettingSchema', 'AnalysisSettingSchema',
'OdsException', 'PANDAS_COMPRESSION_MAP', 'PANDAS_DEFAULT_NULL_VALUES', 'USUAL_FILE_NAME', 'OED_TYPE_TO_NAME',
'OED_NAME_TO_TYPE', 'OED_IDENTIFIER_FIELDS', 'VALIDATOR_ON_ERROR_ACTION', 'DEFAULT_VALIDATION_CONFIG', 'OED_PERIL_COLUMNS', 'fill_empty',
'UnknownColumnSaveOption', 'BLANK_VALUES', 'is_empty'
]
'UnknownColumnSaveOption', 'BLANK_VALUES', 'is_empty',
] # this is necessary for flake8 to pass, otherwise you get an unused import error
3 changes: 2 additions & 1 deletion ods_tools/oed/setting_schema.py
Original file line number Diff line number Diff line change
Expand Up @@ -255,7 +255,8 @@ def get(self, settings_fp, key=None, validate=True):
The entire settings data as a dictionary if key is None, otherwise the value for the given key.
"""
settings_data = self.load(settings_fp)
self.validate(settings_data, raise_error=True)
if validate:
self.validate(settings_data, raise_error=True)
return settings_data if not key else settings_data.get(key)


Expand Down
Loading

0 comments on commit 3c429e9

Please sign in to comment.