Skip to content

Model Management Service– Samples

The samples below exemplify how to use the provided endpoints.

Note

For avoiding confusions with JSON syntax, placeholders are indicated using angle brackets instead of curly brackets in the following samples.

Uploading a Model with Version Metadata and a Binary File

Request:

1
2
POST  /api/modelmanagement/v3/models
X-XSRF-TOKEN: `<xsrf_token>`

Provide the following content for the metadata key of the form-data:

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
{
  "name": "Model 1",
  "description": "Model 1",
  "type": "Protobuf file",
  "lastVersion": {
    "number": 1.0,
    "expirationDate": "2019-10-01T12:00:00.001",
    "dependencies": [{
      "name": "sklearn-theano",
      "type": "Python",
      "version": "2.7"
    }],
    "io": {
      "consumes": "CSV",
      "input": [{
        "name": "variablename1",
        "type": "integer",
        "description": "description for variablename1",
        "value": 5
      }],
      "output": [{
        "name": "outputname1",
        "type": "integer",
        "description": "description for outputname1",
        "value": null
      }],
      "optionalParameters": {
        "freeFormParams": "for the author to use",
        "param1": "value1"
      }
    },
    "producedBy": [<existing_model_id>, <other_existing_model_id>],
    "kpi": [{
      "name": "error rate",
      "value": 0.9
    }]
  }
}

The file key of the form-data must contain the payload of the model's binary file.

Response:

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
{
  "id": <new_model_id>,
  "name": "Model 1",
  "description": "Model 1",
  "type": "PDF File",
  "author": "creator@siemens.com",
  "lastVersion": {
    "id": <new_version_id>,
    "number": 1.0,
    "expirationDate": "2019-10-01T12:00:00.001",
    "author": "user@siemens.com",
    "creationDate": "2018-10-01T12:00:00.001",
    "dependencies": [{
      "name": "sklearn-theano",
      "type": "Python",
      "version": "2.7"
    }],
    "io": {
      "consumes": "CSV",
      "input": [{
        "name": "variablename1",
        "type": "integer",
        "description": "description for variablename1",
        "value": 5
      }],
      "output": [{
        "name": "outputname1",
        "type": "integer",
        "description": "description for outputname1",
        "value": null
      }],
      "optionalParameters": {
        "freeFormParams": "for the author to use",
        "param1":"value1"
      }
    },
    "producedBy": [<existing_model_id>, <other_existing_model_id>],
    "kpi": [{
      "name": "error rate",
      "value": 0.9
    }]
  }
}

Uploading a New Version of a Model

Request:

1
2
POST  /api/modelmanagement/v3/models/<model_id>/versions
X-XSRF-TOKEN: `<xsrf_token>`

Provide the following content for the metadata key of the form-data:

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
{
  "number": 1.0,
  "expirationDate": "2019-10-01T12:00:00.001",
  "dependencies": [{
    "name": "sklearn-theano",
    "type": "Python",
    "version": "1.7"
  }],
  "io": {
    "consumes": "CSV",
    "input": [{
      "name": "variablename1",
      "type": "integer",
      "description": "description for variablename1",
      "value": 5
    }],
    "output": [{
      "name": "outputname1",
      "type": "integer",
      "description": "description for outputname1",
      "value": null
    }],
    "optionalParameters": {
      "freeFormParams": "for the author to use",
      "param1":"value1"
    }
  },
  "producedBy": [<existing_model_id>, <other_existing_model_id>],
  "kpi": [{
    "name": "error rate",
    "value": 0.9
  }]
}

The file key of the form-data must contain the payload of the model's binary file.

Response:

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
{
  "id": <new_version_id>,
  "number": 1.0,
  "expirationDate": "2019-10-01T12:00:00.001",
  "author": "user@siemens.com",
  "creationDate": "2018-10-01T12:00:00.001",
  "dependencies": [{
    "name": "sklearn-theano",
    "type": "Python",
    "version": "1.7"
  }],
  "io": {
    "consumes": "CSV",
    "input": [{
      "name": "variablename1",
      "type": "integer",
      "description": "description for variablename1",
      "value": 5
    }],
    "output": [{
      "name": "outputname1",
      "type": "integer",
      "description": "description for outputname1",
      "value": null
    }],
    "optionalParameters": {
      "freeFormParams": "for the author to use",
      "param1":"value1"
    }
  },
  "producedBy": [<existing_model_id>, <other_existing_model_id>],
  "kpi": [{
    "name": "error rate",
    "value": 0.9
  }]
}

Updating a Model

The PATCH request is used to selectively update specific attributes of a model's metadata and its version. When updating array fields, the entire array must be provided as an input, because the service completely replaces the respective arrays.
For example, the entire list of items must be provided, when updating the dependencies field. The Model Management service takes the items provided in the request and replaces the stored attribute entirely. This also applies to the io, produced_by and kpi fields.

Except for author, creationDate, and id, any field of the model can be updated, including its version (attribute lastVersion).

Note that, the number attribute is automatically incremented, if not provided with a higher version than what is stored.

Request:

1
2
PATCH  /api/modelmanagement/v3/models/<model_id>
X-XSRF-TOKEN: `<xsrf_token>`

Provide the following content for the metadata key of the form-data:

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
{
  "name":"new model name",
  "lastVersion":
  {
    "number": 1.4,
    "io": {
      "consumes": "CSV",
      "input": [{
          "name": "variablename1",
          "type": "integer",
          "description": "description for variablename1",
          "value": 5
        },
        {
          "name": "newVarName",
          "type": "string",
          "description": "description for newVarName, e.g. path",
          "value": "/usr/lib/zeppelin/some.c"
        }
      ]
    },
  }
}

The file key of the form-data must contain the payload of the model's binary file.

Response:

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
{
  "id":<model_id>,
  "name":"new model name",
  "description": "old model description",
  "author": "user@siemens.com",
  "lastVersion":
  {
    "id": <version_id>,
    "number": 1.0,
    "expirationDate": "2019-10-01T12:00:00.001",
    "author": "user@siemens.com",
    "creationDate": "2018-10-01T12:00:00.001",
    "dependencies": [{
        "name": "sklearn-theano",
        "type": "Python",
        "version": "1.7"
    }],
    "io": {
      "consumes": "CSV",
      "input": [{
          "name": "variablename1",
          "type": "integer",
          "description": "description for variablename1",
          "value": 5
        },
        {
          "name": "newVarName",
          "type": "string",
          "description": "description for newVarName, e.g. path",
          "value": "/usr/lib/zeppelin/some.c"
        }
      ],
      "output": [{
          "name": "outputname1",
          "type": "integer",
          "description": "description for outputname1",
          "value": null
      }],
      "optionalParameters": {
        "freeFormParams": "for the author to use",
        "param1":"value1"
      }
    },
    "producedBy": [<existing_model_id>, <other_existing_model_id>],
    "kpi": [{
        "name": "error rate",
        "value": 0.9
    }]
  }
}

Updating the Last Version of a Model

Request:

1
2
PATCH  /api/modelmanagement/v3/models/<model_id>/versions/last
X-XSRF-TOKEN: <xsrf_token>

Any field of the version can be updated, except for author, creationDate and id.

Provide the following content for the metadata key of the form-data:

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
{
  "number": 1.2,
  "expirationDate": "2019-10-01T12:00:00.001",
  "dependencies": [{
      "name": "sklearn-theano",
      "type": "Python",
      "version": "1.7"
    },
    {
      "name": numpy,
      "type": "Python",
      "version": "1.15"
  }],
  "io": {
    "consumes": "CSV",
    "input": [{
        "name": "variablename1",
        "type": "integer",
        "description": "description for variablename1",
        "value": 5
    }],
    "output": [{
        "name": "outputname1",
        "type": "integer",
        "description": "description for outputname1",
        "value": null
    }],
    "optionalParameters": {
      "freeFormParams": "for the author to use",
      "param1":"value1"
    }
  },
  "producedBy": [<existing_model_id>, <other_existing_model_id>],
  "kpi": [{
      "name": "error rate",
      "value": 0.9
  }]
}

The file key of the form-data must contain the payload of the model's binary file.

Response:

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
{
  "id": <version_id>,
  "number": 1.2,
  "expirationDate": "2019-10-01T12:00:00.001",
  "author": "user@siemens.com",
  "creationDate": "2018-10-01T12:00:00.001",
  "dependencies": [{
      "name": "sklearn-theano",
      "type": "Python",
      "version": "1.7"
    },
    {
      "name": numpy,
      "type": "Python",
      "version": "1.15"
  }],
  "io": {
    "consumes": "CSV",
    "input": [{
        "name": "variablename1",
        "type": "integer",
        "description": "description for variablename1",
        "value": 5
    }],
    "output": [{
        "name": "outputname1",
        "type": "integer",
        "description": "description for outputname1",
        "value": null
    }],
    "optionalParameters": {
      "freeFormParams": "for the author to use",
      "param1":"value1"
    }
  },
  "producedBy": [<existing_model_id>, <other_existing_model_id>],
  "kpi": [{
      "name": "error rate",
      "value": 0.9
  }]
}

Listing Available Models

This lists all available models, along with their last version only.

Request:

1
2
GET  /api/modelmanagement/v3/models
Accept: `application/json`

Response:

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
{[
    {
      "id": <model1_id>,
      "name": "some model 1",
      "description": "Some Model 1",
      "type": "PB file",
      "author": "user@siemens.com",
      "lastVersion": {
        "id": <version1_id>,
        "number": 1.0,
        "expirationDate": "2019-10-01T12:00:00.001",
        "author": "user@siemens.com",
        "creationDate": "2018-10-01T12:00:00.001",
        "dependencies": [{
            "name": "sklearn-theano",
            "type": "Python",
            "version": "1.7"
        }],
        "io": {
          "consumes": "CSV",
          "input": [{
              "name": "variablename1",
              "type": "integer",
              "description": "description for variablename1",
              "value": 5
            }],
            "output": [{
                "name": "outputname1",
                "type": "integer",
                "description": "description for outputname1",
                "value": null
            }],
            "optionalParameters": {
              "freeFormParams": "for the author to use",
              "param1":"value1"
            }
          },
          "producedBy": [<existing_model_id>, <other_existing_model_id>],
          "kpi": [{
              "name": "error rate",
              "value": 0.9
          }]
        }
    },
    {
      "id": <model2_id>,
      "name": "some model 2",
      "description": "Some Model 2",
      "type": "JSON file",
      "author": "user@siemens.com",
      "lastVersion": {
        "id": <version1_id>,
        "number": 1.0,
        "expirationDate": "2019-11-01T12:00:00.001",
        "author": "user@siemens.com",
        "creationDate": "2018-10-01T12:00:00.001",
        "dependencies": [{
            "name": "sklearn-theano",
            "type": "Python",
            "version": "1.7"
        }],
        "io": {
          "consumes": "CSV",
          "input": [{
              "name": "variablename1",
              "type": "integer",
              "description": "description for variablename1",
              "value": 5
          }],
          "output": [{
              "name": "outputname1",
              "type": "integer",
              "description": "description for outputname1",
              "value": null
          }],
          "optionalParameters": {
            "freeFormParams": "for the author to use",
            "param1":"value1"
          }
        },
        "producedBy": [<yet_another_existing_model_id>, <and_another_existing_model_id>],
        "kpi": [{
            "name": "error rate",
            "value": 0.9
        }]
      }
  }],
  "page": {
    "number": 0,
    "size": 14,
    "totalPages": 1,
    "totalElements": 14
  }
}

Obtaining a Model's Metadata

Request:

1
GET  /api/modelmanagemen/v3/models/<model_id>`

Response:

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
{
  "id": <model_id>,
  "name": "some_model",
  "description": "Model 1",
  "type": "PDF File",
  "author": "creator@siemens.com",
  "lastVersion": {
    "id": <version_id>,
    "number": 1.0,
    "expirationDate": "2019-10-01T12:00:00.001",
    "author": "user@siemens.com",
    "creationDate": "2018-10-01T12:00:00.001",
    "dependencies": [{
        "name": "sklearn-theano",
        "type": "Python",
        "version": "1.7"
    }],
    "io": {
      "consumes": "CSV",
      "input": [{
          "name": "variablename1",
          "type": "integer",
          "description": "description for variablename1",
          "value": 5
      }],
      "output": [{
          "name": "outputname1",
          "type": "integer",
          "description": "description for outputname1",
          "value": null
      }],
      "optionalParameters": {
        "freeFormParams": "for the author to use",
        "param1":"value1"
      }
    },
    "producedBy": [<existing_model_id>, <other_existing_model_id>],
    "kpi": [{
        "name": "error rate",
        "value": 0.9
    }]
  }
}

Downloading a Model's Metadata or Last Version's Payload

This request can be used to download either the metadata or the payload of the last version based on the Content-Type header. If the Content-Type is specified as application/octet-stream, the service returns the last version's payload. In this sample the Content-Type is specified as application/json, for which the last version's metadata is returned:

1
2
3
GET /api/modelmanagement/v3/<model_id>/versions/<version_id> HTTP/1.1
X-XSRF-TOKEN: `<x-xsrf-token>`
Content-Type: `application/json`

Response:

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
{
  "id": <version_id>,
  "number": 1.0,
  "expirationDate": "2019-10-01T12:00:00.001",
  "author": "user@siemens.com",
  "creationDate": "2018-10-01T12:00:00.001",
  "dependencies": [{
      "name": "sklearn-theano",
      "type": "Python",
      "version": "1.7"
  }],
  "io": {
    "consumes": "CSV",
    "input": [{
        "name": "variablename1",
        "type": "integer",
        "description": "description for variablename1",
        "value": 5
    }],
    "output": [{
        "name": "outputname1",
        "type": "integer",
        "description": "description for outputname1",
        "value": null
    }],
    "optionalParameters": {
      "freeFormParams": "for the author to use",
      "param1":"value1"
    }
  },
  "producedBy": [<existing_model_id>, <other_existing_model_id>],
  "kpi": [{
      "name": "error rate",
      "value": 0.9
  }]
}

Obtaining the Metadata or Payload of a Specific Version of a Model

This request can be used to download either the metadata or the payload of the specific version of a model. If the Content-Type header is specified as application/octet-stream, the service returns the specified version's payload. In this sample the Content-Type is specified as application/json, for which the service returns the metadata of the model's specified version.

1
2
3
GET /api/modelmanagement/v3/models/<model_id>/versions/<version_id> HTTP/1.1
Content-Type: `application/json`
X-XSRF-TOKEN: `<token>`

Response:

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
{
  "id": <version_id>,
  "number": 1.0,
  "expirationDate": "2019-10-01T12:00:00.001",
  "author": "user@siemens.com",
  "creationDate": "2018-10-01T12:00:00.001",
  "dependencies": [{
      "name": "sklearn-theano",
      "type": "Python",
      "version": "1.7"
  }],
  "io": {
    "consumes": "CSV",
    "input": [{
        "name": "variablename1",
        "type": "integer",
        "description": "description for variablename1",
        "value": 5
    }],
    "output": [{
        "name": "outputname1",
        "type": "integer",
        "description": "description for outputname1",
        "value": null
    }],
    "optionalParameters": {
      "freeFormParams": "for the author to use",
      "param1":"value1"
    }
  },
  "producedBy": [<existing_model_id>, <other_existing_model_id>],
  "kpi": [{
      "name": "error rate",
      "value": 0.9
  }]
}

Deleting a Model

When deleting a model, all of its related versions are deleted successively. Versions are deleted from smallest to largest version number. After deleting all associated metadata and payload files, the model itself is deleted.

1
2
DELETE /api/modelmanagement/v3/models/<model_id>`
X-XSRF-TOKEN: `<xsrf-token>`

Response:

1
Status: 204 - No content

Deleting the Last Version of a Model

1
2
DELETE /api/modelmanagement/v3/models/<model_id>/versions/last
X-XSRF-TOKEN: `<xsrf-token>`

Response:

1
Status: 204 - No content

Deleting a Specific Version of a Model

Both the model ID and the version ID must be specified for this service.

1
2
DELETE /api/modelmanagement/v3/models/<model_id>/versions/<version_id>
X-XSRF-TOKEN: `<xsrf-token>`

Response:

1
Status: 204 - No content

Any questions left?

Ask the community


Except where otherwise noted, content on this site is licensed under the MindSphere Development License Agreement.