Skip to content

Commit 51e5092

Browse files
committed
refactor retrieve_all_from_ss
1 parent 82094a6 commit 51e5092

File tree

5 files changed

+29
-20
lines changed

5 files changed

+29
-20
lines changed

shared/sessionstate.py

Lines changed: 14 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -19,19 +19,17 @@ def save_in_ss(data_dict):
1919

2020

2121
def retrieve_all_from_ss():
22-
OK = ss_get("LOGIN_OK", False)
23-
MY_SSH = ss_get("MY_SSH", None)
24-
username = ss_get("user_name", "")
25-
GROUPS = ss_get("GROUPS", "")
26-
GROUP = ss_get("GROUP", "")
27-
SCRATCH = ss_get("SCRATCH", "")
28-
RDS = ss_get("RDS", "")
29-
PROJECT = ss_get("PROJECT", None)
30-
SAMPLE = ss_get("SAMPLE", None)
31-
PIPELINE = ss_get("PIPELINE", "select")
32-
return OK, MY_SSH, username, GROUPS, GROUP, SCRATCH, RDS, PROJECT, SAMPLE, PIPELINE
33-
34-
35-
# keys = ["LOGIN_OK", "MY_SSH", "user_name", "GROUPS", "GROUP", "SCRATCH", "RDS"]
36-
# def retrieve_all_from_ss(keys):
37-
# return {key: ss_get(key, default_value) for key, default_value in zip(keys, [False, None, "", "", "", "", ""])}
22+
keys_defaults = {
23+
"LOGIN_OK": False,
24+
"MY_SSH": None,
25+
"user_name": "",
26+
"GROUPS": "",
27+
"GROUP": "",
28+
"SCRATCH": "",
29+
"RDS": "",
30+
"PROJECT": None,
31+
"SAMPLE": None,
32+
"PIPELINE": "select",
33+
}
34+
35+
return tuple(ss_get(key, default) for key, default in keys_defaults.items())

tabs/tab_command.py

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,18 @@
1515
if "job_id" not in st.session_state:
1616
ss_set("job_id", "")
1717
# pull saved values if set, otherwise set to defaults
18-
OK, MY_SSH, username, GROUPS, GROUP, SCRATCH, RDS, PROJECT, SAMPLE, PIPELINE = retrieve_all_from_ss()
18+
(
19+
OK,
20+
MY_SSH,
21+
username,
22+
GROUPS,
23+
GROUP,
24+
SCRATCH,
25+
RDS,
26+
PROJECT,
27+
SAMPLE,
28+
PIPELINE,
29+
) = retrieve_all_from_ss()
1930

2031

2132
def get_path_to_script(selected_pipeline, selected_project, selected="all"):

tabs/tab_logon.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
def tab():
99
# pull saved values if set, otherwise set to defaults
1010
keys = ["LOGIN_OK", "MY_SSH", "user_name", "GROUPS", "GROUP", "SCRATCH", "RDS", "PROJECT", "SAMPLE"]
11-
OK, MY_SSH, username, GROUPS, GROUP, SCRATCH, RDS, PROJECT, SAMPLE, PIPELINE = retrieve_all_from_ss()
11+
(OK, MY_SSH, username, GROUPS, GROUP, SCRATCH, RDS, PROJECT, SAMPLE, PIPELINE) = retrieve_all_from_ss()
1212
cols = st.columns(3)
1313
with cols[0]:
1414
server = st.text_input("Enter your remote server:", "alma.icr.ac.uk", key="server")

views/login.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212

1313
tl.tab()
1414
# pull saved values if set, otherwise set to defaults
15-
OK, MY_SSH, username, GROUPS, GROUP, SCRATCH, RDS, PROJECT, SAMPLE, PIPELINE = retrieve_all_from_ss()
15+
(OK, MY_SSH, username, GROUPS, GROUP, SCRATCH, RDS, PROJECT, SAMPLE, PIPELINE) = retrieve_all_from_ss()
1616

1717

1818
# I want to move between tabs automatically

views/run_pipeline.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ def reset_button_state():
1515
st.write("Select your pipeline and your project, then submit the process")
1616

1717
# pull saved values if set, otherwise set to defaults
18-
OK, MY_SSH, username, GROUPS, GROUP, SCRATCH, RDS, PROJECT, SAMPLE, PIPELINE = retrieve_all_from_ss()
18+
(OK, MY_SSH, username, GROUPS, GROUP, SCRATCH, RDS, PROJECT, SAMPLE, PIPELINE) = retrieve_all_from_ss()
1919

2020
samples = ["all", "demo"] # , "customised"]
2121

0 commit comments

Comments
 (0)