From e63bf1a553c01a401bca94d847e7737a71bee3f0 Mon Sep 17 00:00:00 2001 From: Nicola Cerutti <94574085+ncerutti@users.noreply.github.com> Date: Mon, 29 Jan 2024 10:37:31 +0000 Subject: [PATCH] Add vulnerability adjustments field to schema (#81) * added vulnerability adjustments field to schema * added vuln set to model_settings, renamed vuln adj fields * added vulnerability options * separated vulnerability_replacements in replace_file and replace_data --- ods_tools/data/analysis_settings_schema.json | 46 +++++++ ods_tools/data/model_settings_schema.json | 126 +++++++++++++++++++ 2 files changed, 172 insertions(+) diff --git a/ods_tools/data/analysis_settings_schema.json b/ods_tools/data/analysis_settings_schema.json index ac0f4cff..5c1eadcf 100644 --- a/ods_tools/data/analysis_settings_schema.json +++ b/ods_tools/data/analysis_settings_schema.json @@ -412,6 +412,52 @@ } } }, + "vulnerability_adjustments": { + "type": "object", + "title": "Vulnerability Adjustments", + "description": "Object containing vulnerability adjustments and replacements.", + "properties": { + "adjustments": { + "type": "object", + "title": "Vulnerability Factor Adjustments", + "description": "Dictionary containing vulnerability adjustments with vulnerability ID as integer keys and adjustment factors as float values.", + "patternProperties": { + "^[0-9]+$": { + "type": "number", + "minimum": 0 + } + }, + "additionalProperties": false + }, + "replace_data": { + "type": "object", + "title": "Vulnerability Replacements", + "description": "Detailed vulnerability replacements.", + "patternProperties": { + "^[0-9]+$": { + "type": "array", + "items": { + "type": "array", + "minItems": 3, + "maxItems": 3, + "items": [ + { "type": "integer" }, + { "type": "integer" }, + { "type": "number", "minimum": 0, "maximum": 1 } + ] + } + } + }, + "additionalProperties": false + }, + "replace_file": { + "type": "string", + "title": "Vulnerability Replacement File", + "description": "Path to a CSV file containing vulnerability data to be replaced." + } + }, + "additionalProperties": false + }, "gul_output": { "type": "boolean", "title": "Produce GUL output", diff --git a/ods_tools/data/model_settings_schema.json b/ods_tools/data/model_settings_schema.json index 673a495d..83e256c1 100644 --- a/ods_tools/data/model_settings_schema.json +++ b/ods_tools/data/model_settings_schema.json @@ -398,6 +398,86 @@ "options" ] }, + "vulnerability_set":{ + "title":"Vulnerability set selector", + "description":"The 'id' field from options is used as a file suffix, e.g. vulnerability_.bin, vulnerability_.csv, vulnerability_.parquet", + "type":"object", + "uniqueItems":false, + "additionalProperties": false, + "properties":{ + "name":{ + "type":"string", + "title":"UI Option", + "description":"UI name for selection", + "minLength":1 + }, + "desc":{ + "type":"string", + "title":"Short description", + "description":"UI description for selection" + }, + "used_for":{ + "type":"string", + "title":"Where the setting is applied", + "description":"Set if this parameter is ONLY used at input 'generation' or for output 'losses'", + "enum":[ + "all", + "generation", + "losses" + ] + }, + "tooltip":{ + "type":"string", + "title":"UI tooltip", + "description":"Long description (optional)" + }, + "default":{ + "type":"string", + "title":"Default footprint set", + "description":"Initial setting for vulnerability set" + }, + "options":{ + "type":"array", + "title":"Selection options for footprint", + "description":"Array of possible vulnerability sets", + "items":{ + "type":"object", + "title":"Selection option element", + "description":"Vulnerability set options", + "additionalProperties":false, + "properties":{ + "id":{ + "type":"string", + "title":"Vulnerability set suffix", + "description":"String value used to select a vulnerability set", + "minLength":1 + }, + "desc":{ + "type":"string", + "title":"Vulnerability set description", + "description":"UI description for selection", + "minLength":1 + }, + "tooltip":{ + "type":"string", + "title":"UI tooltip", + "description":"Long description (optional)" + } + }, + "required":[ + "id", + "desc" + ] + } + } + }, + "required":[ + "name", + "desc", + "default", + "options" + ] + }, "valid_output_perspectives":{ "type":"array", "title":"Globally supported loss perspectives", @@ -458,6 +538,52 @@ ] } }, + "vulnerability_adjustments": { + "type": "object", + "title": "Vulnerability Adjustments", + "description": "Object containing vulnerability adjustments and replacements.", + "properties": { + "adjustments": { + "type": "object", + "title": "Vulnerability Factor Adjustments", + "description": "Dictionary containing vulnerability adjustments with vulnerability ID as integer keys and adjustment factors as float values.", + "patternProperties": { + "^[0-9]+$": { + "type": "number", + "minimum": 0 + } + }, + "additionalProperties": false + }, + "replace_data": { + "type": "object", + "title": "Vulnerability Replacements", + "description": "Detailed vulnerability replacements.", + "patternProperties": { + "^[0-9]+$": { + "type": "array", + "items": { + "type": "array", + "minItems": 3, + "maxItems": 3, + "items": [ + { "type": "integer" }, + { "type": "integer" }, + { "type": "number", "minimum": 0, "maximum": 1 } + ] + } + } + }, + "additionalProperties": false + }, + "replace_file": { + "type": "string", + "title": "Vulnerability Replacement File", + "description": "Path to a CSV file containing vulnerability data to be replaced." + } + }, + "additionalProperties": false + }, "string_parameters":{ "title":"Single string paramters", "type":"array",