Skip to content

Oms API PUT create new workset

amc1999 edited this page Sep 29, 2021 · 3 revisions

Create new model workset and append new 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 creates new workset by inserting workset metadata, parameter(s) metadata and parameter(s) values from json request body. Workset metadata must contain model digest (or model name) and workset name, any other parts of metadata is optional.

Workset parameters are optional, you can create empty workset and add parameters later. Each parameter must have metadata and parameter value(s). Parameter metadata must contain parameter name and if cell values supplied then also number of sub-values (use 1 as default), all other metadata are optional. For each parameter values must be supplied. Workset cannot contain parameter metadata only, it must have all parameter values. See below for information about parameter values.

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".

If workset with the same name already exist then method return an error.

If workset name not specified or empty then new workset created with unique name.

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

Method:

PUT /api/workset-create

For example:

curl -v -X PUT -H "Content-Type: application/json" "http://localhost:4040/api/workset-create" -d @test.json

JSON body:

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

Parameter values must be one of:

  • JSON cell values, identical to output of read parameter "page": Read parameter values from workset
  • copy of parameter values from model run, use: { "Kind": "run", "From": "run digest or run name or run stamp" }
  • copy of parameter values from other workset, use: { "Kind": "set", "From": "workset name" } Source workset must be readonly.

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"
}

Example 1:

{
  "ModelName": "modelOne",
  "Name": "NewSet",
  "Txt": [
    {
      "LangCode": "EN",
      "Descr": "New Set of model One parameters"
    }
  ]
}

Example 2:

{
  "ModelName": "modelOne",
  "ModelDigest": "_201208171604590148_",
  "Name": "NewSet",
  "BaseRunDigest": "",
  "IsReadonly": false,
  "Txt": [
    {
      "LangCode": "EN",
      "Descr": "New Set of model One parameters"
    },
    {
      "LangCode": "FR",
      "Descr": "(FR) New Set of model One parameters",
      "Note": "(FR) Note for New Set of model One parameters"
    }
  ],
  "Param": [
    {
      "Name": "ageSex",
      "SubCount": 1,
      "DefaultSubId": 0,
      "Txt": [
        {
          "LangCode": "EN",
          "Note": "Age by Sex new set of values"
        },
        {
          "LangCode": "FR",
          "Note": "(FR) Age by Sex new set of values"
        }
      ],
      "Value": [
        {"Dims": ["10-20","M"], "IsNull": false, "Value": 0.1, "SubId": 0},
        {"Dims": ["10-20","F"], "IsNull": false, "Value": 0.2, "SubId": 0},
        {"Dims": ["20-30","M"], "IsNull": false, "Value": 0.3, "SubId": 0},
        {"Dims": ["20-30","F"], "IsNull": false, "Value": 0.4, "SubId": 0},
        {"Dims": ["30-40","M"], "IsNull": false, "Value": 0.5, "SubId": 0},
        {"Dims": ["30-40","F"], "IsNull": false, "Value": 0.6, "SubId": 0},
        {"Dims": ["40+","M"],   "IsNull": false, "Value": 0.7, "SubId": 0},
        {"Dims": ["40+","F"],   "IsNull": false, "Value": 0.8, "SubId": 0}
      ]
    }
  ]
}

Example 3:

Create workset based on existing model run and copy two parameters:

  • copy parameter ageSex from model run Default-4
  • copy parameter salaryAge from Default workset
{
  "ModelName": "modelOne",
  "ModelDigest": "_201208171604590148_",
  "Name": "m1_based_on_first_run",
  "BaseRunDigest": "09cf2735bbe8aa88fd427c20925ca14a",
  "Txt": [{
      "LangCode": "EN",
      "Descr": "modelOne based on first run",
      "Note": "modelOne copy parameters from Default-4 run and Default workset"
    }, {
      "LangCode": "FR",
      "Descr": "(FR) modelOne based on first run",
      "Note": "(FR) modelOne copy parameters from Default-4 run and Default workset"
    }
  ],
  "Param": [
    {
      "Name": "ageSex",
      "Kind": "run",
      "From": "Default-4"
    },
    {
      "Name": "salaryAge",
      "Kind": "set",
      "From": "Default"
    }
  ]
}

curl -v -X PUT -H "Content-Type: application/json" "http://localhost:4040/api/workset-create" -d @m1_ws_new_on_run.json

*   Trying ::1...
* TCP_NODELAY set
* Connected to localhost (::1) port 4040 (#0)
> PUT /api/workset-create HTTP/1.1
> Host: localhost:4040
> User-Agent: curl/7.55.1
> Accept: */*
> Content-Type: application/json
> Content-Length: 399
>
* upload completely sent off: 399 out of 399 bytes
< HTTP/1.1 200 OK
< Content-Location: /api/model/_201208171604590148_/workset/auto_name_set_of_parameters_2020_05_01_15_22_54_807
< Content-Type: application/json
< Date: Fri, 01 May 2020 19:22:54 GMT
< Content-Length: 165
<
{"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"}
* Connection #0 to host localhost left intact

Example 4:

{
  "ModelName": "modelOne",
  "ModelDigest": "_201208171604590148_",
  "Name": "NewSet",
  "IsReadonly": true,
  "Txt": [
    {
      "LangCode": "EN",
      "Descr": "New Set of model One parameters"
    },
    {
      "LangCode": "FR",
      "Descr": "(FR) New Set of model One parameters",
      "Note": "(FR) Note for New Set of model One parameters"
    }
  ],
  "Param": [
    {
      "Name": "ageSex",
      "SubCount": 1,
      "DefaultSubId": 0,
      "Txt": [
        {
          "LangCode": "EN",
          "Note": "Age by Sex new set of values"
        },
        {
          "LangCode": "FR",
          "Note": "(FR) Age by Sex new set of values"
        }
      ],
      "Value": [
        {"Dims": ["10-20","M"], "IsNull": false, "Value": 0.1, "SubId": 0},
        {"Dims": ["10-20","F"], "IsNull": false, "Value": 0.2, "SubId": 0},
        {"Dims": ["20-30","M"], "IsNull": false, "Value": 0.3, "SubId": 0},
        {"Dims": ["20-30","F"], "IsNull": false, "Value": 0.4, "SubId": 0},
        {"Dims": ["30-40","M"], "IsNull": false, "Value": 0.5, "SubId": 0},
        {"Dims": ["30-40","F"], "IsNull": false, "Value": 0.6, "SubId": 0},
        {"Dims": ["40+","M"],   "IsNull": false, "Value": 0.7, "SubId": 0},
        {"Dims": ["40+","F"],   "IsNull": false, "Value": 0.8, "SubId": 0}
      ]
    },
    {
      "Name": "salaryAge",
      "SubCount": 1,
      "DefaultSubId": 0,
      "Txt": [
        {
          "LangCode": "EN",
          "Note": "Salary by Age new set of values"
        },
        {
          "LangCode": "FR",
          "Note": "(FR) Salary by Age new set of values"
        }
      ],
      "Value": [
        {"Dims": ["L","10-20"], "IsNull": false, "Value": 10, "SubId": 0},
        {"Dims": ["L","20-30"], "IsNull": false, "Value": 20, "SubId": 0},
        {"Dims": ["L","30-40"], "IsNull": false, "Value": 30, "SubId": 0},
        {"Dims": ["L","40+"],   "IsNull": false, "Value": 40, "SubId": 0},
        {"Dims": ["M","10-20"], "IsNull": false, "Value": 11, "SubId": 0},
        {"Dims": ["M","20-30"], "IsNull": false, "Value": 21, "SubId": 0},
        {"Dims": ["M","30-40"], "IsNull": false, "Value": 31, "SubId": 0},
        {"Dims": ["M","40+"],   "IsNull": false, "Value": 41, "SubId": 0},
        {"Dims": ["H","10-20"], "IsNull": false, "Value": 12, "SubId": 0},
        {"Dims": ["H","20-30"], "IsNull": false, "Value": 22, "SubId": 0},
        {"Dims": ["H","30-40"], "IsNull": false, "Value": 32, "SubId": 0},
        {"Dims": ["H","40+"],   "IsNull": false, "Value": 42, "SubId": 0}
      ]
    },
    {
      "Name": "StartingSeed",
      "SubCount": 1,
      "DefaultSubId": 0,
      "Txt": [
        {
          "LangCode": "EN",
          "Note": "Starting seed new set of value"
        }
      ],
      "Value": [
        {"Dims": [], "IsNull": false, "Value": 8191, "SubId": 0}
      ]
    },
    {
      "Name": "salaryFull",
      "SubCount": 4,
      "DefaultSubId": 3,
      "Txt": [
        {
          "LangCode": "EN",
          "Note": "Full or part time by Salary new set of values"
        }
      ],
      "Value": [
        {"Dims": ["L"], "IsNull": false, "Value": "Part", "SubId": 0},
        {"Dims": ["M"], "IsNull": false, "Value": "Full", "SubId": 0},
        {"Dims": ["H"], "IsNull": false, "Value": "Full", "SubId": 0},
        {"Dims": ["L"], "IsNull": false, "Value": "Part", "SubId": 1},
        {"Dims": ["M"], "IsNull": false, "Value": "Part", "SubId": 1},
        {"Dims": ["H"], "IsNull": false, "Value": "Part", "SubId": 1},
        {"Dims": ["L"], "IsNull": false, "Value": "Full", "SubId": 2},
        {"Dims": ["M"], "IsNull": false, "Value": "Full", "SubId": 2},
        {"Dims": ["H"], "IsNull": false, "Value": "Full", "SubId": 2},
        {"Dims": ["L"], "IsNull": false, "Value": "Full", "SubId": 3},
        {"Dims": ["M"], "IsNull": false, "Value": "Full", "SubId": 3},
        {"Dims": ["H"], "IsNull": false, "Value": "Part", "SubId": 3}
      ]
    },
    {
      "Name": "baseSalary",
      "SubCount": 4,
      "DefaultSubId": 3,
      "Txt": [],
      "Value": [
        {"Dims": [],"IsNull": false, "Value": "Full", "SubId": 0},
        {"Dims": [],"IsNull": false, "Value": "Part", "SubId": 1},
        {"Dims": [],"IsNull": false, "Value": "Full", "SubId": 2},
        {"Dims": [],"IsNull": false, "Value": "Part", "SubId": 3}
      ]
    },
    {
      "Name": "filePath",
      "SubCount": 4,
      "DefaultSubId": 3,
      "Txt": [],
      "Value": [
        {"Dims": [], "IsNull": false, "Value": "file 0 path", "SubId": 0},
        {"Dims": [], "IsNull": false, "Value": "file 1 path", "SubId": 1},
        {"Dims": [], "IsNull": false, "Value": "file 2 path", "SubId": 2},
        {"Dims": [], "IsNull": false, "Value": "file 3 path", "SubId": 3}
      ]
    },
    {
      "Name": "isOldAge",
      "SubCount": 4,
      "DefaultSubId": 3,
      "Txt": [
        {
          "LangCode": "EN",
          "Note": "Is old age new set of values"
        }
      ],
      "Value": [
        {"Dims": ["10-20"], "IsNull": false, "Value": false, "SubId": 0},
        {"Dims": ["20-30"], "IsNull": false, "Value": false, "SubId": 0},
        {"Dims": ["30-40"], "IsNull": false, "Value": false, "SubId": 0},
        {"Dims": ["40+"],   "IsNull": false, "Value": true,  "SubId": 0},
        {"Dims": ["10-20"], "IsNull": false, "Value": false, "SubId": 1},
        {"Dims": ["20-30"], "IsNull": false, "Value": false, "SubId": 1},
        {"Dims": ["30-40"], "IsNull": false, "Value": false, "SubId": 1},
        {"Dims": ["40+"],   "IsNull": false, "Value": true,  "SubId": 1},
        {"Dims": ["10-20"], "IsNull": false, "Value": false, "SubId": 2},
        {"Dims": ["20-30"], "IsNull": false, "Value": false, "SubId": 2},
        {"Dims": ["30-40"], "IsNull": false, "Value": false, "SubId": 2},
        {"Dims": ["40+"],   "IsNull": false, "Value": true,  "SubId": 2},
        {"Dims": ["10-20"], "IsNull": false, "Value": false, "SubId": 3},
        {"Dims": ["20-30"], "IsNull": false, "Value": false, "SubId": 3},
        {"Dims": ["30-40"], "IsNull": false, "Value": false, "SubId": 3},
        {"Dims": ["40+"],   "IsNull": false, "Value": true,  "SubId": 3}
      ]
    }
  ]
}

Home

Getting Started

Model development in OpenM++

Using OpenM++

Model Development Topics

OpenM++ web-service: API and cloud setup

Using OpenM++ from Python and R

Docker

OpenM++ Development

OpenM++ Design, Roadmap and Status

OpenM++ web-service API

GET Model Metadata

GET Model Extras

GET Model Run results metadata

GET Model Workset metadata: set of input parameters

Read Parameters, Output Tables or Microdata values

GET Parameters, Output Tables or Microdata values

GET Parameters, Output Tables or Microdata as CSV

GET Modeling Task metadata and task run history

Update Model Profile: set of key-value options

Update Model Workset: set of input parameters

Update Model Runs

Update Modeling Tasks

Run Models: run models and monitor progress

Download model, model run results or input parameters

Upload model runs or worksets (input scenarios)

Download and upload user files

User: manage user settings

Model run jobs and service state

Administrative: manage web-service state

Clone this wiki locally