Skip to content

Commit

Permalink
Merge branch 'fix-standalone-validation' of https://github.com/Neurod…
Browse files Browse the repository at this point in the history
…ataWithoutBorders/nwb-guide into fix-standalone-validation
  • Loading branch information
garrettmflynn committed Jun 14, 2024
2 parents 9db5db2 + 256f65b commit bff980b
Show file tree
Hide file tree
Showing 29 changed files with 596 additions and 308 deletions.
9 changes: 5 additions & 4 deletions .github/workflows/daily_tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -39,10 +39,7 @@ jobs:
NotifyOnAnyFailure:
runs-on: ubuntu-latest
needs: [DevTests, LiveServices, BuildTests, ExampleDataCache, ExampleDataTests]
if: |
${{
always() && (needs.DevTests.result == 'failure' || needs.LiveServices.result == 'failure' || needs.BuildTests.result == 'failure' || needs.ExampleDataCache.result == 'failure' || needs.ExampleDataTests.result == 'failure')
}}
if: always() && (${{ needs.DevTests.result }} == 'failure' || ${{ needs.LiveServices.result }} == 'failure' || ${{ needs.BuildTests.result }} == 'failure' || ${{ needs.ExampleDataCache.result }} == 'failure' || ${{ needs.ExampleDataTests.result }} == 'failure')
steps:
- name: Printout which failed
run: |
Expand All @@ -51,6 +48,10 @@ jobs:
echo "BuildTests: ${{ needs.BuildTests.result }}"
echo "ExampleDataCache: ${{ needs.ExampleDataCache.result }}"
echo "ExampleDataTests: ${{ needs.ExampleDataTests.result }}"
- name: debugging
run: export test=(${{ needs.DevTests.result }} == 'failure' || ${{ needs.LiveServices.result }} == 'failure' || ${{ needs.BuildTests.result }} == 'failure' || ${{ needs.ExampleDataCache.result }} == 'failure' || ${{ needs.ExampleDataTests.result }} == 'failure')
- name: debugging print
run: echo $test
#- name: Printout logic trigger
# run: ${{ needs.DevTests.result }} == 'failure' || ${{ needs.LiveServices.result }} == 'failure' || ${{ needs.BuildTests.result }} == 'failure' || ${{ needs.ExampleDataCache.result }} == 'failure' || ${{ needs.ExampleDataTests.result }} == 'failure'
- uses: dawidd6/action-send-mail@v3
Expand Down
9 changes: 5 additions & 4 deletions src/electron/frontend/core/components/FileSystemSelector.js
Original file line number Diff line number Diff line change
Expand Up @@ -280,9 +280,11 @@ export class FilesystemSelector extends LitElement {
>`
: ""}`}
<div class="controls">
${this.value ? html`<div @click=${() => this.#handleFiles()}>${unsafeSVG(restartSVG)}</div>` : ""}
</div>
<div class="controls">
${this.value
? html`<div @click=${() => this.#handleFiles()}>${unsafeSVG(restartSVG)}</div>`
: ""}
</div>
</button>
${this.multiple && isArray && this.value.length > 1
? new List({
Expand All @@ -293,7 +295,6 @@ export class FilesystemSelector extends LitElement {
},
})
: ""}
</div>
${isMultipleTypes
? html`<div id="button-div">
Expand Down
13 changes: 6 additions & 7 deletions src/electron/frontend/core/components/InspectorList.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,12 @@ import { getMessageType, isErrorImportance } from "../validation";

import { unsafeHTML } from "lit/directives/unsafe-html.js";

import { header } from '../../utils/text'
import { header } from "../../utils/text";

const sortAlphabeticallyWithNumberedStrings = (a, b) => {
if (a === b) return 0;
return a.localeCompare(b, undefined, { numeric: true, sensitivity: 'base' });
}

return a.localeCompare(b, undefined, { numeric: true, sensitivity: "base" });
};

const sortList = (items) => {
return items
Expand All @@ -23,19 +22,19 @@ const sortList = (items) => {
else if (lowA) return 1;
else return -1;
})

.sort((a, b) => {
const aCritical = isErrorImportance.includes(a.importance);
const bCritical = isErrorImportance.includes(b.importance);
if (aCritical && bCritical) return 0;
else if (aCritical) return -1;
else return 1;
})
});
};

const aggregateMessages = (items) => {
let messages = {};
console.log(items)
console.log(items);
items.forEach((item) => {
const copy = { ...item };
delete copy.file_path;
Expand Down
16 changes: 1 addition & 15 deletions src/electron/frontend/core/components/InstanceListItem.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ export class InstanceListItem extends LitElement {
declare label: string
declare status: string
declare selected: boolean
declare onRemoved?: Function

static get styles() {
return css`
Expand Down Expand Up @@ -120,7 +119,7 @@ export class InstanceListItem extends LitElement {
}
}

constructor({ label, status, selected, onRemoved, id, ...metadata } = {
constructor({ label, status, selected, id, ...metadata } = {
label: "",
status: "",
selected: false
Expand All @@ -131,7 +130,6 @@ export class InstanceListItem extends LitElement {
this.status = status;
this.selected = selected;
this.metadata = metadata
if (this.onRemoved) this.onRemoved = onRemoved;
}

#onClick () {
Expand All @@ -154,18 +152,6 @@ export class InstanceListItem extends LitElement {
>${this.label}
<div class="indicator"></div>
</span>
${this.onRemoved
? html`<nwb-button
size="small"
primary
color="gray"
@click=${this.onRemoved}
.buttonStyles=${{
padding: "7px",
}}
>x</nwb-button
>`
: ""}
</li>
`
}
Expand Down
39 changes: 6 additions & 33 deletions src/electron/frontend/core/components/InstanceManager.js
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";
import { notify } from "../notifications";
import { Accordion } from "./Accordion";
import { InstanceListItem } from "./InstanceListItem";
import { checkStatus } from "../validation";
Expand Down Expand Up @@ -142,7 +142,6 @@ export class InstanceManager extends LitElement {
this.header = props.header;
this.instanceType = props.instanceType ?? "Instance";
if (props.onAdded) this.onAdded = props.onAdded;
if (props.onRemoved) this.onRemoved = props.onRemoved;
if (props.onDisplay) this.onDisplay = props.onDisplay;
this.controls = props.controls ?? [];
}
Expand All @@ -157,8 +156,12 @@ export class InstanceManager extends LitElement {
} else return content;
};

getInstance(id) {
return this.#items.find((item) => item.id === id);
}

updateState = (id, state) => {
const item = this.#items.find((i) => i.id === id);
const item = this.getInstance(id);

item.status = state;

Expand All @@ -178,7 +181,6 @@ export class InstanceManager extends LitElement {
};

// onAdded = () => {}
// onRemoved = () => {}

toggleInput = (force) => {
const newInfoDiv = this.shadowRoot.querySelector("#new-info");
Expand Down Expand Up @@ -248,34 +250,6 @@ export class InstanceManager extends LitElement {
#items = [];
#info = {};

#onRemoved(ev) {
const parent = ev.target.parentNode;
const name = parent.getAttribute("data-instance");
const ogPath = name.split("/");
const path = [...ogPath];
let target = toRender;
const key = path.pop();
target = path.reduce((acc, cur) => acc[cur], target);
this.onRemoved(target[key], ogPath);
delete target[key];

if (parent.hasAttribute("selected")) {
const previous = parent.previousElementSibling?.getAttribute("data-instance");
if (previous) this.#selected = previous;
else {
const next = parent.nextElementSibling?.getAttribute("data-instance");
if (next) this.#selected = next;
else this.#selected = undefined;
}
}

// parent.remove()
// const instance = this.shadowRoot.querySelector(`div[data-instance="${name}"]`)
// instance.remove()

this.requestUpdate();
}

#hideAll(chosenInstanceElement) {
Array.from(this.shadowRoot.querySelectorAll("div[data-instance]")).forEach((instanceElement) => {
if (instanceElement !== chosenInstanceElement) instanceElement.hidden = true;
Expand Down Expand Up @@ -332,7 +306,6 @@ export class InstanceManager extends LitElement {
id: key,
label: key.split("/").pop(),
selected: key === this.#selected,
onRemoved: this.#onRemoved.bind(this),
...info,
};
Expand Down
9 changes: 5 additions & 4 deletions src/electron/frontend/core/components/JSONSchemaInput.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ import { OptionalSection } from "./OptionalSection";
import { InspectorListItem } from "./InspectorList.js";
import { renderDateTime, resolveDateTime } from "./DateTimeSelector";
import { isObject } from "../../utils/typecheck";
import { resolve } from "../../utils/promises";

const isDevelopment = !!import.meta.env;

Expand Down Expand Up @@ -583,7 +584,7 @@ export class JSONSchemaInput extends LitElement {
// onUpdate = () => {}
// onValidate = () => {}

updateData(value, forceValidate = false) {
async updateData(value, forceValidate = false) {
if (!forceValidate) {
// Update the actual input element
const inputElement = this.getElement();
Expand All @@ -603,9 +604,9 @@ export class JSONSchemaInput extends LitElement {
const name = path.splice(-1)[0];

this.#updateData(fullPath, value);
this.#triggerValidation(name, path); // NOTE: Is asynchronous
const possiblePromise = this.#triggerValidation(name, path);

return true;
return resolve(possiblePromise, () => true);
}

getElement = () => this.shadowRoot.querySelector(".schema-input");
Expand Down Expand Up @@ -641,7 +642,7 @@ export class JSONSchemaInput extends LitElement {
if (hooks.willTimeout !== false) this.#activateTimeoutValidation(name, path, hooks);
};

#triggerValidation = async (name, path) => {
#triggerValidation = (name, path) => {
this.#clearTimeoutValidation();
return this.onValidate
? this.onValidate()
Expand Down
6 changes: 1 addition & 5 deletions src/electron/frontend/core/components/NWBFilePreview.js
Original file line number Diff line number Diff line change
Expand Up @@ -159,11 +159,7 @@ export class NWBFilePreview extends LitElement {
{ path: fileArr[0].info.file, ...options },
{ title }
) // Inspect the first file
: await run(
"neuroconv/inspect",
{ path, ...options },
{ title: title + "s" }
); // Inspect the folder
: await run("neuroconv/inspect", { path, ...options }, { title: title + "s" }); // Inspect the folder
const result = onlyFirstFile
? {
Expand Down
2 changes: 1 addition & 1 deletion src/electron/frontend/core/components/pages/Page.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import { LitElement, html } from "lit";
import { run } from "../../../utils/run";
import { get, save } from "../../progress/index.js";

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

import { mapSessions, merge } from "../../../utils/data";
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.js";
import { startLottie } from "../../../lotties";

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.js";
import { startLottie } from "../../../lotties";

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.js";
import { startLottie } from "../../../lotties";
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 @@ -134,29 +134,27 @@ export class GuidedInspectorPage extends Page {
return html`
${until(
(async () => {
this.report = inspector;
const oneFile = fileArr.length <= 1;
const willRun = !this.report
const willRun = !this.report;
const swalOpts = willRun ? await createProgressPopup({ title: oneFile ? title : `${title}s` }) : {};
const { close: closeProgressPopup } = swalOpts;
if (oneFile) {
if (!this.report) {
const result = await run(
"neuroconv/inspect",
{ path: fileArr[0].info.file, ...options, request_id: swalOpts.id },
swalOpts
).catch((error) => {
this.notify(error.message, "error");
return null;
})
.finally(() => closeProgressPopup());
)
.catch((error) => {
this.notify(error.message, "error");
return null;
})
.finally(() => closeProgressPopup());
if (!result) return "Failed to generate inspector report.";
Expand All @@ -182,7 +180,6 @@ export class GuidedInspectorPage extends Page {
const path = getSharedPath(fileArr.map(({ info }) => info.file));
if (!this.report) {
const result = await run(
"neuroconv/inspect",
{ path, ...options, request_id: swalOpts.id },
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ export class InspectPage extends Page {
}
);

console.log(result)
console.log(result);

closeProgressPopup();

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

import { notyf } from "../../../dependencies.js";
import { notyf } from "../../../notifications";
import { homeDirectory, testDataFolderPath } from "../../../globals.js";

import { SERVER_FILE_PATH, electron, path, port, fs } from "../../../../utils/electron";
Expand Down
3 changes: 1 addition & 2 deletions src/electron/frontend/core/components/table/Cell.ts
Original file line number Diff line number Diff line change
Expand Up @@ -179,9 +179,8 @@ export class TableCell extends LitElement {

if (!this.editable) return // Don't set value if not editable

if (this.input) this.input.set(value) // Ensure all operations are undoable
if (this.input) return this.input.set(value) // Ensure all operations are undoable
else this.#value = value // Silently set value if not rendered yet

}

#value
Expand Down
2 changes: 1 addition & 1 deletion src/electron/frontend/core/errors.ts
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
import { notify } from './dependencies'
import { notify } from './notifications'
export const onThrow = (message: string, id?: string) => notify(id ? `<b>[${id}]</b>: ${message}` : message, "error", 7000);
2 changes: 1 addition & 1 deletion src/electron/frontend/core/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import { Dashboard } from './components/Dashboard.js'
import {
notyf,
notify
} from './dependencies.js'
} from './notifications'

import Swal from 'sweetalert2'
import { loadServerEvents, pythonServerOpened } from "./server/index.js";
Expand Down
Loading

0 comments on commit bff980b

Please sign in to comment.