Skip to content

Commit

Permalink
rename entity config field
Browse files Browse the repository at this point in the history
  • Loading branch information
ankona committed Feb 22, 2024
1 parent ea4b847 commit 3564690
Show file tree
Hide file tree
Showing 5 changed files with 11 additions and 17 deletions.
2 changes: 1 addition & 1 deletion smartsim/_core/control/job.py
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ def __init__(self) -> None:
self.type: str = ""
self.timestamp: int = 0
self.status_dir: str = ""
self.meta: t.Dict[str, str] = {}
self.config: t.Dict[str, str] = {}

@property
def is_db(self) -> bool:
Expand Down
20 changes: 7 additions & 13 deletions smartsim/_core/entrypoints/telemetrymonitor.py
Original file line number Diff line number Diff line change
Expand Up @@ -194,8 +194,8 @@ def __init__(self, entity: JobEntity, sink: Sink) -> None:
super().__init__(entity, sink)
self._client: t.Optional[redis.Redis[bytes]] = None
self._address = _Address(
self._entity.meta.get("host", "127.0.0.1"),
int(self._entity.meta.get("port", 6379)),
self._entity.config.get("host", "127.0.0.1"),
int(self._entity.config.get("port", 6379)),
)

async def _configure_client(self) -> None:
Expand Down Expand Up @@ -345,8 +345,7 @@ def find_collectors(cls, entity: JobEntity) -> t.List[Collector]:
@property
def all_collectors(self) -> t.Iterable[Collector]:
"""Get a list of all managed collectors"""
chain = itertools.chain(*self._collectors.values())
return list(chain)
return list(itertools.chain(*self._collectors.values()))


@dataclass
Expand Down Expand Up @@ -402,8 +401,8 @@ def _hydrate_persistable(
if entity.is_db:
print("nice db you got there... shame to lose it!")
# db shards are hydrated individually
entity.meta["host"] = persistable_entity.get("hostname", "NO-DB-HOSTNAME")
entity.meta["port"] = persistable_entity.get("port", "NO-DB-PORT")
entity.config["host"] = persistable_entity.get("hostname", "NO-DB-HOSTNAME")
entity.config["port"] = persistable_entity.get("port", "NO-DB-PORT")

return entity

Expand Down Expand Up @@ -775,18 +774,13 @@ async def on_timestep(self, timestamp: int) -> None:
:param experiment_dir: the experiement directory to monitor for changes
:type experiment_dir: pathlib.Path
"""
entity_map = self._tracked_jobs

if not self._launcher:
return

# consider not using name to avoid collisions
names = {entity.name: entity for entity in entity_map.values()}

# trigger all metric collection for the timestep
await self._collector.collect()

if names:
# consider not using name to avoid collisions
if names := {entity.name: entity for entity in self._tracked_jobs.values()}:
step_updates = self._launcher.get_step_update(list(names.keys()))

for step_name, step_info in step_updates:
Expand Down
2 changes: 1 addition & 1 deletion tests/test_collector_manager.py
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ def _mock_entity(
entity.name = name if name else str(uuid.uuid4())
entity.status_dir = test_dir
entity.type = type
entity.meta = {
entity.config = {
"host": host,
"port": port,
}
Expand Down
2 changes: 1 addition & 1 deletion tests/test_collector_sink.py
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ def _mock_entity(
entity.name = name if name else str(uuid.uuid4())
entity.status_dir = test_dir
entity.type = type
entity.meta = {
entity.config = {
"host": host,
"port": port,
}
Expand Down
2 changes: 1 addition & 1 deletion tests/test_collectors.py
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ def _mock_entity(
entity.name = name if name else str(uuid.uuid4())
entity.status_dir = test_dir
entity.type = type
entity.meta = {
entity.config = {
"host": host,
"port": port,
}
Expand Down

0 comments on commit 3564690

Please sign in to comment.