Skip to content

Commit 725a881

Browse files
committed
add dry-run option
1 parent 209fec0 commit 725a881

File tree

3 files changed

+21
-15
lines changed

3 files changed

+21
-15
lines changed

pages/run_pipeline.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -84,6 +84,7 @@ def reset_button_state():
8484
)
8585
WORK_DIR = st.text_input("Working directory", value=WORK_DIR or SCRATCH)
8686
OUTPUT_DIR = st.text_input("Output directory", value=OUTPUT_DIR or SCRATCH)
87+
dry_run = st.checkbox("Dry run (do not execute the job)", value=False)
8788

8889
# passing inputs between tabs
8990
if OK:
@@ -96,7 +97,8 @@ def reset_button_state():
9697
work_dir=WORK_DIR,
9798
output_dir=OUTPUT_DIR,
9899
custom_sample_list=custom_sample_list,
99-
bed_file=BED_FILE
100+
bed_file=BED_FILE,
101+
dry_run=dry_run
100102
)
101103
save_in_ss(
102104
{

shared/command_helper.py

Lines changed: 14 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,8 @@ def pipe_cmd(
2828
work_dir="work",
2929
output_dir="output",
3030
custom_sample_list=[],
31-
bed_file=""
31+
bed_file="",
32+
dry_run=False
3233
):
3334
def get_pipeline_command():
3435
"""Generate the pipeline execution command based on the sample selection."""
@@ -37,17 +38,19 @@ def get_pipeline_command():
3738
# not sure if this is the best thing-using job id for filenamne
3839
log_out = f"{work_dir}/logs/%j.out"
3940
log_err = f"{work_dir}/logs/%j.err"
40-
41-
args = []
41+
42+
args = [path_to_script]
4243
base_cmd = f"sbatch -o {log_out} -e {log_err}"
4344

4445
if selected_samples == "demo":
45-
args = [path_to_script, work_dir, output_dir]
46+
args += [work_dir, output_dir]
4647

47-
elif selected_samples == "all":
48+
elif selected_samples == "all":#I removed this option
4849
#./your_script.sh --env "/my/custom/env" --work-dir "my_work" --outdir "my_output" --config "my_config" --params "parans.json" --bed file.bed
49-
args = [
50-
path_to_script,
50+
if dry_run:
51+
args.append("--dry-run")
52+
53+
args += [
5154
"--work-dir", work_dir,
5255
"--outdir", output_dir,
5356
]
@@ -57,17 +60,16 @@ def get_pipeline_command():
5760
elif selected_samples == "customised":
5861
if not custom_sample_list:
5962
raise ValueError("custom_sample_list cannot be empty")
60-
args = [
61-
path_to_script,
63+
if dry_run:
64+
args.append("--dry-run")
65+
args += [
6266
"--work-dir", work_dir,
6367
"--outdir", output_dir,
6468
"--samples", "\t".join(custom_sample_list),
6569
]
6670
if bed_file:
6771
args += ["--bed", bed_file]
68-
# elif selected_samples == "test": #this will become dry-run, but I should develop it for all scripts
69-
# cmd_pipeline += f"sbatch -o {log_out} -e {log_err} /data/scratch/DCO/DIGOPS/SCIENCOM/msarkis/NF-project-configurations/test.sh --work-dir {work_dir} --outdir {output_dir}"
70-
72+
7173
preamble = f"""
7274
mkdir -p {work_dir}/logs
7375
cd {work_dir}

tabs/tab_command.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,8 @@ def tab(
1515
work_dir="work",
1616
output_dir="output",
1717
custom_sample_list=[],
18-
bed_file=""
18+
bed_file="",
19+
dry_run=False
1920
):
2021
# --- Initialize session state ---
2122
st.session_state.setdefault("username", username)
@@ -47,7 +48,8 @@ def run_nextflow():
4748
output_dir=output_dir,
4849
work_dir=work_dir,
4950
custom_sample_list=custom_sample_list,
50-
bed_file=bed_file
51+
bed_file=bed_file,
52+
dry_run=dry_run
5153
)
5254
st.code(cmd_pipeline)
5355
result = MY_SSH.run_cmd(cmd_pipeline)

0 commit comments

Comments
 (0)