Skip to content
Open
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
4 changes: 4 additions & 0 deletions src/asyncmd/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@
TrajectoryFunctionValueCacheInH5PY as _TrajectoryFunctionValueCacheInH5PY,
)
# pylint: disable-next=unused-import
from .slurm import set_slurm_settings, set_all_slurm_settings

Check notice on line 39 in src/asyncmd/config.py

View workflow job for this annotation

GitHub Actions / pylint

I0011

Locally disabling unused-import (W0611)


if typing.TYPE_CHECKING: # pragma: no cover
Expand Down Expand Up @@ -65,7 +65,7 @@
"""
# NOTE: I think we should use a conservative default, e.g. 0.25*cpu_count()
# pylint: disable-next=global-statement
global _SEMAPHORES

Check notice on line 68 in src/asyncmd/config.py

View workflow job for this annotation

GitHub Actions / pylint

I0020

Suppressed 'global-statement' (from line 68)

Check notice on line 68 in src/asyncmd/config.py

View workflow job for this annotation

GitHub Actions / pylint

I0011

Locally disabling global-statement (W0603)
if num is None:
if (logical_cpu_count := os.cpu_count()) is not None:
num = max(1, int(logical_cpu_count / 4))
Expand All @@ -73,7 +73,11 @@
# fallback if os.cpu_count() can not determine the number of cpus
# play it save and not have more than 2?
num = 2
elif num < 1:
raise ValueError("`num` must be at least 1!")
if max_num is not None:
if max_num < 1:
raise ValueError("`max_num` must be at least 1!")
num = min((num, max_num))
_SEMAPHORES[_SEMAPHORES_KEYS.MAX_PROCESS] = asyncio.BoundedSemaphore(num)

Expand Down Expand Up @@ -108,7 +112,7 @@
# and subprocess.check_call [which also need files/pipes to work])
# also maybe we need other open files like a storage :)
# pylint: disable-next=global-statement
global _SEMAPHORES

Check notice on line 115 in src/asyncmd/config.py

View workflow job for this annotation

GitHub Actions / pylint

I0020

Suppressed 'global-statement' (from line 115)

Check notice on line 115 in src/asyncmd/config.py

View workflow job for this annotation

GitHub Actions / pylint

I0011

Locally disabling global-statement (W0603)
rlim_soft = resource.getrlimit(resource.RLIMIT_NOFILE)[0]
if num is None:
num = rlim_soft
Expand Down Expand Up @@ -158,7 +162,7 @@
python/asyncmd. `None` means do not limit the maximum number of jobs.
"""
# pylint: disable-next=global-statement
global _OPT_SEMAPHORES

Check notice on line 165 in src/asyncmd/config.py

View workflow job for this annotation

GitHub Actions / pylint

I0020

Suppressed 'global-statement' (from line 165)

Check notice on line 165 in src/asyncmd/config.py

View workflow job for this annotation

GitHub Actions / pylint

I0011

Locally disabling global-statement (W0603)
if num is None:
_OPT_SEMAPHORES[_OPT_SEMAPHORES_KEYS.SLURM_MAX_JOB] = None
else:
Expand Down Expand Up @@ -196,7 +200,7 @@
Raised if ``cache_type`` is not one of the allowed values.
"""
# pylint: disable-next=global-statement
global _GLOBALS

Check notice on line 203 in src/asyncmd/config.py

View workflow job for this annotation

GitHub Actions / pylint

I0011

Locally disabling global-statement (W0603)
allowed_values = ["h5py", "npz", "memory"]
if (cache_type := cache_type.lower()) not in allowed_values:
raise ValueError(f"Given cache type must be one of {allowed_values}."
Expand Down Expand Up @@ -253,7 +257,7 @@
Whether to clear the old/previously set cache, by default False.
"""
# pylint: disable-next=global-statement
global _GLOBALS

Check notice on line 260 in src/asyncmd/config.py

View workflow job for this annotation

GitHub Actions / pylint

I0011

Locally disabling global-statement (W0603)
if _GLOBALS.get(_GLOBALS_KEYS.TRAJECTORY_FUNCTION_CACHE_TYPE, "not_set") != "h5py":
# nothing to copy as h5py was not the old cache type
if h5py_group.file.mode == "r":
Expand Down Expand Up @@ -328,7 +332,7 @@
"""
print(f"Values controlling caching: {_GLOBALS}")
# pylint: disable-next=protected-access
sem_print = {key: sem._value

Check notice on line 335 in src/asyncmd/config.py

View workflow job for this annotation

GitHub Actions / pylint

I0011

Locally disabling protected-access (W0212)
for key, sem in {**_SEMAPHORES, **_OPT_SEMAPHORES}.items()
if sem is not None}
print(f"Semaphores controlling resource usage: {sem_print}")
7 changes: 7 additions & 0 deletions tests/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,13 @@
reason="Need gromacs (gmx) executable.")


@pytest.fixture
def h5py():
"""Fixture to import h5py."""
return pytest.importorskip("h5py", minversion=None,
reason="Requires 'h5py' to run.")


def pytest_addoption(parser):
parser.addoption(
"--runslow", action="store_true", default=False, help="run slow tests"
Expand Down
Loading
Loading