Skip to content
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

Accept settings JSON on analysis or model creation #1067

Merged
merged 9 commits into from
Jun 27, 2024

Conversation

sambles
Copy link
Contributor

@sambles sambles commented Jun 21, 2024

Accept settings JSON on analysis or model creation

Models and Analyses V2 endpoints now accept settings json on POST and PATCH calls via an optional 'settings: { .. json ..}' field. These are validated before the new object is created, if valid the settings are loaded into the newly created (or updated) instance.

Example Analysis (POST / PATCH)

{
  "name": "string",
  "portfolio": 1,
  "model": 1,
  "settings": {
    "model_name_id": "PiWind",
    "model_supplier_id": "OasisLMF",
    "gul_threshold": 0,
    "gul_output": true,
    "model_settings": {
        "event_set": "p",
        "event_occurrence_id": "lt"
    },
    "gul_summaries": [
        {"id": 1, "eltcalc": true}
    ],
    "il_output": false,
    "il_summaries": [],
    "ri_output": 'foo',
    "ri_summaries": []
  }
}

Example Model (POST / PATCH)

{
  "supplier_id": "OasisLMF",
  "model_id": "PiWind",
  "version_id": "ver",
  "settings": {  
    "model_settings":{
        "event_set":{
            "name": "Event Set",
            "desc": "Piwind Event Set selection",
            "default": "p",
            "options":[
                {"id":"p", "desc": "Probabilistic", "number_of_events": 1447}
            ]
         },
        "event_occurrence_id":{
            "name": "Occurrence Set",
            "desc": "PiWind Occurrence selection",
            "default": "lt",
            "options":[
                {"id":"lt", "desc": "Long Term"}
            ]
        }
     },
    "lookup_settings":{},
    "model_default_samples" :10
  }
}

@sambles sambles added the Enhancement Small improvement or refinement. label Jun 25, 2024
@sambles sambles self-assigned this Jun 25, 2024
@sambles sambles merged commit 51ade55 into main Jun 27, 2024
27 checks passed
@sambles sambles deleted the 1056/settings-json-on-create branch June 27, 2024 10:40
sambles added a commit that referenced this pull request Jun 27, 2024
* wip

* Only read settings JSON on create / partial update

* POST settings on model creation working

* PATCH model settings working

* Expand analyses with Settings on POST/PATCH

* PEP8

* Fix model list serializer

* Fix missing field

* Fix missing run_mode
@sambles sambles mentioned this pull request Jun 27, 2024
1 task
@awsbuild awsbuild added this to the 2.3.6 milestone Jul 2, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Enhancement Small improvement or refinement. LTS - 2.3 production
Projects
Status: Done
Development

Successfully merging this pull request may close these issues.

Passing analysis/model settings as a(n optional) parameter when creating a new analysis or model
2 participants