Skip to content

Commit

Permalink
fix: use MPILock instead of single rank selection.
Browse files Browse the repository at this point in the history
  • Loading branch information
drodarie committed Dec 16, 2024
1 parent 5289acd commit eedad94
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 3 deletions.
3 changes: 2 additions & 1 deletion bsb/storage/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@

from .. import plugins
from ..exceptions import UnknownStorageEngineError
from ..services import MPILock
from ..services.mpi import MPIService

if typing.TYPE_CHECKING:
Expand Down Expand Up @@ -389,7 +390,7 @@ def open_storage(root, comm=None):
"""
engines = get_engines()
for name, engine in engines.items():
if engine.peek_exists(root) and engine.recognizes(root, MPIService(comm)):
if engine.peek_exists(root) and engine.recognizes(root, MPILock.sync(comm)):
return Storage(name, root, comm, missing_ok=False)
else:
for name, engine in engines.items():
Expand Down
8 changes: 6 additions & 2 deletions bsb/storage/interfaces.py
Original file line number Diff line number Diff line change
Expand Up @@ -116,9 +116,13 @@ def root_slug(self):

@staticmethod
@abc.abstractmethod
def recognizes(root, comm):
def recognizes(root, lock):
"""
Must return whether the given argument is recognized as a valid storage object.
Must return whether the given root argument is recognized as a valid storage object.
:param root: The unique identifier for the storage
:param lock: Window to synchronize read write operations across
all MPI processes in the communicator.
"""
pass

Expand Down

0 comments on commit eedad94

Please sign in to comment.