Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Revert raising an error if the env variable SHMDIR isn't set #43

Merged
merged 1 commit into from
May 3, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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