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

Modify /convert endpoint to create user folders (βœ“ Sandbox Passed) #10

Closed
wants to merge 1 commit into from
Closed
Changes from all 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
17 changes: 17 additions & 0 deletions convertPheno_server/server/apis/submission.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,9 @@
"""
For submitting a to be converted file
"""
import os
from pathlib import Path

from copy import deepcopy
from io import BytesIO
import gzip
Expand Down Expand Up @@ -254,6 +257,20 @@ def post(self, userid):
if runExample:
ns.logger.info("run /w example data")
user_id = get_or_create_user(userid).id

# Retrieve the Keycloak userid hash from the request data
user_keycloak_hash = data.get("KeycloakUserIdHash")
# Check if the user exists in the database based on the Keycloak hash
user = db.session.query(User).filter_by(keycloak_hash=user_keycloak_hash).one_or_none()
if user is None:
# Create new directories in the "output" and "uploads" directories with the Keycloak userid hash
upload_dir = GeneralConfig.FLASK_UPLOAD_DIR / user_keycloak_hash
output_dir = GeneralConfig.FLASK_OUT_DIR / user_keycloak_hash
os.makedirs(upload_dir, exist_ok=True)
os.makedirs(output_dir, exist_ok=True)

# Proceed with getting or creating the user as before

else:
ns.logger.info("run /w uploaded data")
user = (
Expand Down
Loading