@datagrok/compute 0.7.3 → 0.8.3

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/package.json CHANGED
@@ -1,8 +1,8 @@
1
1
  {
2
2
  "name": "@datagrok/compute",
3
3
  "friendlyName": "Compute",
4
- "version": "0.7.3",
5
- "description": "",
4
+ "version": "0.8.3",
5
+ "description": "Provides additional analytical and UI blocks for [Datagrok scientific computing](../../help/compute/compute.md)",
6
6
  "repository": {
7
7
  "type": "git",
8
8
  "url": "https://github.com/datagrok-ai/public.git",
@@ -12,7 +12,7 @@
12
12
  "@datagrok-libraries/utils": "^0.4.0",
13
13
  "cash-dom": "latest",
14
14
  "codemirror": "^5.64.0",
15
- "datagrok-api": "^0.151.0",
15
+ "datagrok-api": "^1.0.0",
16
16
  "dayjs": "latest",
17
17
  "exceljs": "^4.3.0",
18
18
  "file-saver": "^2.0.5",
@@ -1,8 +1,9 @@
1
1
  #name: Fab Arm Exchange
2
2
  #language: python
3
- #tags: model, simulation
4
- #meta.modality: Antibody
5
- #meta.domain: Manufacturing
3
+ #tags: antibody-eng
4
+ #meta.department: BTDS
5
+ #meta.status: Upstream
6
+ #meta.group: Bioengineering process
6
7
  #input: double meaConcentration = 60 {category:FAE Reaction Parameters; units:mM; caption:2-MEA Concentration} [2-MEA Concentration]
7
8
  #input: double phOfFaeReaction = 7.5 {category:FAE Reaction Parameters; caption:pH of FAE Reaction} [pH of FAE Reaction]
8
9
  #input: double faeReactionTime = 3 {category:FAE Reaction Parameters; units:hr; caption:FAE Reaction Time} [FAE Reaction Time]
@@ -1,7 +1,6 @@
1
1
  //name: Heat Exchange
2
2
  //language: javascript
3
- //tags: model, simulation
4
- //meta.modality: Small molecule
3
+ //tags: simulation
5
4
  //input: int len = 1000
6
5
  //input: double k = 1.2
7
6
  //output: dataframe simulation {viewer: Line Chart(multiAxis: "true")}
@@ -9,6 +8,7 @@
9
8
  //output: double finalSaturation
10
9
  //output: double finalConcentration
11
10
  //meta.domain: Manufacturing
11
+ //meta.modality: Small molecule
12
12
 
13
13
  function sigmoid(z) {
14
14
  return 1 / (1 + Math.exp(-z));
@@ -1,7 +1,6 @@
1
1
  #name: IntervalsFromECG
2
2
  #description: Identify the beats in an ECG signal and compute the IBIs
3
3
  #language: python
4
- #tags: model
5
4
  #input: double samplingFrequency = 2048
6
5
  #input: int bpmMax = 120 [Maximal expected heart rate (in beats per minute): (1 < bpm_max <= 400)]
7
6
  #input: double delta = 0 [Threshold for the peak detection. By default it is computed from the signal (adaptive thresholding)]
@@ -1,5 +1,5 @@
1
1
  //name: Logistic Map
2
- //tags: model, simulation
2
+ //tags: simulation
3
3
  //description: Archetypal example of how complex, chaotic behaviour can arise from very simple non-linear dynamical equations.
4
4
  //language: javascript
5
5
  //input: int iterations = 1000 [Number of iterations per point]
@@ -1,5 +1,5 @@
1
1
  //name: Lorenz Attractor
2
- //tags: model, simulation
2
+ //tags: simulation
3
3
  //meta.domain: Nonlinear dynamics
4
4
  //description: Set of chaotic solutions of the system for weather prediction. It illustrates the phenomenon known as the Butterfly effect or (more technically) sensitive dependence on initial conditions
5
5
  //language: javascript
@@ -1,5 +1,5 @@
1
1
  //name: Lotka-Volterra
2
- //tags: model, simulation
2
+ //tags: simulation
3
3
  //meta.domain: Nonlinear dynamics
4
4
  //description: Model describes the dynamics of biological systems in which two species interact, one as a predator and the other as prey.
5
5
  //language: javascript
@@ -14,6 +14,7 @@
14
14
  //input: double timeStop = 18
15
15
  //output: dataframe df {viewer: Line Chart(x: "Time", multiAxis: "true", title: "Lotka-Volterra Model")}
16
16
 
17
+
17
18
  function sumArrays(...arrays) {
18
19
  return Array.from({ length: 2 })
19
20
  .map((_, i) => arrays
@@ -1,7 +1,6 @@
1
1
  #name: Vmax
2
2
  #description: Predict the minimum filter size required for the separation of effluent from bioreactors, given the constraints of batch size and total batch time based on a training dataset of time vs filtrate volume for a given filter type, filter area and pressure
3
3
  #language: r
4
- #tags: model
5
4
  #input: dataframe test_data {editor: Compute:manualOutlierSelectionDialog; editor-button: Outliers...}
6
5
  #input: double test_area = 3.5 {caption: Filter Area; units: cm²} [Filter area]
7
6
  #input: double vbatch = 25 {caption: VBatch; units: L} [Desired batch size to process]
package/scripts/pkpd.R CHANGED
@@ -12,7 +12,6 @@
12
12
  #input: double effect = 8 {category: PD parameters} [EC50]
13
13
  #output: graphics PKPD
14
14
  #output: double Cmax {units: nM}
15
- #tags: model
16
15
  #meta.domain: PKPD
17
16
 
18
17
  require("ggplot2")
package/scripts/popPK.R CHANGED
@@ -10,7 +10,6 @@
10
10
  #input: double perV = 30 {category: PK parameters} [peripheral compartment volume]
11
11
  #input: double interRate = 1 {category: PK parameters} [intercompartmental rate]
12
12
  #output: graphics popPK
13
- #tags: model
14
13
  #meta.domain: PKPD
15
14
 
16
15
  require("ggplot2")
package/scripts/trig.js CHANGED
@@ -1,7 +1,6 @@
1
1
  //name: trig
2
2
  //description: Returns sin, cos, and tan
3
3
  //language: javascript
4
- //tags: model
5
4
  //input: double x
6
5
  //output: double sin
7
6
  //output: double cos
package/scripts/vmax.js CHANGED
@@ -1,7 +1,9 @@
1
1
  //name: Vmax
2
2
  //description: Predict the minimum filter size required for the separation of effluent from bioreactors, given the constraints of batch size and total batch time based on a training dataset of time vs filtrate volume for a given filter type, filter area and pressure
3
3
  //language: javascript
4
- //tags: model, filtration
4
+ //tags: filtration, scale-up
5
+ //meta.department: BTDS
6
+ //meta.status: Upstream
5
7
  //input: dataframe inputTable {caption: Input table; viewer: OutliersSelectionViewer(block: 25) | Scatter Plot(y: "t/V (hr/(L/m²))", block: 75, filter: "!${isOutlier}", showFilteredOutPoints: "true", filteredOutRowsColor: 4293991195, showRegressionLine: "true", markers: "isOutlier", lassoTool: "true", legendVisibility: "Never", filterByZoom: "false")}
6
8
  //input: dataframe reportingParameters {caption: Reporting parameters; viewer: Grid()}
7
9
  //input: double testFilterArea = 3.5 {caption: Test filter area; units: cm²} [Test filter area]
@@ -16,7 +18,7 @@
16
18
  //output: dataframe recommendations {viewer: Grid(block: 25, showColumnLabels: false, showRowHeader: false); caption: Recommendations; category: OUTPUT}
17
19
  //output: dataframe sampleCharacteristics {viewer: Grid(block: 25, showColumnLabels: false, showRowHeader: false); caption: Sample characteristics; category: OUTPUT}
18
20
  //output: dataframe filter {viewer: Grid(block: 25, showColumnLabels: false, showRowHeader: false); caption: Filter; category: OUTPUT}
19
-
21
+ //editor: Compute:ComputationView
20
22
  // inputTable = grok.shell.tables[0]; reportingParameters = grok.shell.tables[1];
21
23
  // testFilterArea = 3.5; desiredVolumeOfBatch = 25; desiredProcessTime = 0.5; sf = 1.5;
22
24
 
@@ -1,8 +1,8 @@
1
1
  //name: wrapper
2
2
  //language: javascript
3
3
  //output: view v
4
- //tags: model
5
4
  //meta.domain: math
5
+ //meta.direction: up
6
6
 
7
7
  v = grok.shell.newView('Wrapper', [ui.div(['hello world'])]);
8
8
  // here, launch the app
@@ -0,0 +1,61 @@
1
+ .model-catalog-view .d4-gallery-card.entity-model i {
2
+ height: 64px;
3
+ width: 64px;
4
+ position: initial;
5
+ flex-shrink: 0;
6
+ }
7
+
8
+ .model-catalog-view .d4-gallery-card.entity-model .d4-link-label i.grok-icon + label {
9
+ margin-left: 6px;
10
+ align-items: center;
11
+ display: inline-flex;
12
+ white-space: normal;
13
+ }
14
+
15
+ .model-catalog-view .d4-gallery-card.entity-model {
16
+ padding: 0 8px;
17
+ align-items: center;
18
+ display: flex;
19
+ margin: 0;
20
+ height: 94px;
21
+ }
22
+
23
+ .model-catalog-view .grok-gallery-grid[mode="Brief"] .grok-gallery-grid {
24
+ flex-direction: row!important;
25
+ }
26
+
27
+ .model-catalog-view .grok-gallery-grid[mode="Brief"] .d4-link-label i.grok-icon {
28
+ width: 32px;
29
+ height: 32px;
30
+ position: initial;
31
+ }
32
+
33
+ .model-catalog-view .grok-gallery-grid[mode="Brief"] .d4-link-label label {
34
+ margin-left: 8px;
35
+ }
36
+
37
+ .model-catalog-view .grok-gallery-grid[mode="Brief"] .grok-gallery-grid .d4-link-label {
38
+ min-width: 250px;
39
+ margin-bottom: 9px;
40
+ color: var(--grey-6);
41
+ padding: 10px;
42
+ width: initial;
43
+ }
44
+
45
+ .model-catalog-view .d4-tree-view-root > .d4-tree-view-group-host > .d4-tree-view-group > .d4-tree-view-node {
46
+ font-size: 20px;
47
+ padding: 4px 0;
48
+ color: var(--grey-6);
49
+ }
50
+
51
+ .model-catalog-view .d4-tree-view-root > .d4-tree-view-group-host > .d4-tree-view-group > .d4-tree-view-group-host > .d4-tree-view-group > .d4-tree-view-node {
52
+ font-size: 16px;
53
+ padding: 4px 0;
54
+ color: var(--grey-6);
55
+ }
56
+
57
+ .model-catalog-view .d4-tree-view-root > .d4-tree-view-group-host > .d4-tree-view-group > .d4-tree-view-group-host > .d4-tree-view-group > .d4-tree-view-group-host > .d4-tree-view-group .d4-tree-view-node {
58
+ font-size: 14px;
59
+ padding: 4px 0;
60
+ color: var(--grey-6);
61
+ }
@@ -11,20 +11,29 @@ export class ModelCatalogView extends DG.CustomCardView {
11
11
  constructor() {
12
12
  super({dataSource: grok.dapi.functions, permanentFilter: '#model'});
13
13
 
14
+ this.root.classList.add('model-catalog-view');
14
15
  this.meta = new ModelHandler();
15
16
  this.name = 'Models';
16
17
  this.permanentFilter = '#model';
18
+ this.renderMode = DG.RENDER_MODE.BRIEF;
17
19
 
18
20
  this.objectType = 'Func';
19
21
  this.categoryFilters = {
20
- 'options.direction': 'Direction',
21
- 'tag': 'Tags',
22
- 'createdOn': 'Created',
23
- 'author.id': 'Author'
22
+ 'options.department': 'Department',
23
+ 'options.group': 'Group',
24
+ 'options.process': 'Process',
25
+ 'tag': 'Tags'
26
+ };
27
+
28
+ this.filters = {
29
+ 'All': '',
30
+ 'Favorites': 'starredBy = @current',
31
+ 'Used by me': 'usedBy = @current'
24
32
  };
25
33
  this.hierarchy = [
26
- 'options.direction',
27
- 'options.domain'
34
+ 'options.department',
35
+ 'options.group',
36
+ 'options.process'
28
37
  ];
29
38
  this.showTree = true;
30
39
  this.initRibbon();
@@ -32,14 +41,11 @@ export class ModelCatalogView extends DG.CustomCardView {
32
41
  }
33
42
 
34
43
  initRibbon() {
35
- this.setRibbonPanels([[ui.icons.add(() => onboardModel())]]);
44
+ this.setRibbonPanels([[ui.icons.sync(() => this.refresh())]]);
36
45
  }
37
46
 
38
47
  initMenu() {
39
48
  this.ribbonMenu
40
- .group('Models')
41
- .item('Add New...', () => onboardModel())
42
- .endGroup()
43
49
  .group('Help')
44
50
  .item('Compute Engine', () => window.open('https://github.com/datagrok-ai/public/tree/master/packages/Compute', '_blank'))
45
51
  .item('Developing Models', () => window.open('https://datagrok.ai/help/compute/scripting', '_blank'))
@@ -1,9 +1,7 @@
1
1
  import * as grok from 'datagrok-api/grok';
2
2
  import * as ui from 'datagrok-api/ui';
3
3
  import * as DG from 'datagrok-api/dg';
4
- import {ModelCatalogView} from "./model-catalog-view";
5
- import {TYPE} from "datagrok-api/dg";
6
- import {FunctionView} from '@datagrok-libraries/utils/src/function-view';
4
+ import wu from "wu";
7
5
 
8
6
  export class ModelHandler extends DG.ObjectHandler {
9
7
  get type() {
@@ -11,14 +9,11 @@ export class ModelHandler extends DG.ObjectHandler {
11
9
  }
12
10
 
13
11
  async getById(id: string): Promise<DG.Func> {
14
- console.log('id:', id);
15
12
  return await grok.dapi.functions.find(id);
16
13
  }
17
14
 
18
15
  async refresh(x: DG.Script): Promise<DG.Func> {
19
- let script = await this.getById(x.id);
20
- console.log('script:', script);
21
- return script;
16
+ return await this.getById(x.id);
22
17
  }
23
18
 
24
19
  getLanguageIcon(language: string) {
@@ -33,11 +28,24 @@ export class ModelHandler extends DG.ObjectHandler {
33
28
  }
34
29
 
35
30
  renderIcon(x: DG.Func, context: any = null): HTMLElement {
36
- return x instanceof DG.Script ? this.getLanguageIcon(x.language) : ui.iconImage(x.package.name, x.package.getIconUrl());
31
+ if (x instanceof DG.Script)
32
+ return this.getLanguageIcon(x.language);
33
+ let iconUrl = x.package.getIconUrl();
34
+ if (x.options['icon'] != null) {
35
+ let packagePathSegments = iconUrl.split('/');
36
+ packagePathSegments.pop();
37
+ packagePathSegments.push(x.options['icon']);
38
+ iconUrl = packagePathSegments.join('/')
39
+ }
40
+ return ui.iconImage(x.package.name, iconUrl);
37
41
  }
38
42
 
39
43
  renderMarkup(x: DG.Func): HTMLElement {
40
- return ui.span([this.renderIcon(x), ui.label(x.friendlyName)]);
44
+ let markup = ui.span([this.renderIcon(x), ui.label(x.friendlyName)]);
45
+ let c = grok.functions.getCurrentCall();
46
+ markup.ondblclick = (e) => {
47
+ ModelHandler.openModel(x, c); }
48
+ return markup;
41
49
  }
42
50
 
43
51
  renderProperties(x: DG.Func) {
@@ -46,41 +54,43 @@ export class ModelHandler extends DG.ObjectHandler {
46
54
  a.addTitle(ui.span([this.renderIcon(x), ui.label(x.friendlyName), ui.contextActions(x), ui.star(x.id)]));
47
55
  a.addPane('Details', () => {
48
56
  return this.renderDetails(x);
49
- });
50
- a.addCountPane('Usage', () => {
51
- return ui.span(['Usage statistics']);
52
- }, () => 99);
57
+ }, true);
53
58
  a.end();
54
59
  return a.root;
55
60
  }
56
61
 
57
62
  renderDetails(x: DG.Func) {
58
- return ui.divV([ui.render(x.author), ui.render(x.createdOn)], {style: {lineHeight: '150%'}});
63
+ return ui.divV([ui.markdown(x.description), ui.span([ui.render(x.author), ' created ', ui.render(x.createdOn)])], {style: {lineHeight: '150%'}});
59
64
  }
60
65
 
61
66
  renderTooltip(x: DG.Func) {
62
- return ui.divText(`${x.friendlyName}`);
63
- }
64
-
65
- renderCard(x: DG.Func, context?: any): HTMLElement {
66
67
  let h = this.renderMarkup(x);
67
68
  h.classList.add('d4-link-label');
68
69
  let card = ui.bind(x, ui.divV([
69
70
  ui.h2(h),
70
- ui.divText(x.description, 'ui-description'),
71
- this.renderDetails(x),
71
+ ui.divV([ui.divText(x.description, 'ui-description')], {style: {lineHeight: '150%'}})
72
72
  ]));
73
73
  let c = grok.functions.getCurrentCall();
74
- card.ondblclick = (e) => {
75
- ModelHandler.openModel(x, c);
76
- }
74
+ card.ondblclick = (e) => { ModelHandler.openModel(x, c); }
75
+ return card;
76
+ }
77
+
78
+ renderCard(x: DG.Func, context?: any): HTMLElement {
79
+ let h = this.renderMarkup(x);
80
+ h.classList.add('d4-link-label');
81
+ let card = ui.bind(x, ui.h2(h));
82
+ let c = grok.functions.getCurrentCall();
83
+ card.ondblclick = (e) => { ModelHandler.openModel(x, c); }
77
84
  return card;
78
85
  }
79
86
 
80
87
  static openModel(x: DG.Func, parentCall?: DG.FuncCall) {
81
88
  let fc = x.prepare();
82
- if (parentCall != null)
89
+ if (parentCall != null) {
90
+ let modelsView = wu(grok.shell.views).find((v) => v.parentCall?.func.name == 'modelCatalog');
91
+ parentCall.aux['view'] = modelsView;
83
92
  fc.parentCall = parentCall;
93
+ }
84
94
  fc.edit();
85
95
  }
86
96
 
package/src/package.ts CHANGED
@@ -11,6 +11,7 @@ import {OutliersSelectionViewer} from './outliers-selection/outliers-selection-v
11
11
  import {FunctionView} from "@datagrok-libraries/utils/src/function-view";
12
12
  import {delay} from "@datagrok-libraries/utils/src/test";
13
13
  import {ComputationView} from "@datagrok-libraries/utils/src/computation-view";
14
+ import './css/model-card.css';
14
15
 
15
16
  let initCompleted: boolean = false;
16
17
  export const _package = new DG.Package();
@@ -23,6 +24,15 @@ export function OutliersSelection() {
23
24
  return new OutliersSelectionViewer();
24
25
  }
25
26
 
27
+ //name: ComputationViewTest
28
+ //description: Creates an outliers selection viewer
29
+ //tags: viewer
30
+ //input: funccall call
31
+ //output: view result
32
+ export function ComputationViewTest(call: DG.FuncCall) {
33
+ // return new ComputationView(call.func);
34
+ }
35
+
26
36
 
27
37
  /*//output: widget result
28
38
  //tags: dashboard
@@ -42,11 +52,27 @@ export function functionParametersGrid(f: DG.Func): DG.View {
42
52
  }
43
53
 
44
54
  //name: hof
45
- //tags: model
55
+ //tags: sidebar
56
+ //description: some description
46
57
  export function hof() {
47
- grok.shell.info('blablabla');
58
+ grok.shell.info('hof');
59
+ let f: DG.Func = DG.Func.byName('Sin');
60
+ let v: DG.View = functionParametersGrid(f);
61
+ v.parentCall = grok.functions.getCurrentCall();
62
+ //v.parentView = v.parentCall?.aux['view'];
63
+ grok.shell.addView(v);
64
+ }
65
+
66
+
67
+ //name: hof2
68
+ //description: some description 2 2 2
69
+ export function hof2() {
70
+ grok.shell.info('hof2');
48
71
  let f: DG.Func = DG.Func.byName('Sin');
49
72
  let v: DG.View = functionParametersGrid(f);
73
+ v.parentCall = grok.functions.getCurrentCall().parentCall;
74
+ v.parentView = v.parentCall?.aux['view'];
75
+ v.path = 'hof';
50
76
  grok.shell.addView(v);
51
77
  }
52
78