Description
Description
If installed, matplotlib
is always imported as part of the DVGeoCST class, regardless if DVGeometryCST
is used or not (due to the way we configure our __init__
files). This can cause problems when run on large number of processors (shown in screenshot below) resulting in failed cases.
Steps to reproduce issue
This is difficult to reproduce as it depends on the system and IO, but in principle can be done by simply doing
from pygeo import DVGeometry
Current behavior
Under the right conditions and system, fails as shown above.
Expected behavior
Should not fail on any number of procs
Possible solution
While in principle it should be fine to import matplotlib
on all procs, it does not make much sense to import at all in a parallel code. The only use case is when running an embarrassingly parallel plotting script, which is not the case for this class. Thus, we should remove all matplotlib imports from pygeo.
Removing and refactoring can take several forms.
- let functions take in a
fig
andax
object that can be operated on directly. - move plotting into separate utility functions taking in objects of CST
Limited solutions
There are other ideas that have come up during discussions, but they either partially address the issue or just delay it. Decided to include them below for documentation purposes.
Import only on root proc
Importing only on the root proc (MPI.COMM_WORLD.rank == 0) does alleviate the issue, but does not work if there are multiple proc sets with different comms. Its possible to move the import statements into the class such that the proc set comm is accessible, but this is generally not recommended.
Modify __init__
Modifying __init__
files to not import all pygeo packages and subpackages. This breaks backwards compatibility and does not really solve the fundamental issue either.