optimas-org / optimas

Optimization at scale, powered by libEnsemble
https://optimas.readthedocs.io
Other
22 stars 13 forks source link

Add is_manager attribute #205

Closed shuds13 closed 3 months ago

shuds13 commented 4 months ago

Add support for manager only operations when running with MPI communications.

Note that when running with MPI comms, user calling scripts will need to run post-processing operations using this e.g.,


    exploration.run()

    # Get generated points.
    if exploration.is_manager:
        h = exploration.history
        h = h[h["sim_ended"]]
        x0_gen = h["x0"]
        x1_gen = h["x1"]

Supports #203

shuds13 commented 3 months ago

I think I've addressed the comments. Feel free to modify my wording.

AngelFP commented 3 months ago

Any idea why the openMPI tests are failing? I don't see why this happens by looking at the changes. Could it be related to pytest-mpi?

shuds13 commented 3 months ago

Yes the failure was caused by my adding of an mpi4py import in the new test. This gets imported by pytest at the global level (for all tests) and created a nested MPI environment, causing openMPI tests to fail. To do this, test would need to store mpi_comm in exploration.

AngelFP commented 3 months ago

Thanks for checking that! The problem I see now is that the new test will pass no matter what the value of is_manager is, right? Is there any way we could check that it is actually working as expected?

shuds13 commented 3 months ago

I've confirmed without the if exploration.is_manager: the test fails with IndexError, so this test verifies manager only behaviour.

AngelFP commented 3 months ago

Great, thanks for checking. Then we can merge this as is.