diff --git a/.dockerignore b/.dockerignore index 6859030..e416cce 100644 --- a/.dockerignore +++ b/.dockerignore @@ -1,5 +1,8 @@ .github +.git test +test_data +output_folder **/*.nii.gz build **/build diff --git a/Dockerfile b/Dockerfile index 0fe3850..fe65994 100644 --- a/Dockerfile +++ b/Dockerfile @@ -42,10 +42,11 @@ ARG MAMBA_DOCKERFILE_ACTIVATE=1 ARG CUDA_VERSION COPY --chown=$MAMBA_USER:$MAMBA_USER requirements.txt /tmp/requirements.txt +RUN grep -v -E '^(torch)' /tmp/requirements.txt > /tmp/requirements2.txt USER root RUN apt-get update && apt-get install -y python3-tk git USER $MAMBA_USER -RUN pip install --verbose -r /tmp/requirements.txt && pip uninstall -y torch && pip install --verbose torch==2.3.1 --index-url https://download.pytorch.org/whl/cu${CUDA_VERSION} +RUN pip install --verbose -r /tmp/requirements2.txt && pip uninstall -y torch && pip install --verbose torch==2.3.1 --index-url https://download.pytorch.org/whl/cu${CUDA_VERSION} RUN mkdir ~/dummyinput && mkdir ~/dummyoutput RUN git clone https://github.com/CBICA/PredCRD.git && cd PredCRD && pip install -e . RUN git clone https://github.com/CBICA/DLWMLS.git && cd DLWMLS && pip install -e . && DLWMLS -i ~/dummyinput -o ~/dummyoutput diff --git a/requirements.txt b/requirements.txt index fad0d6a..1ac934a 100644 --- a/requirements.txt +++ b/requirements.txt @@ -3,7 +3,7 @@ spare-scores NiChartHarmonize DLICV DLMUSE -NiChart_DLMUSE +NiChart_DLMUSE>=1.0.9 DLWMLS @ git+https://github.com/CBICA/DLWMLS # general python dependencies diff --git a/src/viewer/utils/utils_menu.py b/src/viewer/utils/utils_menu.py index ad98628..176a3c6 100644 --- a/src/viewer/utils/utils_menu.py +++ b/src/viewer/utils/utils_menu.py @@ -16,6 +16,7 @@ def menu() -> Any: email = st.session_state.cloud_session_token['email'] logout_url = "https://cbica-nichart.auth.us-east-1.amazoncognito.com/logout?client_id=4shr6mm2h0p0i4o9uleqpu33fj&response_type=code&scope=email+openid+phone&redirect_uri=https://cbica-nichart-alb-272274500.us-east-1.elb.amazonaws.com/oauth2/idpresponse" st.sidebar.info(f"Logged in as {email}.") + st.sidebar.info(f"User ID: {st.session_state.cloud_user_id}") ## TODO: Make this button also delete user data automatically st.sidebar.button("Log out", on_click=redirect, args=(logout_url,)) if st.session_state.pipeline == "Home": diff --git a/src/viewer/utils/utils_session.py b/src/viewer/utils/utils_session.py index 0a58692..ec5fb89 100644 --- a/src/viewer/utils/utils_session.py +++ b/src/viewer/utils/utils_session.py @@ -26,19 +26,19 @@ def config_page() -> None: ## Function to parse AWS login (if available) def process_session_token(): - ''' - WARNING: We use unsupported features of Streamlit - However, this is quite fast and works well with - the latest version of Streamlit (1.27) - Also, this does not verify the session token's - authenticity. It only decodes the token. - ''' - headers = _get_websocket_headers() + #headers = _get_websocket_headers() + headers = st.context.headers if not headers or "X-Amzn-Oidc-Data" not in headers: return {} return jwt.decode( headers["X-Amzn-Oidc-Data"], algorithms=["ES256"], options={"verify_signature": False} ) + +def process_session_user_id(): + headers = st.context.headers + if not headers or "X-Amzn-Oidc-Identity" not in headers: + return "NO_USER_FOUND" + return headers["X-Amzn-Oidc-Identity"] def init_session_state() -> None: @@ -64,10 +64,12 @@ def init_session_state() -> None: st.session_state.cloud_session_token = process_session_token() if st.session_state.cloud_session_token: st.session_state.has_cloud_session = True + st.session_state.cloud_user_id = process_session_user_id() else: st.session_state.has_cloud_session = False else: st.session_state.has_cloud_session = False + ################################### @@ -195,9 +197,17 @@ def init_session_state() -> None: # Set initial values for paths st.session_state.paths["root"] = os.path.dirname(os.path.dirname(os.getcwd())) st.session_state.paths["init"] = st.session_state.paths["root"] - st.session_state.paths["dir_out"] = os.path.join( - st.session_state.paths["root"], "output_folder" - ) + if st.session_state.has_cloud_session: + user_id = st.session_state.cloud_user_id + st.session_state.paths["dir_out"] = os.path.join( + st.session_state.paths["root"], "output_folder", user_id + ) + else: + st.session_state.paths["dir_out"] = os.path.join( + st.session_state.paths["root"], "output_folder" + ) + + if not os.path.exists(st.session_state.paths["dir_out"]): os.makedirs(st.session_state.paths["dir_out"]) diff --git a/src/viewer/utils/utils_st.py b/src/viewer/utils/utils_st.py index 2e69633..ff75495 100644 --- a/src/viewer/utils/utils_st.py +++ b/src/viewer/utils/utils_st.py @@ -217,7 +217,7 @@ def help_working_dir(): - On the desktop app, you can initiate a NiChart pipeline by selecting the **working directory** from a previously completed task. - - On the cloud app, the results are deleted in regular intervals, so they may not be available. + - On the cloud app, the results are deleted in regular intervals, so they may not be available if you come back later. """ ) col1, col2 = st.columns([0.5, 0.1])