Skip to content

Commit

Permalink
Merge branch 'swap_try_except_to_decorator' of https://github.com/Neu…
Browse files Browse the repository at this point in the history
…rodataWithoutBorders/nwb-guide into swap_try_except_to_decorator
  • Loading branch information
garrettmflynn committed May 29, 2024
2 parents 0ea9fad + 489675d commit 0e8b478
Show file tree
Hide file tree
Showing 177 changed files with 179 additions and 152 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<p align="center">
<img src="src/electron/renderer/assets/img/logo-guide-draft-transparent-tight.png" width="250" alt="NeuroConv logo"/>
<img src="src/electron/frontend/assets/img/logo-guide-draft-transparent-tight.png" width="250" alt="NeuroConv logo"/>
<h3 align="center">NWB Graphical User Interface for Data Entry</h3>
<p align="center">
<a href="https://github.com/NeurodataWithoutBorders/nwb-guide/actions/workflows/testing.yml"><img src="https://github.com/NeurodataWithoutBorders/nwb-guide/actions/workflows/testing.yml/badge.svg" alt="Full Tests"></a>
Expand Down
12 changes: 8 additions & 4 deletions docs/developer_guide.rst
Original file line number Diff line number Diff line change
Expand Up @@ -88,13 +88,17 @@ Repo Structure
- `main`
- `src` - Contains all the source code for the backend
- `assets` - Contains all the backend-facing assets (e.g. images, css, etc.)
- `renderer`
- `src` - Contains all the source code for the frontend
- `preload`
- `preload.js` - Exposes electron-specific variables to the frontend
- `frontend`
- `core` - Contains all the source code for the frontend
- `index.js` - The entry point for the application
- `pages.js` - The main code that controls which pages are rendered and how they are linked together
- `stories` - Contains all the Web Components and related Storybook stories
- `electron` - Contains all the Electron-related code to enable conditional inclusion for development mode
- `components` - Contains all the UI Components used throughout the app
- `assets` - Contains all the frontend-facing assets (e.g. images, css, etc.)
- `utils`
- `electron.js` - Contains electron-exposed variables
- `url.js` - Saving the history state for hot reloading and refresh page functionality
- `pyflask` - Contains all the source code for the backend
- `schemas` - Contains all the JSON schemas used for validation

Expand Down
2 changes: 1 addition & 1 deletion docs/index.rst
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ NWB GUIDE documentation
=======================
|
.. image:: ../src/electron/renderer/assets/img/logo-guide-draft-transparent-tight.png
.. image:: ../src/electron/frontend/assets/img/logo-guide-draft-transparent-tight.png
:scale: 50 %
:align: center
:alt: NWB GUIDE logo
Expand Down
2 changes: 1 addition & 1 deletion electron.vite.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import ViteYaml from "@modyfi/vite-plugin-yaml";

import { resolve } from "path";

const htmlRoot = "src/electron/renderer";
const htmlRoot = "src/electron/frontend";

export default defineConfig({
main: {
Expand Down
12 changes: 5 additions & 7 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,7 @@
"scripts": {
"start": "electron-vite dev --outDir build",
"postinstall": "electron-builder install-app-deps",
"dev": "concurrently -n BE,FE --kill-others \"npm run dev:server\" \"npm run dev:app\"",
"dev:app": "vite src/electron/renderer",
"dev:server": "cd src/pyflask && python -m flask run --port 4242",
"server": "cd src/pyflask && python -m flask run --port 4242",
"build": "npm run build:app",
"echo": "python -c \"print('hello')\"",
"build:app": "electron-vite build --outDir build",
Expand Down Expand Up @@ -77,7 +75,7 @@
"win": {
"asar": false,
"target": "nsis",
"icon": "src/electron/renderer/assets/app-icon/logo-guide-draft.ico",
"icon": "src/electron/frontend/assets/app-icon/logo-guide-draft.ico",
"requestedExecutionLevel": "requireAdministrator"
},
"mac": {
Expand All @@ -98,7 +96,7 @@
]
}
],
"icon": "src/electron/renderer/assets/img/logo-guide-draft.png",
"icon": "src/electron/frontend/assets/img/logo-guide-draft.png",
"darkModeSupport": false,
"hardenedRuntime": true,
"gatekeeperAssess": false,
Expand All @@ -114,7 +112,7 @@
"linux": {
"asar": true,
"target": "AppImage",
"icon": "src/electron/renderer/assets/img/logo-guide-draft.png",
"icon": "src/electron/frontend/assets/img/logo-guide-draft.png",
"extraResources": [
{
"from": "./build/flask/nwb-guide",
Expand All @@ -127,7 +125,7 @@
"oneClick": false,
"perMachine": false,
"allowToChangeInstallationDirectory": true,
"installerIcon": "src/electron/renderer/assets/app-icon/logo-guide-draft.ico"
"installerIcon": "src/electron/frontend/assets/app-icon/logo-guide-draft.ico"
},
"publish": {
"provider": "github"
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,9 @@ import "../../../../../node_modules/fomantic-ui/dist/components/accordion.min.cs
import "../../../../../node_modules/@sweetalert2/theme-bulma/bulma.css";
// import "../../node_modules/intro.js/minified/introjs.min.css"
import "../../assets/css/guided.css";
import isElectron from "../electron/check.js";
import { isStorybook, reloadPageToHome } from "../dependencies/globals";
import { isElectron } from "../../utils/electron.js";
import { isStorybook, reloadPageToHome } from "../globals.js";

import { getCurrentProjectName, updateAppProgress } from "../progress/index.js";

// import "https://jsuites.net/v4/jsuites.js"
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { LitElement, css, html } from "lit";

import { fs, remote } from "../electron/index";
import { fs, remote } from "../../utils/electron";
import { List } from "./List";
const { dialog } = remote;

Expand Down
File renamed without changes.
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { LitElement, css, html } from "lit";
import "./Button";
import { notify } from "../dependencies/globals";
import { notify } from "../dependencies";
import { Accordion } from "./Accordion";
import { InstanceListItem } from "./instances/item";
import { checkStatus } from "../validation";
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
Original file line number Diff line number Diff line change
@@ -1,7 +1,10 @@
import { LitElement, html } from "lit";
import { runConversion } from "./guided-mode/options/utils.js";
import { get, save } from "../../progress/index.js";
import { dismissNotification, isStorybook, notify } from "../../dependencies/globals";

import { dismissNotification, notify } from "../../dependencies.js";
import { isStorybook } from "../../globals.js";

import { randomizeElements, mapSessions, merge } from "./utils";

import { resolveMetadata } from "./guided-mode/data/utils.js";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import { html } from "lit";
import { contact_lottie } from "../../../../assets/lotties/contact-us-lotties.js";
import { Page } from "../Page.js";

import { startLottie } from "../../../dependencies/globals";
import { startLottie } from "../../../dependencies.js";

export class ContactPage extends Page {
header = {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import { html } from "lit";
import { docu_lottie } from "../../../../assets/lotties/documentation-lotties.js";
import { Page } from "../Page.js";

import { startLottie } from "../../../dependencies/globals";
import { startLottie } from "../../../dependencies.js";

import { Button } from "../../Button.js";

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import { html } from "lit";
import { Page } from "../Page.js";
import { ProgressCard } from "./ProgressCard.js";

import { startLottie } from "../../../dependencies/globals";
import { startLottie } from "../../../dependencies.js";
import * as progress from "../../../progress/index.js";
import { newDataset } from "../../../../assets/lotties/index.js";

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import { onThrow } from "../../../../errors";
import pathExpansionSchema from "../../../../../../../schemas/json/path-expansion.schema.json" assert { type: "json" };
import { merge } from "../../utils";
import { List } from "../../../List";
import { fs } from "../../../../electron/index.js";
import { fs } from "../../../../../utils/electron.js";
import { Button } from "../../../Button.js";
import { Modal } from "../../../Modal";
import { header } from "../../../forms/utils";
Expand Down Expand Up @@ -259,7 +259,9 @@ export class GuidedPathExpansionPage extends Page {
throw message;
}

const results = await run(`neuroconv/locate`, finalStructure, { title: "Locating Data" }).catch((error) => {
const results = await run(`neuroconv/locate`, finalStructure, {
title: "Locating Data",
}).catch((error) => {
this.notify(error.message, "error");
throw error;
});
Expand Down Expand Up @@ -319,14 +321,21 @@ export class GuidedPathExpansionPage extends Page {
const structureState = this.#initialize();

// Require properties for all sources
const generatedSchema = { type: "object", properties: {}, additionalProperties: false };
const generatedSchema = {
type: "object",
properties: {},
additionalProperties: false,
};
const controls = {};

const baseDirectory = this.workflow.base_directory.value;
const globals = (structureState.globals = {});

for (let key in this.info.globalState.interfaces) {
generatedSchema.properties[key] = { type: "object", ...pathExpansionSchema };
generatedSchema.properties[key] = {
type: "object",
...pathExpansionSchema,
};

if (baseDirectory) globals[key] = { base_directory: baseDirectory };

Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
import { isStorybook } from "../../../../dependencies/globals";
import Swal from "sweetalert2";

import { isStorybook } from "../../../../globals.js";

import { JSONSchemaForm } from "../../../JSONSchemaForm.js";
import { InstanceManager } from "../../../InstanceManager.js";
import { ManagedPage } from "./ManagedPage.js";
Expand Down Expand Up @@ -205,7 +208,9 @@ export class GuidedSourceDataPage extends ManagedPage {
}

render() {
this.localState = { results: structuredClone(this.info.globalState.results ?? {}) };
this.localState = {
results: structuredClone(this.info.globalState.results ?? {}),
};

this.forms = this.mapSessions(this.createForm, this.localState.results);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,9 @@ export class GuidedStructurePage extends Page {
};

beforeSave = async () => {
const interfaces = (this.info.globalState.interfaces = { ...this.list.object });
const interfaces = (this.info.globalState.interfaces = {
...this.list.object,
});

// Remove or reassign extra interfaces in results
if (this.info.globalState.results) {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { getEditableItems } from "../../../JSONSchemaInput.js";
import { merge } from "../../utils";
import { merge } from "../../utils.js";

// Merge project-wide data into metadata
export function populateWithProjectMetadata(info, globalState) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ 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 "../../../../electron/index.js";
import { electron } from "../../../../../utils/electron.js";
import { getSharedPath, removeFilePaths, truncateFilePaths } from "../../../preview/NWBFilePreview.js";
const { ipcRenderer } = electron;
import { until } from "lit/directives/until.js";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ 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 "../../../../electron/index.js";
import { electron } from "../../../../../utils/electron.js";
import { NWBFilePreview, getSharedPath } from "../../../preview/NWBFilePreview.js";
const { ipcRenderer } = electron;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import { Page } from "../../Page.js";
import { getStubArray } from "../options/GuidedStubPreview.js";
import { getSharedPath } from "../../../preview/NWBFilePreview.js";

import { electron, path } from "../../../../electron/index.js";
import { electron, path } from "../../../../../utils/electron.js";
const { ipcRenderer } = electron;

export class GuidedResultsPage extends Page {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,10 @@ export class InspectPage extends Page {
};

inspect = async (paths, kwargs = {}, options = {}) => {
const swalOpts = await createProgressPopup({ title: "Inspecting selected filesystem entries.", ...options });
const swalOpts = await createProgressPopup({
title: "Inspecting selected filesystem entries.",
...options,
});

const { close: closeProgressPopup } = swalOpts;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,10 @@ import { Button } from "../../Button.js";
import { global, remove, save } from "../../../progress/index.js";
import { merge, setUndefinedIfNotDeclared } from "../utils";

import { homeDirectory, notyf, testDataFolderPath } from "../../../dependencies/globals";
import { SERVER_FILE_PATH, electron, path, port, fs } from "../../../electron/index.js";
import { notyf } from "../../../dependencies.js";
import { homeDirectory, testDataFolderPath } from "../../../globals.js";

import { SERVER_FILE_PATH, electron, path, port, fs } from "../../../../utils/electron.js";

import saveSVG from "../../../../assets/icons/save.svg?raw";
import folderSVG from "../../../../assets/icons/folder_open.svg?raw";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,10 @@ export async function createDandiset(results = {}) {

const api_key = await getAPIKey.call(this, staging);

const api = new dandi.API({ token: api_key, type: staging ? "staging" : undefined });
const api = new dandi.API({
token: api_key,
type: staging ? "staging" : undefined,
});
await api.init();

const metadata = {
Expand Down Expand Up @@ -348,7 +351,9 @@ export class UploadsPage extends Page {
onClick: async () => {
await this.form.validate(); // Will throw an error in the callback

const results = await uploadToDandi.call(this, { ...global.data.uploads });
const results = await uploadToDandi.call(this, {
...global.data.uploads,
});
global.data.uploads = {};
global.save();

Expand Down Expand Up @@ -387,7 +392,9 @@ export class UploadsPage extends Page {
width: "max-content",
},
onClick: async () => {
await createDandiset.call(this, { title: this.form.resolved.dandiset });
await createDandiset.call(this, {
title: this.form.resolved.dandiset,
});
this.requestUpdate();
},
}),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import { unsafeHTML } from "lit/directives/unsafe-html.js";
import { run } from "../pages/guided-mode/options/utils";
import { until } from "lit/directives/until.js";
import { InstanceManager } from "../InstanceManager";
import { path } from "../../electron";
import { path } from "../../../utils/electron.js";
import { FullScreenToggle } from "../FullScreenToggle";

export function getSharedPath(array) {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
import { LitElement, css, html } from "lit";
import { TableCellBase } from "./base.js";
import { BaseRenderer } from "./renderers/base.js";
import { Modal } from "../../Modal";
import { Modal } from "../../Modal.js";

import { SimpleTable } from "../../SimpleTable.js";
import { JSONSchemaInput } from "../../JSONSchemaInput.js";

import { header } from "../../forms/utils";
import { header } from "../../forms/utils.js";

export class NestedEditor extends LitElement {

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,6 @@ import { Notyf } from "notyf";
import checkChromatic from "chromatic/isChromatic";
import lottie from "lottie-web";

export * from "./simple.js";

// ---------- Lottie Helper ----------
const isChromatic = checkChromatic();

Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { notify } from './dependencies/globals'
import { notify } from './dependencies'

export const onThrow = (message: string, id?: string) => {
return notify(id ? `<b>[${id}]</b>: ${message}` : message, "error", 7000);
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,15 @@
import { app, crypto, isElectron } from "../electron/index.js";
import paths from "../../../../paths.config.json" assert { type: "json" };
import { joinPath } from "../globals";
import { app, path, crypto, isElectron } from "../utils/electron.js";

import paths from "../../../paths.config.json" assert { type: "json" };

import supportedInterfaces from "../../../supported_interfaces.json" assert { type: "json" };

export const joinPath = (...args) => (path ? path.join(...args) : args.filter((str) => str).join("/"));

export let runOnLoad = (fn) => {
if (document.readyState === "complete") fn();
else window.addEventListener("load", fn);
};

export const reloadPageToHome = () => {
if (isStorybook) return;
Expand Down Expand Up @@ -29,3 +38,5 @@ export const ENCRYPTION_IV = crypto ? crypto.randomBytes(IV_LENGTH) : null;

// Storybook
export const isStorybook = window.location.href.includes("iframe.html");

export { supportedInterfaces };
Loading

0 comments on commit 0e8b478

Please sign in to comment.