Skip to content

Commit fe35538

Browse files
authored
Merge pull request #86 from MiraGeoscience/GEOPY-2195
GEOPY-2195: Broadcasting of update fails on multiple workers
2 parents 277b8bd + f504342 commit fe35538

1 file changed

Lines changed: 8 additions & 7 deletions

File tree

simpeg/dask/objective_function.py

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -72,14 +72,15 @@ def _validate_type_or_future_of_type(
7272
property_name, objects, obj_type, ensure_unique=True
7373
)
7474
workload = [[]]
75+
lookup = {}
7576
count = 0
7677
for obj in objects:
7778
if count == len(workers):
7879
count = 0
7980
workload.append([])
8081
obj.simulation.simulations[0].worker = workers[count]
8182
future = client.scatter([obj], workers=workers[count])[0]
82-
83+
lookup[obj] = (future, workers[count])
8384
if hasattr(obj, "name"):
8485
future.name = obj.name
8586

@@ -100,7 +101,7 @@ def _validate_type_or_future_of_type(
100101
raise TypeError(f"{property_name} futures must be an instance of {obj_type}")
101102

102103
if return_workers:
103-
return workload, workers
104+
return workload, workers, lookup
104105
else:
105106
return workload
106107

@@ -390,7 +391,7 @@ def objfcts(self):
390391
def objfcts(self, objfcts):
391392
client = self.client
392393

393-
futures, workers = _validate_type_or_future_of_type(
394+
futures, workers, lookup = _validate_type_or_future_of_type(
394395
"objfcts",
395396
objfcts,
396397
L2DataMisfit,
@@ -404,8 +405,8 @@ def objfcts(self, objfcts):
404405
self._workers = workers
405406

406407
self._lookup = {
407-
obj.simulation: (future, worker)
408-
for future, worker, obj in zip(futures[0], workers, objfcts)
408+
misfit.simulation: (future, worker)
409+
for misfit, (future, worker) in lookup.items()
409410
}
410411

411412
def residuals(self, m, f=None):
@@ -443,12 +444,12 @@ def broadcast_updates(self, updates: dict):
443444
if fun not in self._lookup:
444445
continue
445446

446-
objfct, worker = self._lookup[fun]
447+
future, worker = self._lookup[fun]
447448

448449
stores.append(
449450
client.submit(
450451
_setter_broadcast,
451-
objfct,
452+
future,
452453
key,
453454
value,
454455
workers=worker,

0 commit comments

Comments
 (0)