Skip to content

Commit

Permalink
inject into API call
Browse files Browse the repository at this point in the history
  • Loading branch information
CodyCBakerPhD authored Nov 11, 2023
1 parent 72d7776 commit 6f9d327
Showing 1 changed file with 18 additions and 2 deletions.
20 changes: 18 additions & 2 deletions pyflask/apis/neuroconv.py
Original file line number Diff line number Diff line change
Expand Up @@ -127,7 +127,15 @@ class UploadProject(Resource):
@neuroconv_api.doc(responses={200: "Success", 400: "Bad Request", 500: "Internal server error"})
def post(self):
try:
return upload_project_to_dandi(**neuroconv_api.payload)
import psutil

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

return upload_project_to_dandi(**upload_options)

except Exception as e:
if notBadRequestException(e):
Expand All @@ -139,7 +147,15 @@ class UploadFolder(Resource):
@neuroconv_api.doc(responses={200: "Success", 400: "Bad Request", 500: "Internal server error"})
def post(self):
try:
return upload_folder_to_dandi(**neuroconv_api.payload)
import psutil

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

return upload_folder_to_dandi(**upload_options)

except Exception as e:
if notBadRequestException(e):
Expand Down

0 comments on commit 6f9d327

Please sign in to comment.