Skip to content

Commit

Permalink
Merge pull request #49 from CBICA/ag-dev
Browse files Browse the repository at this point in the history
Ag dev to ge-dev
  • Loading branch information
AlexanderGetka-cbica authored Dec 11, 2024
2 parents d10f8ac + af78dbb commit 5b75afd
Show file tree
Hide file tree
Showing 6 changed files with 29 additions and 14 deletions.
3 changes: 3 additions & 0 deletions .dockerignore
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
.github
.git
test
test_data
output_folder
**/*.nii.gz
build
**/build
Expand Down
3 changes: 2 additions & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
1 change: 1 addition & 0 deletions src/viewer/utils/utils_menu.py
Original file line number Diff line number Diff line change
Expand Up @@ -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":
Expand Down
32 changes: 21 additions & 11 deletions src/viewer/utils/utils_session.py
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand All @@ -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


###################################

Expand Down Expand Up @@ -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"])

Expand Down
2 changes: 1 addition & 1 deletion src/viewer/utils/utils_st.py
Original file line number Diff line number Diff line change
Expand Up @@ -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])
Expand Down

0 comments on commit 5b75afd

Please sign in to comment.