-
Notifications
You must be signed in to change notification settings - Fork 12
/
Copy pathmodel_service_api.yaml
580 lines (577 loc) · 18.5 KB
/
model_service_api.yaml
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
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
openapi: 3.0.0
info:
title: "ModelService API"
description: "This API specification is for the World Modelers Modeling Service System. The goal of this API is to provide a controller for model discovery and exploration, as well as for initializing and managing model runs."
version: "1.0.0"
servers:
- url: https://model-service.worldmodelers.com
description: Future (production) server
- url: http://localhost:8080
description: Local server for testing
paths:
/list_models:
post:
tags:
- "exploration"
summary: "Obtain a list of current models"
description: "Request a list of currently available models."
responses:
200:
description: "SUCCESS"
content:
application/json:
schema:
$ref: '#/components/schemas/AvailableModels'
/model_info/{ModelName}:
get:
tags:
- "exploration"
summary: "Get basic metadata information for a specified model."
description: "Submit a model name and receive metadata information about the model, such as its purpose, who maintains it, and how it can be run."
parameters:
- in: path
name: ModelName
description: "The name of a model."
required: true
schema:
$ref: "#/components/schemas/ModelName"
responses:
200:
description: "SUCCESS"
content:
application/json:
schema:
$ref: '#/components/schemas/Model'
/model_outputs/{ModelName}:
get:
tags:
- "exploration"
summary: "Obtain information on a given model's outputs."
description: "Submit a model name and receive information about the output variables produced by this model."
parameters:
- in: path
name: ModelName
description: "The name of a model."
required: true
schema:
$ref: "#/components/schemas/ModelName"
responses:
200:
description: "SUCCESS"
content:
application/json:
schema:
type: "array"
items:
$ref: '#/components/schemas/Variable'
/model_parameters/{ModelName}:
get:
tags:
- "exploration"
summary: "Obtain information about a model's parameters."
description: "Submit a model name and receive information about the parameters used by this model. Specific parameters are used on a per-configuration basis."
parameters:
- in: path
name: ModelName
description: "The name of a model."
required: true
schema:
$ref: "#/components/schemas/ModelName"
responses:
200:
description: "SUCCESS"
content:
application/json:
schema:
type: "array"
items:
$ref: '#/components/schemas/Parameter'
/model_config/{ModelName}:
get:
tags:
- "exploration"
summary: "Obtain configurations for a given model."
description: "Submit a model name and receive all configurations for the given model."
parameters:
- in: path
name: ModelName
description: "The name of a model."
required: true
schema:
$ref: "#/components/schemas/ModelName"
responses:
200:
description: "SUCCESS"
content:
application/json:
schema:
$ref: '#/components/schemas/ModelConfig'
/list_concepts:
get:
tags:
- "concepts"
summary: "Obtain a list of available concepts"
description: >
Request a list of currently available concepts. These are derived from the list of
[UN indicators](https://github.com/WorldModelers/Ontologies/blob/master/performer_ontologies/un_to_indicators.tsv) and are tied to model output variables.
responses:
200:
description: "SUCCESS"
content:
application/json:
schema:
$ref: '#/components/schemas/AvailableConcepts'
/concept_mapping:
get:
tags:
- "concepts"
summary: "Obtain an array of models related to a concept."
description: >
Submit a concept name and optional type and receive an array of concepts
related to that concept.
parameters:
- in: query
name: concept
description: "A concept name"
required: false
schema:
$ref: "#/components/schemas/ConceptName"
- in: query
name: concept_type
description: The type of concept objects to return
schema:
type: string
enum:
- "model"
- "output"
- "parameter"
responses:
200:
description: "SUCCESS"
content:
application/json:
schema:
$ref: '#/components/schemas/ConceptMapping'
/run_model:
post:
tags:
- "execution"
summary: "Run a model for a given a configuration"
description: "Submit a configuration to run a specific model. Model is run asynchronously. Results are available through `/run_results` endpoint. Note that the `requestBody` must include a `config` object which should have as its `keys` the appropriate model `parameter` `labels`. Each `key` should have a corresponding `parameter` `value`. If a `parameter` is missing it will be defaulted."
requestBody:
description: "Model and configuration parameters"
required: true
content:
application/json:
schema:
$ref: "#/components/schemas/ModelConfig"
responses:
200:
description: "SUCCESS"
content:
application/json:
schema:
$ref: "#/components/schemas/RunID"
/run_status/{RunID}:
get:
tags:
- "execution"
summary: "Obtain status for a given model run"
description: "Submit a `RunID` and receive the model run status"
parameters:
- in: path
name: RunID
description: "The `ID` for a given model run."
required: true
schema:
$ref: "#/components/schemas/RunID"
responses:
200:
description: "SUCCESS"
content:
application/json:
schema:
$ref: '#/components/schemas/RunStatus'
/run_results/{RunID}:
get:
tags:
- "execution"
summary: "Obtain metadata about the results of a given model run"
description: "Submit a `RunID` and receive model run results metadata, including whether it succeeded or failed and where to access the result data."
parameters:
- in: path
name: RunID
description: "The ID for a given model run."
required: true
schema:
$ref: "#/components/schemas/RunID"
responses:
200:
description: "SUCCESS"
content:
application/json:
schema:
$ref: '#/components/schemas/RunResults'
/list_runs/{ModelName}:
get:
tags:
- "execution"
summary: "Obtain a list of runs for a given model"
description: "Submit a `ModelName` and receive an array of `RunID`s associated with the given model."
parameters:
- in: path
name: ModelName
description: "A model name"
required: true
schema:
$ref: "#/components/schemas/ModelName"
responses:
200:
description: "SUCCESS"
content:
application/json:
schema:
type: "array"
items:
$ref: '#/components/schemas/RunID'
/available_results:
get:
tags:
- "execution"
summary: "Obtain a list of run results"
description: "Return a list of all available run results."
parameters:
- in: query
name: ModelName
description: "A model name"
required: false
schema:
$ref: "#/components/schemas/ModelName"
- in: query
name: size
description: The maximum number of results to return.
schema:
type: integer
responses:
200:
description: "SUCCESS"
content:
application/json:
schema:
type: "array"
items:
$ref: '#/components/schemas/RunResults'
/result_file/{ResultFileName}:
get:
tags:
- "execution"
summary: "Obtain the result file for a given model run."
description: "Submit a `ResultFileName` and receive model run result file."
parameters:
- in: path
name: ResultFileName
description: "A file name of a result file."
required: true
schema:
$ref: "#/components/schemas/ResultFileName"
responses:
'200':
description: A result file
components:
securitySchemes:
BasicAuth:
type: http
scheme: basic
schemas:
ModelName:
type: "string"
description: "A model's name"
example: "FSC"
StandardName:
type: "object"
description: "A standard name representation"
required:
- "standard_variable_id"
- "standard_variable_name"
- "standard_variable_uri"
properties:
standard_variable_id:
type: "string"
description: "The MINT UUID associated with the standard name"
example: "df1daca4-d727-5dc8-bfa4-fb20c717a32b"
standard_variable_name:
type: "string"
description: "The natural language name for a standard name"
example: "year"
standard_variable_uri:
type: "string"
description: "The URI associated with the standard name"
example: "http://www.geoscienceontology.org/svo/svl/property#year"
Model:
type: "object"
required:
- "name"
- "description"
- "maintainer"
- "label"
description: "An object defining high-level metadata about a model"
properties:
name:
$ref: '#/components/schemas/ModelName'
label:
type: "string"
description: "The human readable name of the model"
versions:
type: "array"
items:
type: "string"
example: ["1.1", "1.2", "LATEST"]
description: "Latest model version"
maintainer:
type: "string"
description: "Maintainer information for this model. Should include institution name and point of contact."
example: "Michael Puma, Columbia University"
description:
type: "string"
description: "A basic overview of the model's purpose."
example: "FSC single country shock configuration."
category:
# this may ultimately be an enumerated (fixed) string
# e.g. select from one of the following (from ontology)
type: "array"
description: "The category for the given model."
items:
type: "string"
example: ["Agriculture", "Economic"]
AvailableModels:
type: "array"
items:
$ref: '#/components/schemas/Model'
uniqueItems: true
description: "An array of available models"
ModelConfig:
# this can be an example config, or a config submitted to execute
# a job. This is loosely defined for the time being.
# note that the `valid` and `error` fields should only be
# completed when associated with the `validate_config` endpoint
type: "object"
description: "A model configuration file (JSON)."
required:
- "name"
- "config"
properties:
name:
$ref: '#/components/schemas/ModelName'
config:
type: "object"
Variable:
# the variable can have arbitrary information stored in its metadata field
type: "object"
description: "A variable used in a model input or output file."
required:
- "name"
- "description"
properties:
name:
type: "string"
description:
type: "string"
units:
type: "string"
metadata:
type: "object"
Parameter:
type: "object"
description: "A user configurable model parameter"
required:
- "name"
- "description"
properties:
name:
type: "string"
description: "The name of the parameter"
example: "crop"
description:
type: "string"
description: "Natural language description of parameter"
example: "Choose the crop of interest from one of [millet, maize, wheat]."
type:
type: "string"
description: "The parameter's type"
example: "StringParameter"
enum:
- NumberParameter
- ChoiceParameter
- TimeParameter
- GeoParameter
- StringParameter
default_value:
description: "The parameter's default value. Type depends on the parameter's type."
example: "maize"
minimum:
description: "The parameter's minimum allowed value. Type depends on the parameter's type."
maximum:
description: "The parameter's maximum allowed value. Type depends on the parameter's type."
choices:
type: "array"
items:
oneOf:
- type: string
- type: integer
description: An array of choices available for a parameter of type ChoiceParameter
example: ["millet", "maize", "wheat"]
SearchResult:
type: "array"
description: "The result of a search"
items:
type: "object"
Query:
type: "object"
required:
- "query_type"
- "result_type"
discriminator:
propertyName: query_type
properties:
query_type:
type: "string"
description: "Is this a geo, time or text query?"
enum: ["geo", "time", "text"]
result_type:
type: "string"
description: "Should the query return models, datasets, or variables?"
enum: ["models", "datasets", "variables"]
GeoQuery:
allOf:
- $ref: "#/components/schemas/Query"
- type: "object"
description: "A geospatial bounding box search parameter is 4-elements in the WGS84 coordinate system: [xmin, ymin, xmax, ymax]. x is longitude, y is latitude"
required:
- "xmin"
- "xmax"
- "ymin"
- "ymax"
- "result_type"
properties:
xmin:
description: "Minimum longitude"
type: "number"
xmax:
description: "Maximum longitude"
type: "number"
ymin:
description: "Minimum latitude"
type: "number"
ymax:
description: "Maximum latitude"
type: "number"
TimeQuery:
allOf:
- $ref: "#/components/schemas/Query"
- type: "object"
description: "A query defined by a start and end time."
required:
- "start_time"
- "end_time"
properties:
start_time:
description: "Minimum time for search query."
type: "string"
end_time:
description: "Maximum time for search query"
type: "string"
TextQuery:
allOf:
- $ref: "#/components/schemas/Query"
- type: "object"
description: "A text string based query."
required:
- "type"
- "term"
properties:
type:
description: "The type of query (either keyword or standard name)"
type: "string"
enum:
- "keyword"
- "standard name"
term:
description: "The search term of interest."
type: "string"
RunID:
type: "string"
description: "ID associated with a model run. This is the SHA256 hash of the ModelConfig sent to the /run_model endpoint"
example: "3A3B3E0AE57AD4A7EF658C1F7832774F55E403F01FDF44B68B355EC4587D7A04"
ResultFileName:
type: "string"
description: "The name of a model run result file."
example: "3A3B3E0AE57AD4A7EF658C1F7832774F55E403F01FDF44B68B355EC4587D7A04.csv"
RunStatus:
type: "string"
description: "Status information about a model run."
enum:
- "PENDING"
- "FAIL"
- "SUCCESS"
RunResults:
type: "object"
description: "Metadata about the results of a given model run."
required:
- "config"
- "status"
- "output"
properties:
config:
$ref: "#/components/schemas/ModelConfig"
status:
type: "string"
enum: ["SUCCESS", "FAIL", "PENDING"]
output:
type: "string"
description: "URI for accessing output (for example, on S3)"
auth_required:
description: "Does accessing this model output require authentification? True if requires auth."
type: boolean
timestamp:
description: "Epoch timestamp when the model run was initiated (epoch millis)"
type: integer
Error:
type: "object"
description: "Arbitrary error object."
ConceptName:
type: "string"
description: "A concept's name"
example: "precipitation"
Concept:
type: "object"
description: "A model, parameter, or output variable related to a concept"
required:
- "name"
- "score"
- "type"
properties:
name:
type: "string"
description: "The object name"
score:
type: "number"
description: "The score for the object in relation to the concept (higher is closer match)"
type:
type: "string"
description: "Whether the object is related to a model, parameter, or output"
enum:
- "model"
- "output"
- "parameter"
AvailableConcepts:
type: "array"
items:
$ref: "#/components/schemas/ConceptName"
uniqueItems: true
description: "An array of available concept names"
ConceptMapping:
type: "array"
description: >
An array of objects (models, output variables, or parameters) that relate to a concept
items:
$ref: "#/components/schemas/Concept"