Skip to content
Snippets Groups Projects
Commit e9bdc837 authored by Thomas Kluyver's avatar Thomas Kluyver
Browse files

Copy bash script to run notebook to working directory

parent cd10351a
No related branches found
No related tags found
1 merge request!544Reproducibility, step 1
#!/bin/bash #!/bin/bash
# This script is used to run a parameterised copy of a Jupyter notebook. It is
# typically run through Slurm with the sbatch command.
set -euo pipefail set -euo pipefail
......
...@@ -8,6 +8,7 @@ import math ...@@ -8,6 +8,7 @@ import math
import os import os
import pprint import pprint
import re import re
import shutil
import stat import stat
import string import string
import sys import sys
...@@ -771,7 +772,7 @@ def prepare_job( ...@@ -771,7 +772,7 @@ def prepare_job(
nbformat.write(new_nb, nbpath) nbformat.write(new_nb, nbpath)
return JobArgs([ return JobArgs([
"{pkg_dir}/bin/slurm_calibrate.sh", "pycalib-run-nb.sh",
new_name, new_name,
"{python}", "{python}",
cluster_profile, cluster_profile,
...@@ -793,9 +794,7 @@ class JobArgs: ...@@ -793,9 +794,7 @@ class JobArgs:
return isinstance(other, JobArgs) and (self.args == other.args) return isinstance(other, JobArgs) and (self.args == other.args)
def format_cmd(self, python): def format_cmd(self, python):
return [a.format( return [a.format(python=python) for a in self.args]
python=python, pkg_dir=PKG_DIR
) for a in self.args]
def run_direct(self, work_dir, python) -> int: def run_direct(self, work_dir, python) -> int:
return call(self.format_cmd(python), cwd=work_dir) return call(self.format_cmd(python), cwd=work_dir)
...@@ -1014,6 +1013,12 @@ def run(): ...@@ -1014,6 +1013,12 @@ def run():
# And save the invocation of this script itself # And save the invocation of this script itself
save_executed_command(run_tmp_path, version) save_executed_command(run_tmp_path, version)
# Copy the bash script which will be used to run notebooks
shutil.copy2(
os.path.join(PKG_DIR, "bin", "slurm_calibrate.sh"),
os.path.join(run_tmp_path, "pycalib-run-nb.sh")
)
# wait on all jobs to run and then finalize the run by creating a report from the notebooks # wait on all jobs to run and then finalize the run by creating a report from the notebooks
out_path = Path(default_report_path) / detector.upper() / caltype.upper() / datetime.now().isoformat() out_path = Path(default_report_path) / detector.upper() / caltype.upper() / datetime.now().isoformat()
if try_report_to_output: if try_report_to_output:
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment