forked from equinor/xtgeo
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
CLN: Dynamically import matplotlib and pyplot
Normally dynamically importing modules is fairly straight forward: you can just import them in the function or method they are used in. However, by default matplotlib will look for display settings on the machine it's being run on and compute cluster nodes do not have this set. The suggested solution to this is to import matplotlib before anything else is imported, and set its backend to `use("Agg")` which doesn't look for display information. xtgeo implemented this by importing matplotlib in the root __init__, and it generally complicates the dynamic loading situation. This solution tries to ensure that using the Agg backend will still be triggered if it xtgeo believes it is in batch mode and wraps a getting around `sys.modules` after importing it. It also tries not to repeat the import logic if it is already imported.
- Loading branch information
Showing
9 changed files
with
149 additions
and
101 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.