Skip to content
Snippets Groups Projects
Commit 964d293f authored by Karim Ahmed's avatar Karim Ahmed
Browse files

Merge branch 'fix/move_retrieve_yml_with_slurm' into 'master'

copy retrieve_constant to slurm and leave latest copy in out-folder

See merge request detectors/pycalibration!378
parents e235e1e4 03246d13
No related branches found
No related tags found
1 merge request!378copy retrieve_constant to slurm and leave latest copy in out-folder
...@@ -186,8 +186,8 @@ def make_timing_summary(run_path, joblist, request_time, submission_time): ...@@ -186,8 +186,8 @@ def make_timing_summary(run_path, joblist, request_time, submission_time):
time_table=time_table.split('\n')))) time_table=time_table.split('\n'))))
def make_report(run_path, tmp_path, out_path, project, author, version, def make_report(run_path: str, tmp_path: str, out_path: str, project: str,
report_to): author: str, version: str, report_to: str):
""" """
Create calibration report (pdf file) Create calibration report (pdf file)
...@@ -201,12 +201,13 @@ def make_report(run_path, tmp_path, out_path, project, author, version, ...@@ -201,12 +201,13 @@ def make_report(run_path, tmp_path, out_path, project, author, version,
:param project: Project title :param project: Project title
:param author: Author of the notebook :param author: Author of the notebook
:param version: Version of the notebook :param version: Version of the notebook
:param report_to: Name or path of the report file :param report_to: report path tailed with report name
""" """
run_path = path.abspath(run_path) run_path = path.abspath(run_path)
report_path, report_name = path.split(report_to) report_path, report_name = path.split(report_to)
if report_path != '':
out_path = report_path if not report_path:
report_path = out_path
try: try:
check_call([sys.executable, "-m", "sphinx.cmd.quickstart", check_call([sys.executable, "-m", "sphinx.cmd.quickstart",
...@@ -299,16 +300,18 @@ def make_report(run_path, tmp_path, out_path, project, author, version, ...@@ -299,16 +300,18 @@ def make_report(run_path, tmp_path, out_path, project, author, version,
# finally call the make scripts # finally call the make scripts
chdir(run_path) chdir(run_path)
try: try:
check_call(["make", f"SPHINXBUILD={sys.executable} -m sphinx", "latexpdf"]) check_call(["make", f"SPHINXBUILD={sys.executable} -m sphinx",
"latexpdf"])
except CalledProcessError: except CalledProcessError:
print("Failed to make pdf documentation") print("Failed to make pdf documentation")
print("Temp files will not be deleted and " + print("Temp files will not be deleted and "
"can be inspected at: {}".format(run_path)) f"can be inspected at: {run_path}")
return return
print("Moving report to final location: {}".format(out_path))
makedirs(out_path, exist_ok=True) print(f"Moving report to final location: {report_path}")
copy('{}/_build/latex/{}.pdf'.format(run_path, report_name), out_path) makedirs(report_path, exist_ok=True)
copy(f'{run_path}/_build/latex/{report_name}.pdf', report_path)
temp_dirs = glob(f'{tmp_path}/*/') temp_dirs = glob(f'{tmp_path}/*/')
# Remove folders with figures and sphinx files. # Remove folders with figures and sphinx files.
...@@ -318,15 +321,15 @@ def make_report(run_path, tmp_path, out_path, project, author, version, ...@@ -318,15 +321,15 @@ def make_report(run_path, tmp_path, out_path, project, author, version,
# Archiving files in slurm_tmp # Archiving files in slurm_tmp
if os.path.isfile(f'{out_path}/retrieved_constants.yml'): if os.path.isfile(f'{out_path}/retrieved_constants.yml'):
move(f'{out_path}/retrieved_constants.yml', copy(f'{out_path}/retrieved_constants.yml',
f"{tmp_path}") f"{tmp_path}")
# Moving temporary files to out-folder after successful execution # Moving temporary files to out-folder after successful execution
# This helps in keeping elements needed for re-producibility. # This helps in keeping elements needed for re-producibility.
print(f"Moving temporary files to final location" print(f"Moving temporary files to final location"
f": {out_path}/{os.path.basename(tmp_path)} with name: " f": {report_path}/{os.path.basename(tmp_path)} with name: "
f"slurm_out_{report_name}") f"slurm_out_{report_name}")
move(tmp_path, f"{out_path}/slurm_out_{report_name}") move(tmp_path, f"{report_path}/slurm_out_{report_name}")
def make_titlepage(sphinx_path, project, data_path, version): def make_titlepage(sphinx_path, project, data_path, version):
......
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