Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 7 additions & 6 deletions igf_airflow/utils/dag50_olink_reveal_nextflow_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@
retry_delay=timedelta(minutes=5),
retries=4,
queue='hpc_4G',
multiple_outputs=False)
multiple_outputs=True)
def prepare_olink_nextflow_script(
design_dict: dict,
work_dir: str,
Expand Down Expand Up @@ -138,7 +138,7 @@ def prepare_olink_nextflow_script(
WORKDIR=work_dir
)
)
return nf_script_file.as_posix()
return {"run_script": nf_script_file.as_posix()}
except Exception as e:
log.error(e)
send_airflow_failed_logs_to_channels(
Expand All @@ -153,13 +153,14 @@ def prepare_olink_nextflow_script(
queue='hpc_8G4t72hr',
pool='batch_job',
retries=4)
def run_olink_nextflow_script(run_script: str):
def run_olink_nextflow_script(run_script: str) -> str:
try:
script_dir = os.path.dirname(run_script)
bash_cmd = f"""set -eo pipefail;
cd {script_dir};
chmod u+x {run_script};
bash {run_script}"""
## Move to the script dir
cd {script_dir} ;
chmod u+x {run_script} ;
bash {run_script} ;"""
return bash_cmd
except Exception as e:
log.error(e)
Expand Down
9 changes: 7 additions & 2 deletions test/igf_airflow/test_dag50_olink_reveal_nextflow_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -54,10 +54,11 @@ def test_prepare_olink_nextflow_script(self, *args):
with open(design_yaml_file, "w") as fp:
fp.write(design_yaml)
design_dict = {"analysis_design": design_yaml_file}
analysis_script = prepare_olink_nextflow_script.function(
analysis_script_conf = prepare_olink_nextflow_script.function(
design_dict=design_dict,
work_dir=self.temp_dir
)
analysis_script = analysis_script_conf["run_script"]
assert os.path.exists(analysis_script)
with open(analysis_script, "r") as fp:
script_data = fp.read() ## small file
Expand All @@ -84,7 +85,11 @@ def test_run_olink_nextflow_script(self):
analysis_cmd = run_olink_nextflow_script.function(
script_file
)
assert analysis_cmd == f"set -eo pipefail;\ncd {os.path.dirname(script_file)};\nchmod u+x {script_file};\nbash {script_file}"
assert analysis_cmd == f"""set -eo pipefail;
## Move to the script dir
cd {os.path.dirname(script_file)} ;
chmod u+x {script_file} ;
bash {script_file} ;"""

if __name__=='__main__':
unittest.main()