@datagrok/compute 1.39.5 → 1.39.6

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,7 +1,7 @@
1
1
  {
2
2
  "name": "@datagrok/compute",
3
3
  "friendlyName": "Compute",
4
- "version": "1.39.5",
4
+ "version": "1.39.6",
5
5
  "author": {
6
6
  "name": "Aufar Zakiev",
7
7
  "email": "aufar.zakiev@softwarecountry.com"
package/src/package.ts CHANGED
@@ -2,7 +2,7 @@
2
2
  import * as grok from 'datagrok-api/grok';
3
3
  import * as ui from 'datagrok-api/ui';
4
4
  import * as DG from 'datagrok-api/dg';
5
- import {filter} from 'rxjs/operators';
5
+ import {filter, take} from 'rxjs/operators';
6
6
  import {OutliersSelectionViewer} from './outliers-selection/outliers-selection-viewer';
7
7
  import {
8
8
  ComputationView as ComputationViewInst,
@@ -338,6 +338,80 @@ export function ObjectCoolingSelector(params: any) {
338
338
  );
339
339
  }
340
340
 
341
+ //input: dynamic treeNode
342
+ //input: view browseView
343
+ export async function modelCatalogTreeBrowser(treeNode: DG.TreeViewGroup, browseView: DG.BrowseView) {
344
+ const NO_CATEGORY = 'Uncategorized' as const;
345
+
346
+ const modelSource = grok.dapi.functions.filter('(#model)');
347
+ const modelList = await modelSource.list();
348
+ const departments = modelList.reduce((acc, model) => {
349
+ if (model.options.department)
350
+ acc.add(model.options.department)
351
+ else
352
+ acc.add(NO_CATEGORY)
353
+ return acc;
354
+ }, new Set([] as string[]));
355
+
356
+ const hlProcesses = modelList.reduce((acc, model) => {
357
+ if (model.options.HL_process)
358
+ acc.add(model.options.HL_process)
359
+ else
360
+ acc.add(NO_CATEGORY)
361
+ return acc;
362
+ }, new Set([] as string[]));
363
+
364
+ const processes = modelList.reduce((acc, model) => {
365
+ if (model.options.process)
366
+ acc.add(model.options.process)
367
+ else
368
+ acc.add(NO_CATEGORY)
369
+ return acc;
370
+ }, new Set([] as string[]));
371
+
372
+ for (const department of departments) {
373
+ const serverDep = (department !== NO_CATEGORY ? department: undefined);
374
+ const hasModelsDep = modelList.find((model) =>
375
+ model.options.department === serverDep
376
+ )
377
+
378
+ if (!hasModelsDep) continue;
379
+
380
+ const depNode = treeNode.getOrCreateGroup(department, null, false)
381
+ for (const hlProcess of hlProcesses) {
382
+ const serverHlProcess = (hlProcess !== NO_CATEGORY ? hlProcess: undefined);
383
+ const hasModelsHl = modelList.find((model) =>
384
+ model.options.department === serverDep &&
385
+ model.options.HL_process === serverHlProcess
386
+ )
387
+
388
+ if (!hasModelsHl) continue;
389
+
390
+ const hlNode = hlProcess !== NO_CATEGORY ? depNode.getOrCreateGroup(hlProcess, null, false): depNode;
391
+ for (const process of processes) {
392
+ const serverProcess = (process !== NO_CATEGORY ? process: undefined);
393
+ const hasModels = modelList.find((model) =>
394
+ model.options.department === serverDep &&
395
+ model.options.HL_process === serverHlProcess &&
396
+ model.options.process === serverProcess
397
+ )
398
+
399
+ if (!hasModels) continue;
400
+
401
+ const processNode = process !== NO_CATEGORY ? hlNode.getOrCreateGroup(process, null, false): hlNode;
402
+ processNode.onNodeExpanding.pipe(take(1)).subscribe(() => {
403
+ const modelRule = `(#model)`;
404
+ const depRules = department === NO_CATEGORY ? `(options.department = null)`: `(options.department in ("${department}"))`;
405
+ const hlProcessRules = hlProcess === NO_CATEGORY ? `(options.HL_process = null)`: `(options.HL_process in ("${hlProcess}"))`;
406
+ const processRules = process === NO_CATEGORY ? `(options.process = null)`: `(options.process in ("${process}"))`;
407
+ const filteringRules = `(${[modelRule, depRules, hlProcessRules, processRules].join(' and ')})`
408
+ processNode.loadSources(grok.dapi.functions.filter(filteringRules));
409
+ })
410
+ }
411
+ }
412
+ }
413
+ }
414
+
341
415
  //// Compute-utils API section
342
416
 
343
417
  export const testPipeline = testPipelineInst;