Skip to content

Commit

Permalink
Merge branch 'backend-configuration' of https://github.com/NeurodataW…
Browse files Browse the repository at this point in the history
…ithoutBorders/nwb-guide into backend-configuration
  • Loading branch information
garrettmflynn committed Jun 3, 2024
2 parents a808cdf + 25f0814 commit 6f6aed7
Show file tree
Hide file tree
Showing 4 changed files with 71 additions and 75 deletions.
24 changes: 12 additions & 12 deletions src/electron/frontend/core/components/Dashboard.js
Original file line number Diff line number Diff line change
Expand Up @@ -249,10 +249,9 @@ export class Dashboard extends LitElement {
const workflowConfig = page.workflow ?? (page.workflow = {});
const workflowValues = page.info.globalState?.project?.workflow ?? {};

Object.entries(workflowValues).forEach(([ key, state = {} ]) => {

Object.entries(workflowValues).forEach(([key, state = {}]) => {
const config = workflowConfig[key] ?? (workflowConfig[key] = {});
const value = config.value = workflowValues[key];
const value = (config.value = workflowValues[key]);

if (state.elements) {
const elements = state.elements;
Expand All @@ -274,7 +273,6 @@ export class Dashboard extends LitElement {
const { skipped } = this.subSidebar.sections[info.section]?.pages?.[info.id] ?? {};

if (skipped) {

if (isStorybook) return; // Do not skip on storybook

const backwards = previous && previous.info.previous === this.page;
Expand Down Expand Up @@ -315,7 +313,7 @@ export class Dashboard extends LitElement {

.finally(() => {
if (this.#transitionPromise.value) this.#transitionPromise.trigger(this.main.page); // This ensures calls to page.to() can be properly awaited until the next page is ready
})
});
}

// Populate the sections tracked for this page by using the global state as a model
Expand Down Expand Up @@ -374,13 +372,15 @@ export class Dashboard extends LitElement {
if (!active) active = this.activePage; // default to active page

this.main.onTransition = async (transition) => {

const promise = this.#transitionPromise.value ?? (this.#transitionPromise.value = new Promise(
(resolve) => (this.#transitionPromise.trigger = (v) => {
this.#transitionPromise.value = null; // Reset promise
resolve(v);
})
));
const promise =
this.#transitionPromise.value ??
(this.#transitionPromise.value = new Promise(
(resolve) =>
(this.#transitionPromise.trigger = (v) => {
this.#transitionPromise.value = null; // Reset promise
resolve(v);
})
));

if (typeof transition === "number") {
const info = this.page.info;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,6 @@ export class GuidedBackendConfigurationPage extends ManagedPage {
header = {};

workflow = {

// Ensure conversion is completed when skipped
backend_configuration: {
skip: async () => {
Expand All @@ -64,7 +63,6 @@ export class GuidedBackendConfigurationPage extends ManagedPage {
});
},
},

};

footer = {
Expand Down Expand Up @@ -160,8 +158,7 @@ export class GuidedBackendConfigurationPage extends ManagedPage {
"*": itemIgnore,
},
onUpdate: (updatedPath) => {

this.unsavedUpdates = "conversions" // Trigger conversion updates
this.unsavedUpdates = "conversions"; // Trigger conversion updates

const parentPath = updatedPath.slice(0, -1);
const form = instance.getFormElement(parentPath);
Expand Down
Original file line number Diff line number Diff line change
@@ -1,58 +1,57 @@
import { html } from "lit";
import { Page } from "../../Page.js";

import { unsafeSVG } from "lit/directives/unsafe-svg.js";
import folderOpenSVG from "../../../../../assets/icons/folder_open.svg?raw";

import { electron } from "../../../../../utils/electron.js";
import { NWBFilePreview, getSharedPath } from "../../../preview/NWBFilePreview.js";
const { ipcRenderer } = electron;

export const getStubArray = (stubs) =>
Object.values(stubs)
.map((item) => Object.values(item))
.flat();

export class GuidedStubPreviewPage extends Page {
constructor(...args) {
super(...args);
this.style.height = "100%"; // Fix main section
}

header = {
subtitle: `Preview file contents on truncated files using the Neurosift application`,
controls: () =>
html`<nwb-button
size="small"
@click=${() => {
if (ipcRenderer)
ipcRenderer.send(
"showItemInFolder",
getSharedPath(getStubArray(this.info.globalState.preview.stubs).map((item) => item.file))
);
}}
>${unsafeSVG(folderOpenSVG)}</nwb-button
>`,
};

// NOTE: We may want to trigger this whenever (1) this page is visited AND (2) data has been changed.
footer = {
next: "Run Conversion",
onNext: async () => {
await this.save(); // Save in case the conversion fails
return this.to(1); // Will trigger conversion if necessary
},
};

render() {

const { preview, project } = this.info.globalState;

return preview.stubs
? new NWBFilePreview({ project: project.name, files: preview.stubs })
: html`<p style="text-align: center;">Your conversion preview failed. Please try again.</p>`;
}
}

customElements.get("nwbguide-guided-stub-review-page") ||
customElements.define("nwbguide-guided-stub-review-page", GuidedStubPreviewPage);
import { html } from "lit";
import { Page } from "../../Page.js";

import { unsafeSVG } from "lit/directives/unsafe-svg.js";
import folderOpenSVG from "../../../../../assets/icons/folder_open.svg?raw";

import { electron } from "../../../../../utils/electron.js";
import { NWBFilePreview, getSharedPath } from "../../../preview/NWBFilePreview.js";
const { ipcRenderer } = electron;

export const getStubArray = (stubs) =>
Object.values(stubs)
.map((item) => Object.values(item))
.flat();

export class GuidedStubPreviewPage extends Page {
constructor(...args) {
super(...args);
this.style.height = "100%"; // Fix main section
}

header = {
subtitle: `Preview file contents on truncated files using the Neurosift application`,
controls: () =>
html`<nwb-button
size="small"
@click=${() => {
if (ipcRenderer)
ipcRenderer.send(
"showItemInFolder",
getSharedPath(getStubArray(this.info.globalState.preview.stubs).map((item) => item.file))
);
}}
>${unsafeSVG(folderOpenSVG)}</nwb-button
>`,
};

// NOTE: We may want to trigger this whenever (1) this page is visited AND (2) data has been changed.
footer = {
next: "Run Conversion",
onNext: async () => {
await this.save(); // Save in case the conversion fails
return this.to(1); // Will trigger conversion if necessary
},
};

render() {
const { preview, project } = this.info.globalState;

return preview.stubs
? new NWBFilePreview({ project: project.name, files: preview.stubs })
: html`<p style="text-align: center;">Your conversion preview failed. Please try again.</p>`;
}
}

customElements.get("nwbguide-guided-stub-review-page") ||
customElements.define("nwbguide-guided-stub-review-page", GuidedStubPreviewPage);
2 changes: 1 addition & 1 deletion src/pyflask/app.py
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,7 @@ def post(self):
traceback = payload.get("traceback", "")

message = f"{header}\n{'-'*len(header)}\n\n{json.dumps(inputs, indent=2)}\n"

if traceback:
message += f"\n{traceback}\n"

Expand Down

0 comments on commit 6f6aed7

Please sign in to comment.