diff --git a/custom_files/pipeline_project_map.json b/custom_files/pipeline_project_map.json
new file mode 100644
index 0000000..6102957
--- /dev/null
+++ b/custom_files/pipeline_project_map.json
@@ -0,0 +1,5 @@
+{
+ "epi2me-human-variation": ["nf-long-reads"],
+ "epi2me-somatic-variation": ["mopopgen-support"],
+ "nfcore-rnaseq": ["nf-tp53"]
+}
diff --git a/custom_files/user_whitelist.tsv b/custom_files/user_whitelist.tsv
new file mode 100644
index 0000000..117c283
--- /dev/null
+++ b/custom_files/user_whitelist.tsv
@@ -0,0 +1,7 @@
+username group account-code
+admin admin None
+msarkis SCIENCOM None
+ralcraft SCIENCOM None
+sstephens OGENETIC None
+jhouseham UNKNOWN None
+ahyde1 MOPOPGEN None
diff --git a/index.py b/index.py
index 9fe4685..c2b0241 100644
--- a/index.py
+++ b/index.py
@@ -9,8 +9,8 @@
def main():
- p1 = st.Page("pages/login.py")
- p2 = st.Page("pages/run_pipeline.py")
+ p1 = st.Page("views/login.py")
+ p2 = st.Page("views/run_pipeline.py")
nav_pages = [p1, p2]
pages = {"p1": p1, "p2": p2}
st.session_state["pages"] = pages
diff --git a/pages/login.py b/pages/login.py
deleted file mode 100644
index b9c6609..0000000
--- a/pages/login.py
+++ /dev/null
@@ -1,45 +0,0 @@
-import streamlit as st
-
-import shared.sessionstate as ss
-import tabs.tab_logon as tl
-
-header = """
-
-
-đ RUN-NEXTFLOWđ-
- """
-st.markdown(header, unsafe_allow_html=True)
-
-st.write("--- ")
-
-st.write("## Login")
-st.write("Login to your alma account before running a nextflow pipeline.")
-
-OK, MY_SSH, username = tl.tab()
-
-ss.ss_set("LOGIN_OK", OK)
-ss.ss_set("MY_SSH", MY_SSH)
-ss.ss_set("user_name", username)
-
-
-# I want to move between tabs automatically
-# move between tabs
-def display():
- st.session_state["run_pipeline"] = True
- if st.session_state.get("run_pipeline", False) and "login" in st.session_state:
- if "pages" in st.session_state:
- page = st.session_state["pages"].get("p2", None)
- if page:
- st.switch_page(page)
-
-
-if "login" not in st.session_state:
- st.session_state["login"] = {}
-if "run_pipeline" not in st.session_state:
- st.session_state["run_pipeline"] = False
-
-if OK:
- display()
diff --git a/pipeline_project_map.py b/pipeline_project_map.py
new file mode 100644
index 0000000..a18c037
--- /dev/null
+++ b/pipeline_project_map.py
@@ -0,0 +1,11 @@
+import json
+
+
+def load_json_to_dict(file_path):
+ with open(file_path, "r") as file:
+ data = json.load(file)
+ return data
+
+
+file_path = "custom_files/pipeline_project_map.json"
+map_pipeline_project = load_json_to_dict(file_path)
diff --git a/tabs/tab_command.py b/tabs/tab_command.py
index 2a9e0fd..9697976 100644
--- a/tabs/tab_command.py
+++ b/tabs/tab_command.py
@@ -5,7 +5,9 @@
import pandas as pd
import streamlit as st
-# from ping3 import ping
+# Initialize session state variables
+if "run_pipeline_clicked" not in st.session_state:
+ st.session_state.run_pipeline_clicked = False
@contextmanager
@@ -67,6 +69,9 @@ def tab(username, MY_SSH, selected_pipeline, selected_project, selected_samples=
)
def run_nextflow(): # username, MY_SSH, selected_pipeline, selected_project):
+ st.success("Button clicked!")
+ print("run_nextflow was called")
+ return True # temporary
cmd_pipeline = pipe_cmd(
username, selected_pipeline, selected_project, cmd_num=0, selected_samples="all"
) # develop this
@@ -90,5 +95,14 @@ def check_queue(): # username):
st.error(err_str)
left_column, right_column = st.columns(2)
- left_column.button(f"Run the selected nextflow pipeline for {username}", on_click=run_nextflow)
+ # disable button once the user click a first time. by default it gets disabled after calling the callback
+ v = left_column.button(
+ f"Run the selected nextflow pipeline for {username}", disabled=st.session_state.run_pipeline_clicked
+ ) # on_click=run_nextflow,
+ if v:
+ st.session_state.run_pipeline_clicked = True
+ run_nextflow()
+ print("session value:", st.session_state.run_pipeline_clicked)
+ # st.session_state.run_pipeline_clicked = True
+
right_column.button(f"Check queue for {username}", key="checkqueue", on_click=check_queue)
diff --git a/views/login.py b/views/login.py
new file mode 100644
index 0000000..92e1c4b
--- /dev/null
+++ b/views/login.py
@@ -0,0 +1,85 @@
+import pandas as pd
+import streamlit as st
+
+import shared.sessionstate as ss
+import tabs.tab_logon as tl
+
+header = """
+
+
-đ RUN-NEXTFLOWđ-
+ """
+st.markdown(header, unsafe_allow_html=True)
+
+st.write("--- ")
+
+st.write("## Login")
+st.write("Login to your alma account before running a nextflow pipeline.")
+
+OK, MY_SSH, username = tl.tab()
+
+ss.ss_set("LOGIN_OK", OK)
+ss.ss_set("MY_SSH", MY_SSH)
+ss.ss_set("user_name", username)
+
+
+# I want to move between tabs automatically
+# move between tabs
+def display():
+ st.session_state["run_pipeline"] = True
+ if st.session_state.get("run_pipeline", False) and "login" in st.session_state:
+ if "pages" in st.session_state:
+ page = st.session_state["pages"].get("p2", None)
+ if page:
+ st.switch_page(page)
+
+
+def display_restricted_access(username):
+ st.error(
+ f"â ī¸ Access Restricted â ī¸\n\n"
+ f"Dear {username},\n\n"
+ "We apologize, but access to the nextflow-app is currently restricted. "
+ "For any requests or further information, please contact our support team.\n\n"
+ "**Contact Information:**\n"
+ "- **Name:** Mira Sarkis\n"
+ "- **Department:** Scientific Computing Helpdesk (SCHelpdesk)\n"
+ "- **Email:** [schelpdesk@icr.ac.uk](mailto:schelpdesk@icr.ac.uk)\n\n"
+ "Thank you for your understanding."
+ )
+
+ st.info(
+ "âšī¸ **Note:** Please include your username and the reason for your request "
+ "when contacting the support team. This will help us process your request more efficiently."
+ )
+
+
+def update_session_info(group, cost_account):
+ ss.ss_set("user_group", group)
+ ss.ss_set("user_cost_account", cost_account)
+
+
+def check_whiteList(username):
+ whitelist = "custom_files/user_whitelist.tsv"
+ df = pd.read_csv(whitelist, delimiter="\t")
+ row = df.loc[df["username"] == username]
+ if row.empty: # user not on the white liste
+ return False
+
+ # update session info
+ update_session_info(row["group"], row["account-code"])
+ return True
+
+
+if "login" not in st.session_state:
+ st.session_state["login"] = {}
+if "run_pipeline" not in st.session_state:
+ st.session_state["run_pipeline"] = False
+
+if OK:
+ if not check_whiteList(username):
+ display_restricted_access(username)
+ else:
+ display()
diff --git a/pages/run_pipeline.py b/views/run_pipeline.py
similarity index 69%
rename from pages/run_pipeline.py
rename to views/run_pipeline.py
index 1584ed4..1b770ac 100644
--- a/pages/run_pipeline.py
+++ b/views/run_pipeline.py
@@ -2,6 +2,18 @@
import shared.sessionstate as ss
import tabs.tab_command as tt
+from pipeline_project_map import map_pipeline_project
+
+# Initialize session state variables
+if "select1_value" not in st.session_state:
+ st.session_state.select1_value = None
+if "select2_value" not in st.session_state:
+ st.session_state.select2_value = None
+
+
+def reset_button_state():
+ st.session_state.button_clicked = False
+
header = """
@@ -22,23 +34,21 @@
MY_SSH = ss.ss_get("MY_SSH")
username = ss.ss_get("user_name")
-pipelines = ["epi2me-human-variation", "epi2me-somatic-variation", "nfcore-rnaseq"]
-projects = ["nf-long-reads", "nf-tp53", "mopopgen-support"]
samples = ["all", "demo"] # , "customised"]
-
-map_pipeline_project = {
- "epi2me-human-variation": ["nf-long-reads"],
- "epi2me-somatic-variation": ["nf-tp53"],
- "nfcore-rnaseq": ["mopopgen-support"],
-}
selected_project = None
selected_samples = None
+
# adding "select" as the first and default choice
selected_pipeline = st.selectbox("Select a pipeline", options=["select"] + list(map_pipeline_project.keys()))
# display selectbox 2 if selected_pipeline is not "select"
if selected_pipeline != "select":
- selected_project = st.selectbox("Select your project", options=map_pipeline_project[selected_pipeline])
- selected_samples = st.selectbox("Select your samples", samples)
+ selected_project = st.selectbox(
+ "Select your project",
+ options=map_pipeline_project[selected_pipeline],
+ on_change=reset_button_state,
+ key="select_pipeline",
+ )
+ selected_samples = st.selectbox("Select your samples", samples, on_change=reset_button_state, key="selecct_samples")
# passing inputs between tabs
if LOGIN_OK: