Skip to content

Commit

Permalink
[pre-commit.ci] auto fixes from pre-commit.com hooks
Browse files Browse the repository at this point in the history
for more information, see https://pre-commit.ci
  • Loading branch information
pre-commit-ci[bot] committed Nov 2, 2023
1 parent eacd75b commit 91c23dc
Show file tree
Hide file tree
Showing 7 changed files with 64 additions and 74 deletions.
4 changes: 3 additions & 1 deletion pyflask/app.py
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,9 @@ def send_preview(path):
@app.route("/cpus")
def get_cpu_count():
from psutil import cpu_count
return {"physical": cpu_count(logical=False) }

return {"physical": cpu_count(logical=False)}


@api.route("/server_shutdown", endpoint="shutdown")
class Shutdown(Resource):
Expand Down
2 changes: 1 addition & 1 deletion schemas/dandi-upload.schema.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,4 +10,4 @@ upload.properties.number_of_jobs.transform = upload.properties.number_of_threads
return value
}

export default upload
export default upload
4 changes: 2 additions & 2 deletions src/renderer/src/server.ts
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ const serverIsLiveStartup = async () => {
const echoResponse = await fetch(`${baseUrl}/startup/echo?arg=server ready`).then(res => res.json()).catch(e => e)
return echoResponse === "server ready" ? true : false;
};

// Preload Flask imports for faster on-demand operations
const preloadFlaskImports = () => fetch(`${baseUrl}/startup/preload-imports`).then(res => {
if (res.ok) return res.json()
Expand Down Expand Up @@ -136,4 +136,4 @@ export const loadServerEvents = () => {
})
});
}
}
}
37 changes: 14 additions & 23 deletions src/renderer/src/stories/JSONSchemaInput.js
Original file line number Diff line number Diff line change
Expand Up @@ -345,11 +345,10 @@ export class JSONSchemaInput extends LitElement {
?checked=${this.value ?? false}
@change=${(ev) => validateOnChange && this.#triggerValidation(name, path)}
/>`;
} else if (info.type === "string" || info.type === "number" || info.type === 'integer') {

const isInteger = info.type === 'integer';
if (isInteger) info.type = 'number';
const isNumber = info.type === 'number';
} else if (info.type === "string" || info.type === "number" || info.type === "integer") {
const isInteger = info.type === "integer";
if (isInteger) info.type = "number";
const isNumber = info.type === "number";

const fileSystemFormat = isFilesystemSelector(name, info.format);
if (fileSystemFormat) return createFilesystemSelector(fileSystemFormat);
Expand Down Expand Up @@ -378,27 +377,23 @@ export class JSONSchemaInput extends LitElement {
class="guided--input schema-input ${info.step === null ? "hideStep" : ""}"
type="${type}"
step=${isNumber && info.step ? info.step : ""}
placeholder="${info.placeholder ?? ""}"
.value="${this.value ?? ""}"
@input=${(ev) => {
let value = ev.target.value;
let newValue = value
let newValue = value;
// const isBlank = value === '';
if (isInteger) newValue = parseInt(value);
else if (isNumber) newValue = parseFloat(value)
else if (isNumber) newValue = parseFloat(value);
if (isNumber) {
if ('min' in info && value < info.min) newValue = info.min
else if ('max' in info && value > info.max) newValue = info.max
if ("min" in info && value < info.min) newValue = info.min;
else if ("max" in info && value > info.max) newValue = info.max;
}
if (info.transform) newValue = info.transform(newValue, this.value, info)
if (info.transform) newValue = info.transform(newValue, this.value, info);
// // Do not check patter if value is empty
// if (info.pattern && !isBlank) {
Expand All @@ -407,16 +402,12 @@ export class JSONSchemaInput extends LitElement {
// }
if (!isNaN(newValue) && newValue !== value) {
ev.target.value = newValue
value = newValue
ev.target.value = newValue;
value = newValue;
}
this.#updateData(
fullPath,
value
)}
}
this.#updateData(fullPath, value);
}}
@change=${(ev) => validateOnChange && this.#triggerValidation(name, path)}
/>
`;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,7 @@ export class GuidedSourceDataPage extends ManagedPage {
})
);

await this.save()
await this.save();

this.to(1);
},
Expand Down
29 changes: 12 additions & 17 deletions src/renderer/src/stories/pages/guided-mode/options/GuidedUpload.js
Original file line number Diff line number Diff line change
Expand Up @@ -67,30 +67,25 @@ export class GuidedUploadPage extends Page {
render() {
const state = (this.localState = merge(this.info.globalState.upload ?? { info: {} }, {}));


const promise = onServerOpen(() => {
return fetch(new URL("cpus", baseUrl))
.then((res) => res.json()).then(({ physical }) => {

dandiUploadSchema.properties.number_of_jobs.max = physical;

return this.form = new JSONSchemaForm({
schema: dandiUploadSchema,
results: state.info,
onUpdate: () => (this.unsavedUpdates = true),
onThrow,
.then((res) => res.json())
.then(({ physical }) => {
dandiUploadSchema.properties.number_of_jobs.max = physical;

return (this.form = new JSONSchemaForm({
schema: dandiUploadSchema,
results: state.info,
onUpdate: () => (this.unsavedUpdates = true),
onThrow,
}));
});

})
})
});

return html`${new InfoBox({
header: "How do I create a Dandiset?",
content: dandisetInfoContent,
})}<br /><br />${until(
promise,
html`Loading form contents...`
)} `;
})}<br /><br />${until(promise, html`Loading form contents...`)} `;
}
}

Expand Down
60 changes: 31 additions & 29 deletions src/renderer/src/stories/pages/uploads/UploadsPage.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { html } from "lit";
import { until } from 'lit/directives/until.js';
import { until } from "lit/directives/until.js";

import { JSONSchemaForm } from "../../JSONSchemaForm.js";
import { Page } from "../Page.js";
Expand All @@ -25,7 +25,7 @@ import { header } from "../../forms/utils";
import { validateDANDIApiKey } from "../../../validation/dandi";
import { InfoBox } from "../../InfoBox.js";

import { onServerOpen } from '../../../server'
import { onServerOpen } from "../../../server";
import { baseUrl } from "../../../globals.js";

export const isStaging = (id) => parseInt(id) >= 100000;
Expand Down Expand Up @@ -169,32 +169,33 @@ export class UploadsPage extends Page {

const promise = onServerOpen(() => {
return fetch(new URL("cpus", baseUrl))
.then((res) => res.json()).then(({ physical }) => {
console.log(physical)

dandiSchema.properties.number_of_jobs.max = physical;

// NOTE: API Keys and Dandiset IDs persist across selected project
return this.form = new JSONSchemaForm({
results: globalState,
schema: dandiSchema,
sort: ([k1]) => {
if (k1 === folderPathKey) return -1;
},
onUpdate: ([id]) => {
if (id === folderPathKey) {
for (let key in dandiSchema.properties) {
const input = this.form.getInput([key]);
if (key !== folderPathKey && input.value) input.updateData(""); // Clear the results of the form
.then((res) => res.json())
.then(({ physical }) => {
console.log(physical);

dandiSchema.properties.number_of_jobs.max = physical;

// NOTE: API Keys and Dandiset IDs persist across selected project
return (this.form = new JSONSchemaForm({
results: globalState,
schema: dandiSchema,
sort: ([k1]) => {
if (k1 === folderPathKey) return -1;
},
onUpdate: ([id]) => {
if (id === folderPathKey) {
for (let key in dandiSchema.properties) {
const input = this.form.getInput([key]);
if (key !== folderPathKey && input.value) input.updateData(""); // Clear the results of the form
}
}
}

global.save();
},
onThrow,
global.save();
},
onThrow,
}));
});
})
})
});

return html`
${new InfoBox({
Expand All @@ -204,18 +205,19 @@ export class UploadsPage extends Page {
<br />
<br />
${until(
promise.then(form => {
promise.then((form) => {
return html`
${form}
<hr />
${button}
`
`;
}),
html`<p>Waiting to connect to the Flask server...<p/>`,
html`<p>Waiting to connect to the Flask server...</p>
<p />`
)}
<br />
<br />
`
`;
}
}

Expand Down

0 comments on commit 91c23dc

Please sign in to comment.