@datagrok/hit-triage 1.4.0 → 1.4.2
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/CHANGELOG.md +9 -0
- package/dist/package.js +1 -1
- package/dist/package.js.map +1 -1
- package/package.json +1 -1
- package/src/app/hit-app-base.ts +3 -1
- package/src/app/hit-design-app.ts +30 -10
- package/src/package.ts +2 -0
package/package.json
CHANGED
package/src/app/hit-app-base.ts
CHANGED
|
@@ -115,7 +115,9 @@ export abstract class HitAppBase<T> {
|
|
|
115
115
|
const addedColNames: string[] = [];
|
|
116
116
|
for (const col of df1.columns) {
|
|
117
117
|
if (!df2.columns.contains(col.name)) {
|
|
118
|
-
df2.columns.addNew(col.name, col.type);
|
|
118
|
+
const addedCol = df2.columns.addNew(col.name, col.type);
|
|
119
|
+
if (col.semType)
|
|
120
|
+
addedCol.semType = col.semType;
|
|
119
121
|
addedColNames.push(col.name);
|
|
120
122
|
}
|
|
121
123
|
}
|
|
@@ -54,7 +54,12 @@ export class HitDesignApp<T extends HitDesignTemplate = HitDesignTemplate> exten
|
|
|
54
54
|
}
|
|
55
55
|
|
|
56
56
|
async handleJoiningDataframe(df: DG.DataFrame) {
|
|
57
|
-
const
|
|
57
|
+
const molCols = df.columns.bySemTypeAll(DG.SEMTYPE.MOLECULE);
|
|
58
|
+
if (!molCols || molCols.length === 0) {
|
|
59
|
+
grok.shell.error('No molecule column found');
|
|
60
|
+
return;
|
|
61
|
+
}
|
|
62
|
+
const molCol = molCols.find((c) => c?.name?.toLowerCase() === 'smiles' || c?.name?.toLowerCase() === 'molecule') ?? molCols[0];
|
|
58
63
|
if (!molCol) {
|
|
59
64
|
grok.shell.error('No molecule column found');
|
|
60
65
|
return;
|
|
@@ -517,21 +522,36 @@ export class HitDesignApp<T extends HitDesignTemplate = HitDesignTemplate> exten
|
|
|
517
522
|
// TODO: Support multiple functions
|
|
518
523
|
const designerFunc = designerFuncs[0];
|
|
519
524
|
const designerButton = ui.iconFA('pen-nib', async () => {
|
|
520
|
-
const
|
|
525
|
+
const prepareObj: any = {};
|
|
526
|
+
if (designerFunc.inputs.length > 0 && this.dataFrame && this.dataFrame.currentRowIdx >=0 && designerFunc.inputs[0].semType === DG.SEMTYPE.MOLECULE) {
|
|
527
|
+
const mol = _package.convertToSmiles(this.dataFrame.col(this.molColName)?.get(this.dataFrame.currentRowIdx));
|
|
528
|
+
if (mol)
|
|
529
|
+
prepareObj[designerFunc.inputs[0].name] = mol;
|
|
530
|
+
}
|
|
531
|
+
const fc = designerFunc.prepare(prepareObj);
|
|
521
532
|
// the editor we get here will be editing the funccall, so then we can just call it.
|
|
522
533
|
const dialogContent = await fc.getEditor();
|
|
523
534
|
ui.dialog(designerFunc.friendlyName)
|
|
524
535
|
.add(dialogContent)
|
|
525
536
|
.onOK(async () => {
|
|
526
|
-
|
|
527
|
-
|
|
528
|
-
|
|
529
|
-
|
|
530
|
-
|
|
537
|
+
const pg = DG.TaskBarProgressIndicator.create(`Running ${designerFunc.friendlyName}`);
|
|
538
|
+
try {
|
|
539
|
+
await fc.call();
|
|
540
|
+
const res: DG.DataFrame = fc.getOutputParamValue();
|
|
541
|
+
if (!res || !res.rowCount) {
|
|
542
|
+
grok.shell.warning(`${designerFunc.friendlyName} returned an empty result`);
|
|
543
|
+
pg.close();
|
|
544
|
+
return;
|
|
545
|
+
}
|
|
546
|
+
await res.meta.detectSemanticTypes();
|
|
547
|
+
await grok.data.detectSemanticTypes(res);
|
|
548
|
+
await this.handleJoiningDataframe(res);
|
|
549
|
+
} catch (e) {
|
|
550
|
+
grok.shell.error(`Failed to run ${designerFunc.friendlyName}`);
|
|
551
|
+
_package.logger.error(e);
|
|
552
|
+
} finally {
|
|
553
|
+
pg.close();
|
|
531
554
|
}
|
|
532
|
-
await res.meta.detectSemanticTypes();
|
|
533
|
-
await grok.data.detectSemanticTypes(res);
|
|
534
|
-
await this.handleJoiningDataframe(res);
|
|
535
555
|
})
|
|
536
556
|
.show();
|
|
537
557
|
}, designerFunc.description ? designerFunc.description : designerFunc.friendlyName);
|
package/src/package.ts
CHANGED
|
@@ -16,6 +16,8 @@ export class HTPackage extends DG.Package {
|
|
|
16
16
|
molToSmilesLruCache = new DG.LruCache<string, string>(2000);
|
|
17
17
|
|
|
18
18
|
convertToSmiles(mol: string): string {
|
|
19
|
+
if (!mol)
|
|
20
|
+
return '';
|
|
19
21
|
return this.molToSmilesLruCache.getOrCreate(mol,
|
|
20
22
|
(mol) => grok.chem.convert(mol, grok.chem.Notation.Unknown, grok.chem.Notation.Smiles),
|
|
21
23
|
);
|