Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Make default upload parallel params 1 #541

Merged
merged 6 commits into from
Dec 14, 2023
Merged
Show file tree
Hide file tree
Changes from 5 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 4 additions & 8 deletions pyflask/apis/neuroconv.py
Original file line number Diff line number Diff line change
Expand Up @@ -131,11 +131,9 @@ def post(self):

upload_options = neuroconv_api.payload
if "number_of_jobs" not in upload_options:
upload_options.update(number_of_jobs=psutil.cpu_count(logical=False))
upload_options.update(number_of_jobs=1)
if "number_of_threads" not in upload_options:
upload_options.update(
number_of_threads=psutil.cpu_count(logical=True) / psutil.cpu_count(logical=False)
)
upload_options.update(number_of_threads=1)

return upload_project_to_dandi(**upload_options)

Expand All @@ -153,11 +151,9 @@ def post(self):

upload_options = neuroconv_api.payload
if "number_of_jobs" not in upload_options:
upload_options.update(number_of_jobs=psutil.cpu_count(logical=False))
upload_options.update(number_of_jobs=1)
if "number_of_threads" not in upload_options:
upload_options.update(
number_of_threads=psutil.cpu_count(logical=True) / psutil.cpu_count(logical=False)
)
upload_options.update(number_of_threads=1)

return upload_folder_to_dandi(**upload_options)

Expand Down
11 changes: 8 additions & 3 deletions schemas/dandi-upload.schema.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,17 @@ import { isStaging } from '../src/renderer/src/stories/pages/uploads/utils'
import { baseUrl, onServerOpen } from '../src/renderer/src/server/globals'
import { isStorybook } from '../src/renderer/src/dependencies/simple'


const schema = structuredClone(upload)
const idSchema = schema.properties.dandiset as any
Object.assign(idSchema, {
strict: false
})

const additionalSettings = schema.properties.additional_settings.properties as any
additionalSettings.number_of_jobs.description = additionalSettings.number_of_threads.description = '<b>⚠️</b> Setting this value has resulted in unpreditable behaviors (runaway processes, segmentation errors, etc.) on several systems</small>'
CodyCBakerPhD marked this conversation as resolved.
Show resolved Hide resolved


const setReady: any = {}

const createPromise = (prop: string) => new Promise((resolve) => setReady[prop] = resolve)
Expand All @@ -26,9 +31,9 @@ onServerOpen(async () => {
await fetch(new URL("cpus", baseUrl))
.then((res) => res.json())
.then(({ physical, logical }) => {
const { number_of_jobs, number_of_threads } = schema.properties.additional_settings.properties as any;
number_of_jobs.max = number_of_jobs.default = physical;
number_of_threads.max = number_of_threads.default = logical / physical;
const { number_of_jobs, number_of_threads } = additionalSettings as any;
number_of_jobs.max = physical;
number_of_threads.max = logical / physical;
setReady.cpus({ number_of_jobs, number_of_threads })
})
.catch(() => {
Expand Down
8 changes: 5 additions & 3 deletions schemas/json/dandi/upload.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,14 +9,16 @@
"number_of_jobs": {
"type": "integer",
"title": "Job Count",
"description": "The number of files to upload in parallel. <br><small><b>Note:</b> If you encounter an error for any selector value, particularly a Segmentation Fault error, try a value of <code>1</code> to run the jobs without parallelization.</small>",
"min": 1
"description": "The number of files to upload in parallel.",
"min": 1,
"default": 1
},
"number_of_threads": {
"type": "integer",
"title": "Threads per Job",
"description": "The number of threads to handle each file.",
"min": 1
"min": 1,
"default": 1
},
"cleanup": {
"type": "boolean",
Expand Down
9 changes: 9 additions & 0 deletions src/renderer/src/stories/pages/uploads/utils.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@

import { get } from "dandi";
import dandiUploadSchema from "../../../../../../schemas/dandi-upload.schema";
import { html } from "lit";

export const isStaging = (id: string) => parseInt(id) >= 100000;

Expand All @@ -15,6 +16,14 @@ function isNumeric(str: string) {
export const validate = async (name: string, parent: any) => {

const value = parent[name]

if (name === 'number_of_jobs' || name === 'number_of_threads') {
if (value > 1) return [{
type: 'warning',
message: `<b>⚠️</b> Increasing the ${name.split('_').join(' ')} may result in unpredictable behaviors.`
}]
}

if (name === 'dandiset' && value) {
if (isNumeric(value)){

Expand Down
Loading