Skip to content

Commit c58ca1b

Browse files
committed
worker 0 doesnt join default index list mapping. use comm.get_num_workers for initializing resources
1 parent 8da9d41 commit c58ca1b

2 files changed

Lines changed: 9 additions & 4 deletions

File tree

libensemble/resources/worker_resources.py

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -102,10 +102,15 @@ def free_rsets(self, worker=None):
102102

103103
@staticmethod
104104
def get_index_list(num_workers: int, num_rsets: int) -> list[int | None]:
105-
"""Map WorkerID to index into a nodelist"""
105+
"""Map WorkerID to index into a nodelist.
106+
107+
Index 0 is always None since workers are 1-indexed. Worker 0 (gen-on-manager)
108+
resource assignment is handled separately. For gen_on_worker mode, worker 0 is
109+
never started, so index_list[0] is never accessed.
110+
"""
106111
index = 0
107-
index_list: list[int | None] = []
108-
for i in range(0, num_workers + 1):
112+
index_list: list[int | None] = [None] # index 0: worker 0 not in default rset mapping
113+
for i in range(1, num_workers + 1):
109114
if index >= num_rsets:
110115
# Not enough rsets
111116
index_list.append(None)

libensemble/worker.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -223,7 +223,7 @@ def _set_resources(workerID, comm: Comm, libE_specs) -> bool:
223223
"""Sets worker ID in the resources, return True if set"""
224224
resources = Resources.resources
225225
if isinstance(resources, Resources):
226-
resources.set_worker_resources(comm.get_num_workers() + 1, workerID)
226+
resources.set_worker_resources(comm.get_num_workers(), workerID)
227227
return True
228228
else:
229229
logger.debug(f"No resources set on worker {workerID}")

0 commit comments

Comments
 (0)