Skip to content

Commit

Permalink
only call ask_updates on gen if its implemented
Browse files Browse the repository at this point in the history
  • Loading branch information
jlnav committed Dec 4, 2024
1 parent bf4577d commit c24730b
Showing 1 changed file with 11 additions and 2 deletions.
13 changes: 11 additions & 2 deletions libensemble/utils/runners.py
Original file line number Diff line number Diff line change
Expand Up @@ -160,7 +160,12 @@ def _get_initial_ask(self, libE_info) -> npt.NDArray:
return H_out

def _get_points_updates(self, batch_size: int) -> (npt.NDArray, list):
return self.gen.ask_numpy(batch_size), self.gen.ask_updates()
numpy_out = self.gen.ask_numpy(batch_size)
if callable(getattr(self.gen, "ask_updates", None)):
updates = self.gen.ask_updates()

Check warning on line 165 in libensemble/utils/runners.py

View check run for this annotation

Codecov / codecov/patch

libensemble/utils/runners.py#L165

Added line #L165 was not covered by tests
else:
updates = None
return numpy_out, updates

def _convert_tell(self, x: npt.NDArray) -> list:
self.gen.tell_numpy(x)
Expand All @@ -179,7 +184,11 @@ def _get_initial_ask(self, libE_info) -> npt.NDArray:
def _ask_and_send(self):
"""Loop over generator's outbox contents, send to manager"""
while not self.gen.thread.outbox.empty(): # recv/send any outstanding messages
points, updates = self.gen.ask_numpy(), self.gen.ask_updates()
points = self.gen.ask_numpy()
if callable(getattr(self.gen, "ask_updates", None)):
updates = self.gen.ask_updates()
else:
updates = None

Check warning on line 191 in libensemble/utils/runners.py

View check run for this annotation

Codecov / codecov/patch

libensemble/utils/runners.py#L191

Added line #L191 was not covered by tests
if updates is not None and len(updates):
self.ps.send(points)
for i in updates:
Expand Down

0 comments on commit c24730b

Please sign in to comment.