diff --git a/src/xfel_calibrate/repeat.py b/src/xfel_calibrate/repeat.py index 3112a960f5f428cce261595347f36c10bdc5739f..e9939b5d39fb223306d00907835ff8f77cf5dc08 100644 --- a/src/xfel_calibrate/repeat.py +++ b/src/xfel_calibrate/repeat.py @@ -95,6 +95,20 @@ def munge_requirements(reqs: str): return '\n'.join(reqs) +def script_fix(cal_work_dir: Path): + # Workaround: until May 2024, this script contained a leftover & unnecessary + # 'module load anaconda/3' command. This module is not available on EL9. + # We don't use the module at all, so we can safely cut the command out. + script = cal_work_dir / "pycalib-run-nb.sh" + if not script.is_file(): + return + + lines = script.read_text().splitlines(keepends=True) + script.write_text(''.join( + l for l in lines if l.strip().split() != ['module', 'load', 'anaconda/3'] + )) + + def main(argv=None): ap = argparse.ArgumentParser() ap.add_argument("from_dir", type=Path, help="A directory containing steps.json") @@ -143,6 +157,8 @@ def main(argv=None): ) print(f"New working directory: {cal_work_dir}") + script_fix(cal_work_dir) # Strip out 'module load anaconda/3' + # Update metadata YAML file & notebooks with any changes cal_metadata = CalibrationMetadata(cal_work_dir) cal_metadata['calibration-configurations'] = parameters