Repository navigation
Conversation
…ebase # Conflicts: # docs/data_structures/libE_specs/libE_specs_general.rst # libensemble/tools/persistent_support.py
The live queue.Queue objects held by QueueGenerator can't be pickled once libE spawns sim-only worker processes under comms=local (multiprocessing's spawn start method - always on macOS/Windows, and the default everywhere as of Python 3.14). gen_specs, including the generator instance, is pickled for every sim worker regardless of whether it ever runs the generator. QueueGenerator.__getstate__ now drops the live queues before pickling, since sim-only workers never use them (the generator always runs on the manager by default). QueueService also now asserts gen_on_worker is not set, since this generator's queues are only valid in the manager's process/thread.
QueueService already asserted gen_on_worker=False, but QueueGenerator is documented for direct use too (bypassing that guard). Add a _check_queues guard in suggest()/ingest() so a generator that ends up on a worker process (losing its queues via __getstate__) fails with a clear RuntimeError instead of a confusing AttributeError. Add unit tests covering both paths.
|
Good catch from offline discussion: Pushed a follow-up commit (607cbd9) that adds a |
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## develop #1794 +/- ##
===========================================
+ Coverage 88.77% 88.99% +0.21%
===========================================
Files 73 74 +1
Lines 8658 8793 +135
Branches 1402 1420 +18
===========================================
+ Hits 7686 7825 +139
+ Misses 725 721 -4
Partials 247 247 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
Summary
This is a rebase of @shuds13 PR #1737 ("Add libE service mode") onto current
develop, opened as a separate PR (rather than pushing to thefeature/libe_service_modebranch) to avoid surprising him with new activity there. Happy to close this in favor of him updating #1737 directly if preferred.#1737 had gone stale and diverged significantly from
develop. While rebasing and testing it, I found and fixed one additional bug beyond the manager hang already fixed on develop in a5dd111 (which this branch inherits via the merge):QueueGenerator pickling under
comms="local"QueueGenerator/QueueService(libensemble/gen_classes/queue_gen.py) stored livequeue.Queueobjects (andQueueServiceadditionally athreading.Thread) as plain instance attributes. Undercomms="local"(multiprocessing withspawn, the default on macOS/Windows and the default everywhere as of Python 3.14),gen_specs-- including the generator instance -- gets pickled for every spawned worker process, even sim-only ones.queue.Queueholds athreading.Lock, which is unpicklable underspawn, causing all three of this PR's own regression tests to fail 100% of the time undercomms="local".Fixed by:
QueueGenerator.__getstate__to stripinput_queue/output_queuebefore pickling (the generator always runs on the manager; sim-only workers never need these).assert not getattr(libE_specs, "gen_on_worker", False)guard inQueueService.__init__, since this generator's queues are only valid in the manager's own process/thread.Changes
developinto the originalfeature/libe_service_modebranch (resolved a doc conflict inlibE_specs_general.rstand a duplicate-fix conflict inpersistent_support.py).libensemble/gen_classes/queue_gen.py: pickling fix described above.Testing
test_queue_gen.py,test_queue_gen_streaming.py,test_queue_gen_idle_timeout.py(this PR's own new regression tests) all pass undercomms="local".test_manager_main.pyunit tests pass.black/flake8/pre-commitclean.Depends on / overlaps with #1793 (regression test for the manager hang bug, targeted at develop separately since that fix already lives there).