From 8bf6fb7ef44e2add9d67123f79e9339f35c8552a Mon Sep 17 00:00:00 2001
From: Thomas Kluyver <thomas@kluyver.me.uk>
Date: Wed, 18 Aug 2021 10:21:33 +0100
Subject: [PATCH] Use CWD for notebook paths

---
 src/xfel_calibrate/calibrate.py | 12 ++++++------
 1 file changed, 6 insertions(+), 6 deletions(-)

diff --git a/src/xfel_calibrate/calibrate.py b/src/xfel_calibrate/calibrate.py
index f3f50120e..1aa2896f1 100755
--- a/src/xfel_calibrate/calibrate.py
+++ b/src/xfel_calibrate/calibrate.py
@@ -755,7 +755,7 @@ def prepare_job(
 
     return JobArgs([
         "{pkg_dir}/bin/slurm_calibrate.sh",
-        "{run_tmp_path}/" + new_name,
+        new_name,
         "{python}",
         cluster_profile,
         os.path.splitext(new_name)[0].upper(),
@@ -775,18 +775,18 @@ class JobArgs:
     def __eq__(self, other):
         return isinstance(other, JobArgs) and (self.args == other.args)
 
-    def format_cmd(self, run_tmp_path, python):
+    def format_cmd(self, python):
         return [a.format(
-            run_tmp_path=run_tmp_path, python=python, pkg_dir=PKG_DIR
+            python=python, pkg_dir=PKG_DIR
         ) for a in self.args]
 
     def run_direct(self, run_tmp_path, python) -> int:
-        return call(self.format_cmd(run_tmp_path, python))
+        return call(self.format_cmd(python), cwd=run_tmp_path)
 
     def submit_job(self, run_tmp_path, python, args, after_ok=(), after_any=()):
         cmd = get_launcher_command(args, run_tmp_path, after_ok, after_any)
-        cmd += self.format_cmd(run_tmp_path, python)
-        output = check_output(cmd).decode('utf-8')
+        cmd += self.format_cmd(python)
+        output = check_output(cmd, cwd=run_tmp_path).decode('utf-8')
         return output.partition(';')[0].strip()  # job ID
 
 
-- 
GitLab