Skip to content

Commit b9e29a8

Browse files
committed
Completed plot integration
1 parent 2ae6741 commit b9e29a8

3 files changed

Lines changed: 39 additions & 22 deletions

File tree

webapp/constants.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -404,6 +404,7 @@ export const PLOT_WIDGETS = {
404404
config: {
405405
id: 'plotDipole',
406406
name: 'Dipole plot',
407+
uri: 'downloads?uri=workspace/model_output_dipole.png',
407408
method: {
408409
plotKey: 'plotDipole',
409410
plotMethod: 'plotDipole',
@@ -431,6 +432,7 @@ export const PLOT_WIDGETS = {
431432
config: {
432433
id: 'plotEEG',
433434
name: 'EEG plot',
435+
uri: 'downloads?uri=workspace/model_output_EEG.png',
434436
method: {
435437
plotKey: 'plotEEG',
436438
plotMethod: 'plotEEG',

webapp/redux/middleware/plotMiddleware.js

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ import {
1111
SET_THEME,
1212
CREATE_NETWORK,
1313
} from '../actions/general';
14+
import { hideSpinner, showSpinner } from '@metacell/geppetto-meta-client/common/actions/actions';
1415

1516
// A simple cache for plots coming from the backend.
1617
// This is a temporary solution until we have a proper strategy to store the plot data in redux
@@ -27,7 +28,7 @@ const setPlotToWindow = (plotId, data) => {
2728
window.plotCache[plotId] = data;
2829
};
2930

30-
const plotFigure = async (plotId, plotMethod, plotType = false, theme) => {
31+
const plotFigure = async (plotId, plotMethod, plotType = false, uri = null, theme) => {
3132
try {
3233
let response = await Promise.race([
3334
Utils.evalPythonMessage(NETPYNE_COMMANDS.plotFigure, [plotMethod, plotType, theme], false),
@@ -38,7 +39,7 @@ const plotFigure = async (plotId, plotMethod, plotType = false, theme) => {
3839
})]);
3940

4041
console.log('Plot response received for', plotId);
41-
if (!response) {
42+
if (!response && !uri) { //png plots return null response but they provide a uri so they can be grabbed from the workspace
4243
return null;
4344
}
4445

@@ -63,6 +64,9 @@ const plotFigure = async (plotId, plotMethod, plotType = false, theme) => {
6364
}
6465
return htmlText;
6566
}
67+
if ((plotMethod == 'plotDipole' || plotMethod == 'plotEEG' )) { //uri is available here
68+
return (`<img src="${uri}"></img>`) ;
69+
}
6670
if (response?.length !== undefined) {
6771
return response[0];
6872
}
@@ -93,13 +97,15 @@ const updatePlots = (next) => {
9397
export default (store) => (next) => (action) => {
9498
async function setWidget (widget) {
9599
const {
96-
plotMethod,
97-
plotType,
98-
} = widget.config.method;
99-
return plotFigure(widget.id, plotMethod, plotType, store.getState().general.theme)
100+
method,
101+
uri,
102+
} = widget.config;
103+
showSpinner("Loading plot...");
104+
return plotFigure(widget.id, method.plotMethod, method.plotType, uri, store.getState().general.theme)
100105
.then((data) => {
101106
setPlotToWindow(widget.id, data);
102107
widget.initialized = true;
108+
hideSpinner();
103109
if (data) {
104110
console.debug('Plot retrieved:', widget.id);
105111
return widget;

webapp/yarn.lock

Lines changed: 25 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1941,9 +1941,9 @@ ajv@^6.1.0, ajv@^6.10.0, ajv@^6.10.2, ajv@^6.12.4, ajv@^6.7.0:
19411941
uri-js "^4.2.2"
19421942

19431943
ajv@^8.0.1:
1944-
version "8.10.0"
1945-
resolved "https://registry.yarnpkg.com/ajv/-/ajv-8.10.0.tgz#e573f719bd3af069017e3b66538ab968d040e54d"
1946-
integrity sha512-bzqAEZOjkrUMl2afH8dknrq5KEk2SrwdBROR+vH1EKVQTqaUbJVPdc/gEdggTMM0Se+s+Ja4ju4TlNcStKl2Hw==
1944+
version "8.11.0"
1945+
resolved "https://registry.yarnpkg.com/ajv/-/ajv-8.11.0.tgz#977e91dd96ca669f54a11e23e378e33b884a565f"
1946+
integrity sha512-wGgprdCvMalC0BztXvitD2hC04YffAvtsUn93JbGXYLAtCUO4xd17mCCZQxUOItiBwZvJScWo8NIvQMQ71rdpg==
19471947
dependencies:
19481948
fast-deep-equal "^3.1.1"
19491949
json-schema-traverse "^1.0.0"
@@ -2282,12 +2282,12 @@ babel-eslint@^10.0.1:
22822282
resolve "^1.12.0"
22832283

22842284
babel-loader@^8.0.6:
2285-
version "8.2.3"
2286-
resolved "https://registry.yarnpkg.com/babel-loader/-/babel-loader-8.2.3.tgz#8986b40f1a64cacfcb4b8429320085ef68b1342d"
2287-
integrity sha512-n4Zeta8NC3QAsuyiizu0GkmRcQ6clkV9WFUnUf1iXP//IeSKbWjofW3UHyZVwlOB4y039YQKefawyTn64Zwbuw==
2285+
version "8.2.4"
2286+
resolved "https://registry.yarnpkg.com/babel-loader/-/babel-loader-8.2.4.tgz#95f5023c791b2e9e2ca6f67b0984f39c82ff384b"
2287+
integrity sha512-8dytA3gcvPPPv4Grjhnt8b5IIiTcq/zeXOPk4iTYI0SVXcsmuGg7JtBRDp8S9X+gJfhQ8ektjXZlDu1Bb33U8A==
22882288
dependencies:
22892289
find-cache-dir "^3.3.1"
2290-
loader-utils "^1.4.0"
2290+
loader-utils "^2.0.0"
22912291
make-dir "^3.1.0"
22922292
schema-utils "^2.6.5"
22932293

@@ -7093,6 +7093,15 @@ loader-utils@^1.0.1, loader-utils@^1.0.2, loader-utils@^1.1.0, loader-utils@^1.2
70937093
emojis-list "^3.0.0"
70947094
json5 "^1.0.1"
70957095

7096+
loader-utils@^2.0.0:
7097+
version "2.0.2"
7098+
resolved "https://registry.yarnpkg.com/loader-utils/-/loader-utils-2.0.2.tgz#d6e3b4fb81870721ae4e0868ab11dd638368c129"
7099+
integrity sha512-TM57VeHptv569d/GKh6TAYdzKblwDNiumOdkFnejjD0XwTH87K90w3O7AiJRqdQoXygvi1VQTJTLGhJl7WqA7A==
7100+
dependencies:
7101+
big.js "^5.2.2"
7102+
emojis-list "^3.0.0"
7103+
json5 "^2.1.2"
7104+
70967105
localforage@^1.8.1:
70977106
version "1.10.0"
70987107
resolved "https://registry.yarnpkg.com/localforage/-/localforage-1.10.0.tgz#5c465dc5f62b2807c3a84c0c6a1b1b3212781dd4"
@@ -7522,7 +7531,7 @@ minimatch@^3.0.0, minimatch@^3.0.4, minimatch@^3.1.2:
75227531
dependencies:
75237532
brace-expansion "^1.1.7"
75247533

7525-
minimist@^1.2.0, minimist@^1.2.5:
7534+
minimist@^1.2.0, minimist@^1.2.5, minimist@^1.2.6:
75267535
version "1.2.6"
75277536
resolved "https://registry.yarnpkg.com/minimist/-/minimist-1.2.6.tgz#8637a5b759ea0d6e98702cfb3a9283323c93af44"
75287537
integrity sha512-Jsjnk4bw3YJqYzbdyBiNsPWHPfO++UGG749Cxs6peCu5Xg4nrena6OVxOYxrQTqww0Jmwt+Ref8rggumkTLz9Q==
@@ -7568,11 +7577,11 @@ mixin-deep@^1.2.0:
75687577
is-extendable "^1.0.1"
75697578

75707579
mkdirp@^0.5.1, mkdirp@^0.5.3, mkdirp@^0.5.5:
7571-
version "0.5.5"
7572-
resolved "https://registry.yarnpkg.com/mkdirp/-/mkdirp-0.5.5.tgz#d91cefd62d1436ca0f41620e251288d420099def"
7573-
integrity sha512-NKmAlESf6jMGym1++R0Ra7wvhV+wFW63FaSOFPwRahvea0gMUcGUhVeAg/0BC0wiv9ih5NYPB1Wn1UEI1/L+xQ==
7580+
version "0.5.6"
7581+
resolved "https://registry.yarnpkg.com/mkdirp/-/mkdirp-0.5.6.tgz#7def03d2432dcae4ba1d611445c48396062255f6"
7582+
integrity sha512-FP+p8RB8OWpF3YZBCrP5gtADmtXApB5AMLn+vdyA+PyxCjrCs00mjyUozssO33cwDeT3wNGdLxJ5M//YqtHAJw==
75747583
dependencies:
7575-
minimist "^1.2.5"
7584+
minimist "^1.2.6"
75767585

75777586
monotone-convex-hull-2d@^1.0.1:
75787587
version "1.0.1"
@@ -10738,13 +10747,13 @@ triangulate-polyline@^1.0.0:
1073810747
cdt2d "^1.0.0"
1073910748

1074010749
tsconfig-paths@^3.12.0:
10741-
version "3.14.0"
10742-
resolved "https://registry.yarnpkg.com/tsconfig-paths/-/tsconfig-paths-3.14.0.tgz#4fcc48f9ccea8826c41b9ca093479de7f5018976"
10743-
integrity sha512-cg/1jAZoL57R39+wiw4u/SCC6Ic9Q5NqjBOb+9xISedOYurfog9ZNmKJSxAnb2m/5Bq4lE9lhUcau33Ml8DM0g==
10750+
version "3.14.1"
10751+
resolved "https://registry.yarnpkg.com/tsconfig-paths/-/tsconfig-paths-3.14.1.tgz#ba0734599e8ea36c862798e920bcf163277b137a"
10752+
integrity sha512-fxDhWnFSLt3VuTwtvJt5fpwxBHg5AdKWMsgcPOOIilyjymcYVZoCQF8fvFRezCNfblEXmi+PcM1eYHeOAgXCOQ==
1074410753
dependencies:
1074510754
"@types/json5" "^0.0.29"
1074610755
json5 "^1.0.1"
10747-
minimist "^1.2.0"
10756+
minimist "^1.2.6"
1074810757
strip-bom "^3.0.0"
1074910758

1075010759
tslib@^1.10.0, tslib@^1.9.3:

0 commit comments

Comments
 (0)