From 7c38aa4a1ad6dd052a2dbcc6f56b98f0d76a7af0 Mon Sep 17 00:00:00 2001 From: Abdur Rahman Hatim <45071819+hat-im@users.noreply.github.com> Date: Tue, 17 Nov 2026 08:17:36 +0530 Subject: [PATCH 1/2] The status updater creates its directory before its update file --- src/psij/utils.py | 1 + tests/test_status_updater.py | 12 ++++++++++++ 2 files changed, 13 insertions(+) create mode 100644 tests/test_status_updater.py diff --git a/src/psij/utils.py b/src/psij/utils.py index 47357b35a..17ae2256a 100644 --- a/src/psij/utils.py +++ b/src/psij/utils.py @@ -113,6 +113,7 @@ def _get_ips(self) -> List[str]: return r def _create_update_file(self) -> None: + self.work_directory.mkdir(parents=True, exist_ok=True) f = tempfile.NamedTemporaryFile(dir=self.work_directory, prefix='supd_', delete=False) name = f.name self.update_file_name = name diff --git a/tests/test_status_updater.py b/tests/test_status_updater.py new file mode 100644 index 000000000..aabf1075c --- /dev/null +++ b/tests/test_status_updater.py @@ -0,0 +1,12 @@ +import os +import subprocess +import sys +from pathlib import Path + + +def test_a_batch_executor_starts_in_a_home_without_psij_directory(tmp_path: Path) -> None: + subprocess.run([sys.executable, '-c', + 'from psij import JobExecutor; JobExecutor.get_instance("slurm")'], + env={**os.environ, 'HOME': str(tmp_path)}, check=True, capture_output=True) + + assert (tmp_path / '.psij').is_dir() From 22c2586c91f4dd14dcccbfa015f95ae3c5c1e918 Mon Sep 17 00:00:00 2001 From: Abdur Rahman Hatim <45071819+hat-im@users.noreply.github.com> Date: Tue, 17 Nov 2026 20:51:58 +0530 Subject: [PATCH 2/2] The status updater test keeps the user site when it moves HOME --- tests/test_status_updater.py | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/tests/test_status_updater.py b/tests/test_status_updater.py index aabf1075c..1078238ad 100644 --- a/tests/test_status_updater.py +++ b/tests/test_status_updater.py @@ -1,12 +1,16 @@ import os +import site import subprocess import sys from pathlib import Path def test_a_batch_executor_starts_in_a_home_without_psij_directory(tmp_path: Path) -> None: - subprocess.run([sys.executable, '-c', - 'from psij import JobExecutor; JobExecutor.get_instance("slurm")'], - env={**os.environ, 'HOME': str(tmp_path)}, check=True, capture_output=True) + p = subprocess.run([sys.executable, '-c', + 'from psij import JobExecutor; JobExecutor.get_instance("slurm")'], + env={**os.environ, 'HOME': str(tmp_path), + 'PYTHONUSERBASE': site.getuserbase()}, + capture_output=True, text=True) + assert p.returncode == 0, p.stderr assert (tmp_path / '.psij').is_dir()