Skip to content

Commit

Permalink
wip: removed _cached_sensors_config from coordination, handled by per…
Browse files Browse the repository at this point in the history
…un class
  • Loading branch information
JuanPedroGHM committed Jul 26, 2023
1 parent f6d0474 commit 94713db
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 13 deletions.
14 changes: 2 additions & 12 deletions perun/coordination.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,10 @@
import platform
from typing import Dict, List, Optional, Set, Tuple

from perun import log
from perun.backend import Backend
from perun.comm import Comm

_cached_sensor_config: Optional[Tuple[Dict, List]] = None


def getHostRankDict(comm: Comm) -> Dict[str, List[int]]:
"""Return a dictionary with all the host names with each MPI rank in them.
Expand Down Expand Up @@ -69,15 +67,7 @@ def getLocalSensorRankConfiguration(
Returns:
Tuple[List[int], Dict[str, Set[str]]]: Local rank and sensor configuration
"""
global _cached_sensor_config
if _cached_sensor_config is None:
globalHostRanks, globalSensorConfig = getGlobalSensorRankConfiguration(
comm, backends
)
_cached_sensor_config = (globalHostRanks, globalSensorConfig)
else:
globalHostRanks, globalSensorConfig = _cached_sensor_config

globalHostRanks, globalSensorConfig = getGlobalSensorRankConfiguration( comm, backends)
return globalHostRanks[platform.node()], globalSensorConfig[comm.Get_rank()]


Expand Down
8 changes: 7 additions & 1 deletion perun/perun.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ def comm(self) -> Comm:
os.environ["IBV_FORK_SAFE"] = "1"
os.environ["RDMAV_FORK_SAFE"] = "1"

self.comm = Comm()
self._comm = Comm()

return self._comm

Expand All @@ -57,6 +57,12 @@ def backends(self) -> List[Backend]:
log.warning(e)

return self._backends

@property
def sensors(self) -> List[Sensor]:
if not self._sensors:

return self._sensors

def monitor_application(
self,
Expand Down

0 comments on commit 94713db

Please sign in to comment.