Skip to content

Decoupling graphics requirements from libraries #902

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

Open
5 of 6 tasks
RobPasMue opened this issue Mar 31, 2025 · 4 comments
Open
5 of 6 tasks

Decoupling graphics requirements from libraries #902

RobPasMue opened this issue Mar 31, 2025 · 4 comments

Comments

@RobPasMue
Copy link
Member

RobPasMue commented Mar 31, 2025

After the discussions occuring on the PyAnsys Dev meeting, we thought it would be important to decouple the usage of graphics from the main installation of our libraries by defining a "graphics" target for that purpose. See ansys/pyansys-dev-guide#577 and ansys/pyansys-dev-guide#576

By doing a quick analysis of the metapackage and using this script where the variable target_package can be easily tweaked... I obtained the following results:

Note

In order to run it, one must:
1 - clone the repo
2 - create a venv and activate it
3 - install the repo: pip install .
4 - install the following: pip install pyvis pipdeptree

import subprocess
import json
import networkx as nx
from pyvis.network import Network

def get_dependency_tree():
    result = subprocess.run(["pipdeptree", "--json"], capture_output=True, text=True)
    return json.loads(result.stdout)

def build_reverse_dependency_graph(dependencies, target_package):
    graph = nx.DiGraph()
    package_map = {pkg["package"]["key"]: pkg for pkg in dependencies}
    
    for pkg_name, pkg in package_map.items():
        for dep in pkg.get("dependencies", []):
            if dep["key"] == target_package:
                graph.add_node(pkg_name, label=pkg_name, color="blue")
                graph.add_edge(pkg_name, target_package)
    
    return graph

def visualize_graph(graph):
    net = Network(notebook=True, directed=True, cdn_resources='remote')
    net.from_nx(graph)
    net.show("dependency_graph.html")

if __name__ == "__main__":
    target_package = "pyvista"  # Change this to the package you want to track
    dependencies = get_dependency_tree()
    graph = build_reverse_dependency_graph(dependencies, target_package)
    visualize_graph(graph)
    print(f"{len(graph.nodes) - 1} packages depend on {target_package}.")
    print("Dependency graph generated: Open 'dependency_graph.html' in your browser.")

Visualization shows that only 5 packages depend on it directly:

The first 4 should be adapted to use the ansys-tools-visualization-interface package if possible, and make it an optional dependency.

Now, after investigating the packages that depend on ansys-tools-visualization-interface, we get the following list:

This means that, only 5 PyAnsys libraries are the ones forcing the installation of PyVista "by default". We should contact each of these repos and push for its separation into a graphics target as described in ansys/pyansys-dev-guide#576

@AlejandroFernandezLuces
Copy link
Contributor

AlejandroFernandezLuces commented Apr 1, 2025

Added a PR for PyMAPDL: ansys/pymapdl#3820

The visualization was already separated code wise, it was just missing removing it from the main target and adding the graphics target. I think this was made on purpose by @germa89 though, any opinions?

@StefanThoene
Copy link

added a PR for pySpeos: ansys/pyspeos#532

i added error management and warnings so the methods leveraging pyvista(now ansys-tools-visualization-interface) are giving correct errors quick question would this considered a breaking change?

@RobPasMue
Copy link
Member Author

quick question would this considered a breaking change?

You can probably do a new minor release with this change.

StefanThoene added a commit to ansys/pyspeos that referenced this issue Apr 1, 2025
## Description
Comply with [#901](ansys/pyansys#902)
Switch from native pyvista to ansys-tools-vizualization-interface

only basic implementation done additional steps will be coming

## Issue linked
#531 

## Checklist
- [x] I have tested my changes locally.
- [x] I have added necessary documentation or updated existing
documentation.
- [x] I have followed the coding style guidelines of this project.
- [x] I have added appropriate tests (unit, integration, system).
- [x] I have reviewed my changes before submitting this pull request.
- [x] I have linked the issue or issues that are solved by the PR if
any.
- [x] I have assigned this PR to myself.
- [x] I have made sure that the title of my PR follows [Conventional
commits style](https://www.conventionalcommits.org/en/v1.0.0/#summary)
(e.g. ``feat: add optical property``)
- [x] I have agreed with the Contributor License Agreement
([CLA](https://developer.ansys.com/form/cla-acceptance)).

---------

Co-authored-by: Sebastien Morais <[email protected]>
Co-authored-by: pyansys-ci-bot <[email protected]>
Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
Co-authored-by: Sébastien Morais <[email protected]>
Co-authored-by: Pengyuan LU <[email protected]>
@StefanThoene
Copy link

quick question would this considered a breaking change?

You can probably do a new minor release with this change.

we created a new minor release it is now available (for pyspeos)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants