/
handlerGet.go
673 lines (549 loc) · 23.2 KB
/
handlerGet.go
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
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
// Copyright (c) 2016 OpenM++
// This code is licensed under the MIT license (see LICENSE.txt for details)
package main
import (
"net/http"
"path/filepath"
"github.com/openmpp/go/ompp/db"
"github.com/openmpp/go/ompp/omppLog"
)
// return list of models as model_dic rows and model directory:
//
// GET /api/model-list
func modelListHandler(w http.ResponseWriter, r *http.Request) {
// get list of model basics: name, digest and directory
mbs := theCatalog.allModels()
type modelListItem struct {
Model db.ModelDicRow // model_dic db row
Dir string // model directory, relative to model root and slashed: dir/sub
DbPath string // path to model.sqlite, relative to model root and slashed: dir/sub/model.sqlite
Extra string // if not empty then model extra content
}
ml := make([]modelListItem, 0, len(mbs))
// by model digest get model_dic row
for _, b := range mbs {
if m, ok := theCatalog.ModelDicByDigest(b.model.Digest); ok {
ml = append(ml,
modelListItem{
Model: m,
Dir: filepath.Dir(b.relPath),
DbPath: b.relPath,
Extra: b.extra,
})
}
}
// write json response
jsonResponse(w, r, ml)
}
// return list models as model_dic row, model_dic_txt row and model directory:
//
// GET /api/model-list/text
// GET /api/model-list/text/lang/:lang
//
// If optional lang specified then result in that language else in browser language or model default.
func modelTextListHandler(w http.ResponseWriter, r *http.Request) {
rqLangTags := getRequestLang(r, "lang") // get optional language argument and languages accepted by browser
// get list of model basics: name, digest and directory
mbs := theCatalog.allModels()
type modelTxtListItem struct {
ModelDicDescrNote // model_dic db row and model_dic_txt row
Dir string // model directory, relative to model root and slashed: dir/sub
DbPath string // path to model.sqlite, relative to model root and slashed: dir/sub/model.sqlite
Extra string // if not empty then model extra content
}
mtl := make([]modelTxtListItem, 0, len(mbs))
// by model digest get model_dic row and model_dic_txt row in UI language
for _, b := range mbs {
if mt, ok := theCatalog.ModelTextByDigest(b.model.Digest, rqLangTags); ok {
mtl = append(mtl,
modelTxtListItem{
ModelDicDescrNote: *mt,
Dir: filepath.Dir(b.relPath),
DbPath: b.relPath,
Extra: b.extra,
})
}
}
// write json response
jsonResponse(w, r, mtl)
}
// If multiple models with same name exist only one is returned.
//
// GET /api/model/:model
//
// Get language-indepedent model metadata.
func modelMetaHandler(w http.ResponseWriter, r *http.Request) {
doModelMetaHandler(w, r, false)
}
// If multiple models with same name exist only one is returned.
//
// GET /api/model/:model/pack
//
// Get language-indepedent model metadata with packed range types.
func modelMetaPackHandler(w http.ResponseWriter, r *http.Request) {
doModelMetaHandler(w, r, true)
}
// Get language-indepedent model metadata.
// If isPack is true then return "packed" range types as [min, max] enum id's, not as full enum array.
// If multiple models with same name exist only one is returned.
func doModelMetaHandler(w http.ResponseWriter, r *http.Request, isPack bool) {
dn := getRequestParam(r, "model")
// if model digest-or-name is empty then return empty results
if dn == "" {
omppLog.Log("Error: invalid (empty) model digest and name")
http.Error(w, "Invalid (empty) model digest and name", http.StatusBadRequest)
return
}
// find model metadata in catalog and write to output stream
m, err := theCatalog.ModelMetaByDigestOrName(dn)
if err != nil {
omppLog.Log("Error: model digest or name not found: ", dn)
http.Error(w, "Model digest or name not found"+": "+dn, http.StatusBadRequest)
return
}
// ranges are stored as "packed" [min, max] enum id's
if isPack {
jsonResponse(w, r, m) // response with "packed" metatada
return
}
// else: "unpack" range types during json marshal
mcp := copyModelMetaToUnpack(m)
jsonResponse(w, r, mcp)
}
// return language-specific model metadata:
//
// GET /api/model/:model/text-all
//
// Model digest-or-name must specified, if multiple models with same name exist only one is returned.
// Text rows returned in all languages.
func modelAllTextHandler(w http.ResponseWriter, r *http.Request) {
dn := getRequestParam(r, "model")
// find model metadata in catalog
m, err := theCatalog.ModelMetaByDigestOrName(dn)
if err != nil {
omppLog.Log("Error at model metadata search: ", dn, ": ", err.Error())
http.Error(w, err.Error(), http.StatusInternalServerError)
return
}
// find model language-specific metadata by digest
t, err := theCatalog.ModelMetaAllTextByDigestOrName(m.Model.Digest)
if err != nil {
omppLog.Log("Error at model language-specific metadata search: ", dn, ": ", err.Error())
http.Error(w, err.Error(), http.StatusInternalServerError)
return
}
// "unpack" range types during json marshal
// copy of ModelMeta, using alias for TypeMeta to do a special range type marshaling
mcp := copyModelMetaToUnpack(m)
mf := struct {
*modelMetaUnpack // model metadata db rows, language-neutral portion of it
*db.ModelTxtMeta // language-specific portion of model metadata db rows
}{
modelMetaUnpack: mcp,
ModelTxtMeta: t,
}
jsonResponse(w, r, mf)
}
// return list of model langauages:
//
// GET /api/model/:model/lang-list
//
// Model digest-or-name must specified, if multiple models with same name exist only one is returned.
func langListHandler(w http.ResponseWriter, r *http.Request) {
dn := getRequestParam(r, "model")
m, _ := theCatalog.LangListByDigestOrName(dn)
jsonResponse(w, r, m)
}
// return list of model "words": arrays of rows from lang_word and model_word db tables.
//
// GET /api/model/:model/word-list
// GET /api/model/:model/word-list/lang/:lang
//
// Model digest-or-name must specified, if multiple models with same name exist only one is returned.
// If optional lang specified then result in that language else in browser language or model default.
func wordListHandler(w http.ResponseWriter, r *http.Request) {
dn := getRequestParam(r, "model")
rqLangTags := getRequestLang(r, "lang") // get optional language argument and languages accepted by browser
wl, _ := theCatalog.WordListByDigestOrName(dn, rqLangTags)
jsonResponse(w, r, wl)
}
// return profile db rows by model digest-or-name and profile name:
//
// GET /api/model/:model/profile/:profile
//
// If no such profile exist in database then empty result returned.
func modelProfileHandler(w http.ResponseWriter, r *http.Request) {
dn := getRequestParam(r, "model")
profile := getRequestParam(r, "profile")
p, _ := theCatalog.ModelProfileByName(dn, profile)
jsonResponse(w, r, p)
}
// return profile db rows by model digest-or-name:
//
// GET /api/model/:model/profile-list
//
// This is a list of profiles from model database, it is not a "model" profile(s).
// There is no explicit link between profile and model, profile can be applicable to multiple models.
func modelProfileListHandler(w http.ResponseWriter, r *http.Request) {
dn := getRequestParam(r, "model")
pl, _ := theCatalog.ProfileNamesByDigestOrName(dn)
jsonResponse(w, r, pl)
}
// runListHandler return list of run_lst db rows by model digest-or-name:
// GET /api/model/:model/run-list
// If multiple models with same name exist only one is returned.
func runListHandler(w http.ResponseWriter, r *http.Request) {
dn := getRequestParam(r, "model")
rpl, _ := theCatalog.RunPubList(dn)
jsonResponse(w, r, rpl)
}
// return list of run_lst and run_txt db rows by model digest-or-name:
//
// GET /api/model/:model/run-list/text
// GET /api/model/:model/run-list/text/lang/:lang
//
// If multiple models with same name exist only one is returned.
// If optional lang specified then result in that language else in browser language.
func runListTextHandler(w http.ResponseWriter, r *http.Request) {
dn := getRequestParam(r, "model")
rqLangTags := getRequestLang(r, "lang") // get optional language argument and languages accepted by browser
rpl, _ := theCatalog.RunListText(dn, rqLangTags)
jsonResponse(w, r, rpl)
}
// return run_lst db row by model digest-or-name and run digest-or-stamp-or-name:
//
// GET /api/model/:model/run/:run/status
//
// If multiple models with same name exist then result is undefined.
// If multiple runs with same stamp or name exist then result is undefined.
// If no such run exist in database then empty result returned.
func runStatusHandler(w http.ResponseWriter, r *http.Request) {
dn := getRequestParam(r, "model")
rdsn := getRequestParam(r, "run")
rst, _ := theCatalog.RunStatus(dn, rdsn)
jsonResponse(w, r, rst)
}
// return list run_lst db rows by model digest-or-name and run digest-or-stamp-or-name:
//
// GET /api/model/:model/run/:run/status/list
//
// If no such run exist in database then empty result returned.
func runStatusListHandler(w http.ResponseWriter, r *http.Request) {
dn := getRequestParam(r, "model")
rdsn := getRequestParam(r, "run")
rst, _ := theCatalog.RunStatusList(dn, rdsn)
jsonResponse(w, r, rst)
}
// return first run_lst db row by model digest-or-name:
//
// GET /api/model/:model/run/status/first
//
// If multiple models or runs with same name exist only one is returned.
// If no run exist in database then empty result returned.
func firstRunStatusHandler(w http.ResponseWriter, r *http.Request) {
dn := getRequestParam(r, "model")
rst, _ := theCatalog.FirstOrLastRunStatus(dn, true, false)
jsonResponse(w, r, rst)
}
// return last run_lst db row by model digest-or-name:
//
// GET /api/model/:model/run/status/last
//
// If multiple models or runs with same name exist only one is returned.
// If no run exist in database then empty result returned.
func lastRunStatusHandler(w http.ResponseWriter, r *http.Request) {
dn := getRequestParam(r, "model")
rst, _ := theCatalog.FirstOrLastRunStatus(dn, false, false)
jsonResponse(w, r, rst)
}
// return last compeleted run_lst db row by model digest-or-name:
//
// GET /api/model/:model/run/status/last-completed
//
// Run completed if run status one of: s=success, x=exit, e=error
// If multiple models or runs with same name exist only one is returned.
// If no run exist in database then empty result returned.
func lastCompletedRunStatusHandler(w http.ResponseWriter, r *http.Request) {
dn := getRequestParam(r, "model")
rst, _ := theCatalog.FirstOrLastRunStatus(dn, false, true)
jsonResponse(w, r, rst)
}
// return run metadata: run_lst, run_options, run_progress, run_parameter db rows
// by model digest-or-name and digest-or-stamp-or-name:
//
// GET /api/model/:model/run/:run
//
// If multiple models with same name exist then result is undefined.
// If multiple runs with same stamp or name exist then result is undefined.
func runFullHandler(w http.ResponseWriter, r *http.Request) {
dn := getRequestParam(r, "model")
rdsn := getRequestParam(r, "run")
rp, _ := theCatalog.RunFull(dn, rdsn)
jsonResponse(w, r, rp)
}
// return full run metadata: run_lst, run_options, run_progress, run_parameter db rows
// and corresponding text db rows from run_txt and run_parameter_txt tables
// by model digest-or-name and digest-or-stamp-or-name and language:
//
// GET /api/model/:model/run/:run/text
// GET /api/model/:model/run/:run/text/lang/:lang
//
// If multiple models with same name exist then result is undefined.
// If multiple runs with same stamp or name exist then result is undefined.
// It does not return non-completed runs (run in progress).
// Run completed if run status one of: s=success, x=exit, e=error.
// If optional lang specified then result in that language else in browser language.
func runTextHandler(w http.ResponseWriter, r *http.Request) {
dn := getRequestParam(r, "model")
rdsn := getRequestParam(r, "run")
rqLangTags := getRequestLang(r, "lang") // get optional language argument and languages accepted by browser
rp, _ := theCatalog.RunTextFull(dn, rdsn, false, rqLangTags)
jsonResponse(w, r, rp)
}
// return full run metadata: run_lst, run_options, run_progress, run_parameter db rows
// and corresponding text db rows from run_txt and run_parameter_txt tables
// by model digest-or-name and digest-or-stamp-or-name:
//
// GET /api/model/:model/run/:run/text-all
//
// If multiple models with same name exist then result is undefined.
// If multiple runs with same stamp or name exist then result is undefined.
// It does not return non-completed runs (run in progress).
// Run completed if run status one of: s=success, x=exit, e=error.
// Text rows returned in all languages.
func runAllTextHandler(w http.ResponseWriter, r *http.Request) {
dn := getRequestParam(r, "model")
rdsn := getRequestParam(r, "run")
rp, _ := theCatalog.RunTextFull(dn, rdsn, true, nil)
jsonResponse(w, r, rp)
}
// return list of workset_lst db rows by model digest-or-name:
//
// GET /api/model/:model/workset-list
//
// If multiple models with same name exist only one is returned.
func worksetListHandler(w http.ResponseWriter, r *http.Request) {
dn := getRequestParam(r, "model")
wpl, _ := theCatalog.WorksetPubList(dn)
jsonResponse(w, r, wpl)
}
// return list of workset_lst and workset_txt db rows by model digest-or-name:
//
// GET /api/model/:model/workset-list/text
// GET /api/model/:model/workset-list/text/lang/:lang
//
// If multiple models with same name exist only one is returned.
// If optional lang specified then result in that language else in browser language.
func worksetListTextHandler(w http.ResponseWriter, r *http.Request) {
dn := getRequestParam(r, "model")
rqLangTags := getRequestLang(r, "lang") // get optional language argument and languages accepted by browser
wpl, _ := theCatalog.WorksetListText(dn, rqLangTags)
jsonResponse(w, r, wpl)
}
// return workset_lst db row by model digest-or-name and workset name:
//
// GET /api/model/:model/workset/:set/status
//
// If multiple models with same name exist only one is returned.
// If no such workset exist in database then empty result returned.
func worksetStatusHandler(w http.ResponseWriter, r *http.Request) {
dn := getRequestParam(r, "model")
wsn := getRequestParam(r, "set")
ws, ok := theCatalog.WorksetByName(dn, wsn)
if !ok {
omppLog.Log("Warning workset status not found: ", dn, ": ", wsn)
}
jsonResponse(w, r, ws) // return non-empty workset_lst row if no errors and workset exist
}
// return workset_lst db row of default workset by model digest-or-name:
//
// GET /api/model/:model/workset/status/default
//
// If multiple models with same name exist only one is returned.
// If no default workset exist in database then empty result returned.
func worksetDefaultStatusHandler(w http.ResponseWriter, r *http.Request) {
dn := getRequestParam(r, "model")
wst, _ := theCatalog.WorksetDefaultStatus(dn)
jsonResponse(w, r, wst)
}
// return full workset metadata by model digest-or-name and workset name:
//
// GET /api/model/:model/workset/:set/text
// GET /api/model/:model/workset/:set/text/lang/:lang
//
// If multiple models with same name exist only one is returned.
// If no such workset exist in database then empty result returned.
// If optional lang specified then result in that language else in browser language.
func worksetTextHandler(w http.ResponseWriter, r *http.Request) {
dn := getRequestParam(r, "model")
wsn := getRequestParam(r, "set")
rqLangTags := getRequestLang(r, "lang") // get optional language argument and languages accepted by browser
wp, _, _ := theCatalog.WorksetTextFull(dn, wsn, false, rqLangTags)
jsonResponse(w, r, wp)
}
// return full workset metadata by model digest-or-name and workset name:
//
// GET /api/model/:model/workset/:set/text-all
//
// If multiple models with same name exist only one is returned.
// If no such workset exist in database then empty result returned.
// Text rows returned in all languages.
func worksetAllTextHandler(w http.ResponseWriter, r *http.Request) {
dn := getRequestParam(r, "model")
wsn := getRequestParam(r, "set")
wp, _, _ := theCatalog.WorksetTextFull(dn, wsn, true, nil)
jsonResponse(w, r, wp)
}
// return list of task_lst db rows by model digest-or-name:
//
// GET /api/model/:model/task-list
//
// If multiple models with same name exist only one is returned.
func taskListHandler(w http.ResponseWriter, r *http.Request) {
dn := getRequestParam(r, "model")
rpl, _ := theCatalog.TaskList(dn)
jsonResponse(w, r, rpl)
}
// return list of task_lst and task_txt db rows by model digest-or-name:
//
// GET /api/model/:model/task-list/text
// GET /api/model/:model/task-list/text/lang/:lang
//
// If multiple models with same name exist only one is returned.
// If optional lang specified then result in that language else in browser language.
func taskListTextHandler(w http.ResponseWriter, r *http.Request) {
dn := getRequestParam(r, "model")
rqLangTags := getRequestLang(r, "lang") // get optional language argument and languages accepted by browser
tpl, _ := theCatalog.TaskListText(dn, rqLangTags)
jsonResponse(w, r, tpl)
}
// return task_lst row and task sets by model digest-or-name and task name:
//
// GET /api/model/:model/task/:task/sets
//
// If multiple models with same name exist only one is returned.
func taskSetsHandler(w http.ResponseWriter, r *http.Request) {
dn := getRequestParam(r, "model")
name := getRequestParam(r, "task")
tpl, _ := theCatalog.TaskSets(dn, name)
jsonResponse(w, r, tpl)
}
// return task run history from task_lst, task_run_lst, task_run_set tables by model digest-or-name and task name:
//
// GET /api/model/:model/task/:task/runs
//
// If multiple models with same name exist only one is returned.
// It does not return non-completed task runs (run in progress).
// Task run history may contain model runs and input sets (worksets) which are deleted or modified by user,
// there is no guaratntee model runs still exists or worksets contain same input parameter values
// as it was at the time of task run.
func taskRunsHandler(w http.ResponseWriter, r *http.Request) {
dn := getRequestParam(r, "model")
name := getRequestParam(r, "task")
tpl, _ := theCatalog.TaskRuns(dn, name)
jsonResponse(w, r, tpl)
}
// return task_run_lst db row by model digest-or-name, task name and task run stamp or run name:
//
// GET /api/model/:model/task/:task/run-status/run/:run
//
// If multiple models or runs with same name exist only one is returned.
// If no such task or run exist in database then empty result returned.
func taskRunStatusHandler(w http.ResponseWriter, r *http.Request) {
dn := getRequestParam(r, "model")
tn := getRequestParam(r, "task")
trsn := getRequestParam(r, "run")
rst, _ := theCatalog.TaskRunStatus(dn, tn, trsn)
jsonResponse(w, r, rst)
}
// return task_run_lst db row by model digest-or-name, task name and task run stamp or run name:
//
// GET /api/model/:model/task/:task/run-status/list/:run
//
// If no such task or run exist in database then empty result returned.
func taskRunStatusListHandler(w http.ResponseWriter, r *http.Request) {
dn := getRequestParam(r, "model")
tn := getRequestParam(r, "task")
trsn := getRequestParam(r, "run")
rst, _ := theCatalog.TaskRunStatusList(dn, tn, trsn)
jsonResponse(w, r, rst)
}
// return first task_run_lst db row by model digest-or-name and task name:
//
// GET /api/model/:model/task/:task/run-status/first
//
// If multiple models with same name exist only one is returned.
// If no such task or run exist in database then empty result returned.
func firstTaskRunStatusHandler(w http.ResponseWriter, r *http.Request) {
dn := getRequestParam(r, "model")
tn := getRequestParam(r, "task")
rst, _ := theCatalog.FirstOrLastTaskRunStatus(dn, tn, true, false)
jsonResponse(w, r, rst)
}
// return last task_run_lst db row by model digest-or-name and task name:
//
// GET /api/model/:model/task/:task/run-status/last
//
// If multiple models with same name exist only one is returned.
// If no such task or run exist in database then empty result returned.
func lastTaskRunStatusHandler(w http.ResponseWriter, r *http.Request) {
dn := getRequestParam(r, "model")
tn := getRequestParam(r, "task")
rst, _ := theCatalog.FirstOrLastTaskRunStatus(dn, tn, false, false)
jsonResponse(w, r, rst)
}
// return last compeleted task_run_lst db row by model digest-or-name and task name:
//
// GET /api/model/:model/task/:task/run-status/last-completed
//
// task completed if task status one of: s=success, x=exit, e=error
// If multiple models with same name exist only one is returned.
// If no such task or run exist in database then empty result returned.
func lastCompletedTaskRunStatusHandler(w http.ResponseWriter, r *http.Request) {
dn := getRequestParam(r, "model")
tn := getRequestParam(r, "task")
rst, _ := theCatalog.FirstOrLastTaskRunStatus(dn, tn, false, true)
jsonResponse(w, r, rst)
}
// return full task metadata, description, notes, run history by model digest-or-name and task name
// from db-tables: task_lst, task_txt, task_set, task_run_lst, task_run_set and also from workset_txt, run_txt.
//
// GET /api/model/:model/task/:task/text
// GET /api/model/:model/task/:task/text/lang/:lang
//
// If multiple models with same name exist only one is returned.
// It does not return non-completed task runs (run in progress).
// Run completed if run status one of: s=success, x=exit, e=error.
// It also return description and notes for all input worksets, task run(s) workset and model runs.
// If optional lang specified then result in that language else in browser language.
func taskTextHandler(w http.ResponseWriter, r *http.Request) {
dn := getRequestParam(r, "model")
tn := getRequestParam(r, "task")
rqLangTags := getRequestLang(r, "lang") // get optional language argument and languages accepted by browser
tp, trs, _ := theCatalog.TaskTextFull(dn, tn, false, rqLangTags)
jsonResponse(w, r,
&struct {
Task *db.TaskPub
Txt *db.TaskRunSetTxt
}{Task: tp, Txt: trs})
}
// return full task metadata, description, notes, run history by model digest-or-name and task name
// from db-tables: task_lst, task_txt, task_set, task_run_lst, task_run_set and also from workset_txt, run_txt.
//
// GET /api/model/:model/task/:task/text-all
//
// If multiple models with same name exist only one is returned.
// It does not return non-completed runs (run in progress).
// Run completed if run status one of: s=success, x=exit, e=error.
// It also return description and notes for all input worksets, task run(s) workset and model runs.
// Text rows returned in all languages.
func taskAllTextHandler(w http.ResponseWriter, r *http.Request) {
dn := getRequestParam(r, "model")
tn := getRequestParam(r, "task")
tp, trs, _ := theCatalog.TaskTextFull(dn, tn, true, nil)
jsonResponse(w, r,
&struct {
Task *db.TaskPub
Txt *db.TaskRunSetTxt
}{Task: tp, Txt: trs})
}