Skip to content

Remove maplotlib import from pygeo modules #271

Open
@eirikurj

Description

@eirikurj

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.

Image

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 and ax 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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions