Skip to content

Commit dbdf88f

Browse files
committed
platform_specs sometimes seems to be at risk of disappearing when we convert LibeSpecs to dict, so lets save it and reinsert
1 parent 6fa18ef commit dbdf88f

File tree

1 file changed

+8
-2
lines changed

1 file changed

+8
-2
lines changed

libensemble/ensemble.py

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -326,8 +326,14 @@ def libE_specs(self, new_specs):
326326
return
327327

328328
# Cast new libE_specs temporarily to dict
329-
if not isinstance(new_specs, dict):
330-
new_specs = specs_dump(new_specs, by_alias=True, exclude_none=True, exclude_defaults=True)
329+
if not isinstance(new_specs, dict): # exclude_defaults should only be enabled with Pydantic v2
330+
platform_specs_set = False
331+
if new_specs.platform_specs != {}: # bugginess across Pydantic versions for recursively casting to dict
332+
platform_specs_set = True
333+
platform_specs = new_specs.platform_specs
334+
new_specs = specs_dump(new_specs, exclude_none=True, exclude_defaults=True)
335+
if platform_specs_set:
336+
new_specs["platform_specs"] = specs_dump(platform_specs, exclude_none=True)
331337

332338
# Unset "comms" if we already have a libE_specs that contains that field, that came from parse_args
333339
if new_specs.get("comms") and hasattr(self._libE_specs, "comms") and self.parsed:

0 commit comments

Comments
 (0)