Skip to content

Commit

Permalink
Revert raising an error if the env variable SHMDIR isn't set (#43)
Browse files Browse the repository at this point in the history
  • Loading branch information
GianlucaFicarelli committed May 3, 2024
1 parent 2b0b888 commit 1ab2b3e
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 7 deletions.
6 changes: 6 additions & 0 deletions CHANGELOG.rst
Original file line number Diff line number Diff line change
@@ -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
--------------

Expand Down
12 changes: 7 additions & 5 deletions src/blueetl/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -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")
Expand Down
4 changes: 2 additions & 2 deletions tests/unit/test_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -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"):
Expand Down

0 comments on commit 1ab2b3e

Please sign in to comment.