-
Notifications
You must be signed in to change notification settings - Fork 142
refactor: do not import ansys.tools.visualizer by default when importing ansys.mapdl.core #3887
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
|
Thanks for opening a Pull Request. If you want to perform a review write a comment saying: @ansys-reviewer-bot review |
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #3887 +/- ##
==========================================
- Coverage 88.29% 88.28% -0.02%
==========================================
Files 187 187
Lines 14819 14830 +11
==========================================
+ Hits 13084 13092 +8
- Misses 1735 1738 +3 🚀 New features to boost your workflow:
|
|
@koubaa it seems you still need the
|
|
Thanks to your PR I realised that there a bit of code duplicity. I will take care of that in a follow up PR. Additionally what I meant with pymapdl/src/ansys/mapdl/core/misc.py Line 420 in edb6b18
|
|
You might want to remove this: pymapdl/src/ansys/mapdl/core/plotting/visualizer.py Lines 46 to 51 in 8ca84ba
|
Don't import plotter from post module
for more information, see https://pre-commit.ci
…nsys/pymapdl into check-installed-without-import
|
This change has grown because the visualization interface is loaded on startup in multiple places, and I've modified it not to load on startup at all. This may break some scripts, but none of the examples we distribute are affected |
|
Ping me when this is ready (CICD is failing at the moment) |
…nsys/pymapdl into check-installed-without-import
|
@germa89 I fixed the tests but there is one failure in autodoc that I don't understand: WARNING: autodoc: failed to import class 'MapdlPlotter' from module 'ansys.mapdl.core.plotting'; the following exception was raised: I made sure that all the references to MapdlPlotter use the full namespace in the pymapdl repo. Does autodoc pull from other repos too? |
|
@koubaa the documentation failure was due to using previous build cache. I cleaned it up using this workflow and now it seems fine. Additionally, codacy is showing this warning, but I guess it is fine... so I will disable it.
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I am not particularly happy with having variables in a module to be initialized after the first plot.
from ansys.mapdl.core.plotting import MapdlPlotter
from ansys.mapdl.core.plotting import BC_plot_settings # Fails
# plot somethin
pl = MapdlPlotter()
from ansys.mapdl.core.plotting import BC_plot_settings # DOES NOT FailsWhich is why codacy raise the issue. This behaviour to me is an antipattern. However, if this is the only way to get rid of that bug we mentioned, let it be until fix that upstream.
== EDIT ==
Maybe we can just define BC_plot_settings in the module globally as None or a non-initialized class... So we get rid of the codacy warning, and we have a consistent module API.
* hold the bc settings per plotter instance * ci: auto fixes from pre-commit.com hooks. for more information, see https://pre-commit.ci * chore: adding changelog file 3897.miscellaneous.md [dependabot-skip] --------- Co-authored-by: Mohamed Koubaa <[email protected]> Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com> Co-authored-by: pyansys-ci-bot <[email protected]>

Attempting to import a module to check if it is installed is unnecessary. If there is a problem with a module that is installed, it will manifest on import and not on use, which can lead to errors even when that module is never used.
This doesn't fully fix the problem because _apply_default_theme is still used even when plotting isn't done