diff --git a/CHANGELOG.rst b/CHANGELOG.rst index 9ca4d28..5782a55 100644 --- a/CHANGELOG.rst +++ b/CHANGELOG.rst @@ -1,6 +1,12 @@ Changelog ========= +Version 0.11.1 +-------------- + +- Revert raising an error if the env variable SHMDIR isn't set. Log a more detailed warning instead. + + Version 0.11.0 -------------- diff --git a/src/blueetl/utils.py b/src/blueetl/utils.py index 442475f..b7f141a 100644 --- a/src/blueetl/utils.py +++ b/src/blueetl/utils.py @@ -335,15 +335,17 @@ def copy_config(src: StrOrPath, dst: StrOrPath) -> None: dump_yaml(dst, config, default_flow_style=None) -def get_shmdir() -> Path: - """Return the shared memory directory, or raise an error if not set.""" +def get_shmdir() -> Optional[Path]: + """Return the shared memory directory, or return None if not set.""" shmdir = os.getenv("SHMDIR") if not shmdir: - raise RuntimeError( - "SHMDIR must be set to the shared memory directory. " - "The variable should be automatically set when running on an allocated node, " + L.warning( + "SHMDIR should be set to the shared memory directory, " + "or the process may be slower, or even fail because of insufficient space. " + "The variable is automatically set when running on an allocated node, " "but it's not set when connecting via SSH to a pre-allocated node." ) + return None shmdir = Path(shmdir) if not shmdir.is_dir(): raise RuntimeError("SHMDIR must be set to an existing directory") diff --git a/tests/unit/test_utils.py b/tests/unit/test_utils.py index a6a4929..dc54771 100644 --- a/tests/unit/test_utils.py +++ b/tests/unit/test_utils.py @@ -293,8 +293,8 @@ def test_get_shmdir(monkeypatch, tmp_path): assert shmdir == tmp_path monkeypatch.delenv("SHMDIR") - with pytest.raises(RuntimeError, match="SHMDIR must be set to the shared memory directory"): - test_module.get_shmdir() + shmdir = test_module.get_shmdir() + assert shmdir is None monkeypatch.setenv("SHMDIR", str(tmp_path / "non-existent")) with pytest.raises(RuntimeError, match="SHMDIR must be set to an existing directory"):