Oms API PATCH merge workset - openmpp/openmpp.github.io GitHub Wiki

Create new or merge existing model workset metadata, parameter(s) metadata and replace parameter(s) values.

  • Workset is a set of model input parameters (a.k.a. "scenario" input).
  • Workset can be used to run the model.
  • Workset is uniquely identified by name (in model context).
  • Workset must be read-only in order to run the model with this set of input parameters.
  • If user want to edit this set input parameters it must be read-write (not read-only status).

This method merge workset metadata, parameter(s) metadata and parameter(s) values from multipart-form, expected multipart form parts:

  • first workset part with workset metadata and parameters metadata in json
  • optional multiple parts file-csv=parameterName.csv.

First part must have model digest or name and workset name:

  • if no such workset exist in database then new workset created.
  • if workset already exist then merge existing workset metadata with new.
  • if workset name not specified or empty then new workset created with unique name.

Parameter list merged with existing workset parameter list:

  • if parameter exist in workset then parameter metadata merged.
  • if new parameter values supplied then replace parameter values.
  • if parameter not already exist in workset then parameter values must be supplied.

Model can be identified by digest or by model name. It is recommended to use digest because it is uniquely identifies model. It is possible to use model name, which is more human readable than digest, but if there are multiple models with same name in database than result is undefined.

Workset is uniquely identified by name (inside the model). Different models can have worksets with same name, i.e. each model can have workset with name "Default".

This is a beta version and may change in the future.

Method:

PATCH /api/workset-merge

For example:

curl -v -X PATCH -F "[email protected]" http://localhost:4040/api/workset-merge
curl -v -X PATCH -F "[email protected]" -F "parameter-csv=@new_ageSex.csv;filename=ageSex.csv" http://localhost:4040/api/workset-merge

JSON arguments:

It is expected to be same JSON as return of Get Workset Metadata in All Languages method.

For example (test.json file):

{
  "ModelName": "modelOne",
  "ModelDigest": "_201208171604590148_",
  "Name": "modelOne_set2",
  "BaseRunDigest": "",
  "IsCleanBaseRun": true,
  "IsReadonly": false,
  "Txt": [{
      "LangCode": "EN",
      "Descr": "modelOne modified set of parameters",
      "Note": ""
    }, {
      "LangCode": "FR",
      "Descr": "(FR) modelOne modified set of parameters",
      "Note": "(FR) modelOne workset notes"
    }
  ],
  "Param": [{
      "Name": "ageSex",
      "SubCount": 1,
      "Txt": [{
          "LangCode": "EN",
          "Note": "Age by Sex modified values"
        }, {
          "LangCode": "FR",
          "Note": "(FR) Age by Sex modified values"
        }
      ]
    }
  ]
}

Use "IsCleanBaseRun": true and "BaseRunDigest": "" if you want to update base run to empty NULL value. Use only "BaseRunDigest": "" if you do not want to update base run.

Each parameter.csv part expected to be same as return of methods:

For example (new_ageSex.csv file):

sub_id,dim0,dim1,param_value
0,10-20,M,1.1
0,10-20,F,1.2
0,20-30,M,1.3
0,20-30,F,1.4
0,30-40,M,1.5
0,30-40,F,1.6
0,40+,M,1.7
0,40+,F,1.8

JSON response:

{
  "SetId": 142,
  "BaseRunId": 101,
  "ModelId": 1,
  "Name": "auto_name_set_of_parameters_2020_05_01_15_22_54_807",
  "IsReadonly": false,
  "UpdateDateTime": "2020-05-01 15:22:54.809"
}
⚠️ **GitHub.com Fallback** ⚠️