@datagrok/compute 0.1.0 → 0.2.5
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +11 -100
- package/files/model-templates.json +27 -0
- package/package.json +9 -6
- package/scripts/Fab Arm Exchange.py +3 -1
- package/scripts/Heat Exchange.js +3 -1
- package/scripts/IntervalsFromECG.py +24 -0
- package/scripts/{Logistic map.js → Logistic Map.js } +3 -2
- package/scripts/{Lorenz attractor.js → Lorenz Attractor.js } +3 -2
- package/scripts/{Lotka-Volterra Model.js → Lotka-Volterra.js} +3 -2
- package/scripts/Maximal Volume.R +36 -20
- package/scripts/pMax.js +163 -0
- package/scripts/pkpd.R +1 -0
- package/scripts/popPK.R +10 -6
- package/scripts/trig.js +1 -0
- package/scripts/vMaxJS.js +115 -0
- package/src/export-funccall.ts +46 -1
- package/src/help.md +3 -0
- package/src/model-catalog-view.ts +9 -12
- package/src/model-handler.ts +22 -7
- package/src/onboard-model.ts +54 -4
- package/src/outliers-selection.ts +77 -40
- package/src/package.ts +112 -14
- package/webpack.config.js +1 -0
- package/scripts/AT-COE.py +0 -8
- package/scripts/Chemometric.py +0 -16
- package/scripts/Heat Transfer Cooling.py +0 -8
- package/scripts/High-titer field.py +0 -8
- package/scripts/pMax.py +0 -8
package/src/package.ts
CHANGED
|
@@ -7,7 +7,9 @@ import {selectOutliersManually} from './outliers-selection';
|
|
|
7
7
|
import {exportFuncCall} from './export-funccall';
|
|
8
8
|
import {_functionParametersGrid} from './function-views/function-parameters-grid';
|
|
9
9
|
import {ModelCatalogView} from './model-catalog-view';
|
|
10
|
+
import wu from 'wu';
|
|
10
11
|
|
|
12
|
+
let initCompleted: boolean = false;
|
|
11
13
|
export const _package = new DG.Package();
|
|
12
14
|
|
|
13
15
|
//name: test
|
|
@@ -15,18 +17,6 @@ export function test() {
|
|
|
15
17
|
grok.shell.info(_package.webRoot);
|
|
16
18
|
}
|
|
17
19
|
|
|
18
|
-
//tags: init, autostart
|
|
19
|
-
export function init() {
|
|
20
|
-
console.log('init');
|
|
21
|
-
DG.ObjectHandler.register(new ModelHandler());
|
|
22
|
-
}
|
|
23
|
-
|
|
24
|
-
//name: Model Catalog
|
|
25
|
-
//tags: app
|
|
26
|
-
export function modelCatalog() {
|
|
27
|
-
grok.shell.addView(new ModelCatalogView());
|
|
28
|
-
}
|
|
29
|
-
|
|
30
20
|
//name: manualOutlierDetectionDialog
|
|
31
21
|
//input: dataframe inputData
|
|
32
22
|
//output: dataframe augmentedInput
|
|
@@ -35,7 +25,7 @@ export async function manualOutlierSelectionDialog(inputData: DG.DataFrame) {
|
|
|
35
25
|
const call = grok.functions.getCurrentCall();
|
|
36
26
|
|
|
37
27
|
const IS_OUTLIER_COL_LABEL = 'isOutlier';
|
|
38
|
-
const OUTLIER_REASON_COL_LABEL = '
|
|
28
|
+
const OUTLIER_REASON_COL_LABEL = 'Rationale';
|
|
39
29
|
|
|
40
30
|
if (call.options['interactive']) {
|
|
41
31
|
const {augmentedInput, editedInput} = await selectOutliersManually(inputData);
|
|
@@ -77,4 +67,112 @@ export function hof() {
|
|
|
77
67
|
let f: DG.Func = DG.Func.byName('Sin');
|
|
78
68
|
let v: DG.View = functionParametersGrid(f);
|
|
79
69
|
grok.shell.addView(v);
|
|
80
|
-
}
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
//name: renderRestPanel
|
|
73
|
+
//input: func func
|
|
74
|
+
//output: widget panel
|
|
75
|
+
export async function renderRestPanel(func: DG.Func): Promise<DG.Widget> {
|
|
76
|
+
let params: object = {};
|
|
77
|
+
func.inputs.forEach((i) => (<any>params)[i.name] = null);
|
|
78
|
+
let curl = `
|
|
79
|
+
curl --location --request POST '${(<any>grok.settings).apiUrl}/v1/func/${func.nqName}/run' \\
|
|
80
|
+
--header 'Authorization: ${getCookie('auth')}' \\
|
|
81
|
+
--header 'Content-Type: application/json' \\
|
|
82
|
+
--data-raw '${JSON.stringify(params)}'`
|
|
83
|
+
let js = `
|
|
84
|
+
var myHeaders = new Headers();
|
|
85
|
+
myHeaders.append("Authorization", "${getCookie('auth')}");
|
|
86
|
+
myHeaders.append("Content-Type", "application/json");
|
|
87
|
+
|
|
88
|
+
var raw = JSON.stringify(${JSON.stringify(params)});
|
|
89
|
+
|
|
90
|
+
var requestOptions = {
|
|
91
|
+
method: 'POST',
|
|
92
|
+
headers: myHeaders,
|
|
93
|
+
body: raw,
|
|
94
|
+
redirect: 'follow'
|
|
95
|
+
};
|
|
96
|
+
|
|
97
|
+
fetch("${(<any>grok.settings).apiUrl}/v1/func/${func.nqName}/run", requestOptions)
|
|
98
|
+
.then(response => response.text())
|
|
99
|
+
.then(result => console.log(result))
|
|
100
|
+
.catch(error => console.log('error', error));`
|
|
101
|
+
let tabs = ui.tabControl({'CURL': ui.div([ui.divText(curl)]), 'JS': ui.div([ui.divText(js)])})
|
|
102
|
+
return DG.Widget.fromRoot(tabs.root);
|
|
103
|
+
}
|
|
104
|
+
|
|
105
|
+
function getCookie(name: string): string | undefined{
|
|
106
|
+
let matches = document.cookie.match(new RegExp(
|
|
107
|
+
"(?:^|; )" + name.replace(/([\.$?*|{}\(\)\[\]\\\/\+^])/g, '\\$1') + "=([^;]*)"
|
|
108
|
+
));
|
|
109
|
+
return matches ? decodeURIComponent(matches[1]) : undefined;
|
|
110
|
+
}
|
|
111
|
+
|
|
112
|
+
//tags: init, autostart
|
|
113
|
+
export function init() {
|
|
114
|
+
if (initCompleted)
|
|
115
|
+
return;
|
|
116
|
+
DG.ObjectHandler.register(new ModelHandler());
|
|
117
|
+
|
|
118
|
+
grok.events.onAccordionConstructed.subscribe((acc: DG.Accordion) => {
|
|
119
|
+
const ent = acc.context;
|
|
120
|
+
if (ent == null)
|
|
121
|
+
return;
|
|
122
|
+
if (ent.type != 'script')
|
|
123
|
+
return;
|
|
124
|
+
let restPane = acc.getPane('REST');
|
|
125
|
+
if (!restPane)
|
|
126
|
+
acc.addPane('REST', () => ui.wait(async () => (await renderRestPanel(ent)).root));
|
|
127
|
+
});
|
|
128
|
+
|
|
129
|
+
let modelsList = ui.waitBox(async () => {
|
|
130
|
+
let models = await grok.dapi.scripts
|
|
131
|
+
.filter('#model')
|
|
132
|
+
.list();
|
|
133
|
+
let list = ui.divV(models.map((model) => ui.render(model, {onClick: (_) => ModelHandler.openModel(model)})), {style: {lineHeight: '165%'}});
|
|
134
|
+
|
|
135
|
+
let props = ['domain', 'modality'];
|
|
136
|
+
let mtree: { model: DG.Func}[] = models.map((m) => { return {model: m}});
|
|
137
|
+
mtree.forEach((m: {model: DG.Func}) => {
|
|
138
|
+
props.forEach((k) => {
|
|
139
|
+
(<any>m)[k] = m.model.options[k];
|
|
140
|
+
});
|
|
141
|
+
});
|
|
142
|
+
|
|
143
|
+
let tree = DG.TreeViewNode.fromItemCategories(mtree,
|
|
144
|
+
props,
|
|
145
|
+
{ itemToElement: (x) => ui.render(x.model, {onClick: (_) => ModelHandler.openModel(x.model)}), itemToValue: (x) => x.model, removeEmpty: true }).root
|
|
146
|
+
|
|
147
|
+
return ui.tabControl({
|
|
148
|
+
'LIST': list,
|
|
149
|
+
'TREE': tree
|
|
150
|
+
}).root;
|
|
151
|
+
});
|
|
152
|
+
|
|
153
|
+
grok.events.onViewAdding.subscribe((v: DG.View) => {
|
|
154
|
+
if (v instanceof DG.FunctionView && v.func?.hasTag("model")) {
|
|
155
|
+
let modelsView = wu(grok.shell.views).find((v) => v.parentCall?.func.name == 'modelCatalog');
|
|
156
|
+
if (modelsView != undefined) {
|
|
157
|
+
v.parentCall = modelsView!.parentCall;
|
|
158
|
+
v.parentView = modelsView!;
|
|
159
|
+
v.toolbox = modelsList;
|
|
160
|
+
}
|
|
161
|
+
}
|
|
162
|
+
});
|
|
163
|
+
|
|
164
|
+
initCompleted = true;
|
|
165
|
+
}
|
|
166
|
+
|
|
167
|
+
//name: Model Catalog
|
|
168
|
+
//tags: app
|
|
169
|
+
export function modelCatalog() {
|
|
170
|
+
/* let view = new DG.MultiView({
|
|
171
|
+
viewFactories: {
|
|
172
|
+
'Models': {factory: () => new ModelCatalogView(), allowClose: false}
|
|
173
|
+
}
|
|
174
|
+
});*/
|
|
175
|
+
let view = new ModelCatalogView();
|
|
176
|
+
view.name = 'Models';
|
|
177
|
+
grok.shell.addView(view);
|
|
178
|
+
}
|
package/webpack.config.js
CHANGED
package/scripts/AT-COE.py
DELETED
package/scripts/Chemometric.py
DELETED
|
@@ -1,16 +0,0 @@
|
|
|
1
|
-
#name: Chemometric
|
|
2
|
-
#language: python
|
|
3
|
-
#input: double a
|
|
4
|
-
#input: double b
|
|
5
|
-
#output: dataframe c1
|
|
6
|
-
#output: dataframe c2
|
|
7
|
-
#output: int d
|
|
8
|
-
#output: double e
|
|
9
|
-
#tags: model
|
|
10
|
-
|
|
11
|
-
d = a + b
|
|
12
|
-
e = a / b
|
|
13
|
-
d1 = {'col1': [1, 2], 'col2': [3, 4]}
|
|
14
|
-
d2 = {'col1': [1, 5], 'col2': [3, 6]}
|
|
15
|
-
c1 = pd.DataFrame(data = d1)
|
|
16
|
-
c2 = pd.DataFrame(data = d2)
|