Skip to content

Commit 8ae7558

Browse files
feat: separate graphics target (#1782)
Co-authored-by: pyansys-ci-bot <92810346+pyansys-ci-bot@users.noreply.github.com>
1 parent b753d5e commit 8ae7558

37 files changed

+418
-75
lines changed

.github/workflows/ci_cd.yml

Lines changed: 55 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -91,7 +91,8 @@ jobs:
9191
library-name: ${{ env.PACKAGE_NAME }}
9292
operating-system: ${{ matrix.os }}
9393
python-version: ${{ matrix.python-version }}
94-
whitelist-license-check: 'attrs'
94+
whitelist-license-check: 'attrs,referencing'
95+
target: 'all'
9596

9697
docker-style:
9798
name: Docker Style Check
@@ -545,9 +546,61 @@ jobs:
545546
docker logs ${{ env.GEO_CONT_NAME }}
546547
docker rm ${{ env.GEO_CONT_NAME }}
547548
549+
testing-no-graphics:
550+
name: Testing with minimum requirements (no graphics)
551+
needs: [smoke-tests]
552+
runs-on: ubuntu-latest
553+
env:
554+
ANSRV_GEO_IMAGE_MINREQS: 'ghcr.io/ansys/geometry:core-linux-latest'
555+
strategy:
556+
fail-fast: false
557+
matrix:
558+
python-version: ['3.10', '3.13']
559+
steps:
560+
- name: Login in Github Container registry
561+
uses: docker/login-action@v3
562+
with:
563+
registry: ghcr.io
564+
username: ${{ github.actor }}
565+
password: ${{ secrets.GITHUB_TOKEN }}
566+
567+
- name: Pull and launch geometry service
568+
run: |
569+
docker pull ${{ env.ANSRV_GEO_IMAGE_MINREQS }}
570+
docker run --detach --name ${{ env.GEO_CONT_NAME }} -e LICENSE_SERVER=${{ env.ANSRV_GEO_LICENSE_SERVER }} -p ${{ env.ANSRV_GEO_PORT }}:50051 ${{ env.ANSRV_GEO_IMAGE_MINREQS }}
571+
572+
- name: Checkout repository
573+
uses: actions/checkout@v4
574+
575+
- name: Setup Python ${{ matrix.python-version }}
576+
uses: actions/setup-python@v5
577+
with:
578+
python-version: ${{ matrix.python-version }}
579+
580+
- name: Install minimum requirements
581+
run: |
582+
python -m pip install --upgrade pip
583+
pip install -e .[tests-minimal]
584+
# Uninstall pytest-pyvista (not needed for these tests)
585+
pip uninstall -y pytest-pyvista
586+
# Installing docker (needed for the tests)
587+
pip install docker
588+
589+
- name: Run pytest
590+
run: |
591+
pytest -v -c pytest-nographics.ini
592+
593+
- name: Stop the Geometry service
594+
if: always()
595+
run: |
596+
docker stop ${{ env.GEO_CONT_NAME }}
597+
docker logs ${{ env.GEO_CONT_NAME }}
598+
docker rm ${{ env.GEO_CONT_NAME }}
599+
600+
548601
package:
549602
name: Package library
550-
needs: [testing-windows, testing-linux, testing-min-reqs, docs]
603+
needs: [testing-windows, testing-linux, testing-min-reqs, testing-no-graphics, docs]
551604
runs-on: ubuntu-latest
552605
steps:
553606
- name: Build library source and wheel artifacts

doc/changelog.d/1782.added.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
separate graphics target

doc/source/assets.rst

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ For example, on Linux with Python 3.10, unzip the wheelhouse archive and install
2525

2626
.. code:: bash
2727
28-
unzip ansys-geometry-core-v0.10.dev0-wheelhouse-ubuntu-latest-3.10.zip wheelhouse
28+
unzip ansys-geometry-core-v0.10.dev0-all-wheelhouse-ubuntu-latest-3.10.zip wheelhouse
2929
pip install ansys-geometry-core -f wheelhouse --no-index --upgrade --ignore-installed
3030
3131
If you are on Windows with Python 3.10, unzip to a wheelhouse directory by running ``-d wheelhouse``
@@ -43,7 +43,7 @@ The following wheelhouse files are available for download:
4343
{{ "^" * os_name|length }}
4444

4545
{%- for link in download_links %}
46-
* `{{ link.os }} wheelhouse for Python {{ link.python_versions }} <{{ link.prefix_url }}/ansys-geometry-core-{{ link.latest_released_version }}-wheelhouse-{{ link.runner }}-{{ link.python_versions }}.zip>`_
46+
* `{{ link.os }} wheelhouse for Python {{ link.python_versions }} <{{ link.prefix_url }}/ansys-geometry-core-{{ link.latest_released_version }}-all-wheelhouse-{{ link.runner }}-{{ link.python_versions }}.zip>`_
4747
{%- endfor %}
4848

4949
{%- endfor %}

doc/source/getting_started/installation.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -94,7 +94,7 @@ For example, on Linux with Python 3.10, unzip the wheelhouse archive and install
9494

9595
.. code:: bash
9696
97-
unzip ansys-geometry-core-v0.10.dev0-wheelhouse-ubuntu-3.10.zip wheelhouse
97+
unzip ansys-geometry-core-v0.10.dev0-all-wheelhouse-ubuntu-3.10.zip wheelhouse
9898
pip install ansys-geometry-core -f wheelhouse --no-index --upgrade --ignore-installed
9999
100100
If you are on Windows with Python 3.10, unzip the wheelhouse archive to a wheelhouse directory

pyproject.toml

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -26,29 +26,35 @@ classifiers = [
2626
dependencies = [
2727
"ansys-api-geometry==0.4.42",
2828
"ansys-tools-path>=0.3,<1",
29-
"ansys-tools-visualization-interface>=0.2.6,<1",
3029
"attrs!=24.3.0",
3130
"beartype>=0.11.0,<0.20",
3231
"geomdl>=5,<6",
3332
"grpcio>=1.35.0,<1.68",
3433
"grpcio-health-checking>=1.45.0,<1.68",
34+
"matplotlib>=3,<4",
3535
"numpy>=1.20.3,<3",
3636
"Pint>=0.18,<1",
3737
"protobuf>=3.20.2,<6",
38-
"pygltflib>=1.16,<2",
39-
"pyvista>=0.37.0,<1",
4038
"requests>=2,<3",
4139
"scipy>=1.7.3,<2",
4240
"semver>=3,<4",
4341
"six>=1.16.0,<2",
44-
"vtk>=9,<10",
4542
]
4643

4744
[project.optional-dependencies]
45+
graphics = [
46+
"ansys-tools-visualization-interface>=0.2.6,<1",
47+
"pygltflib>=1.16,<2",
48+
"pyvista[jupyter]>=0.38.1,<1",
49+
"vtk>=9,<10",
50+
]
4851
all = [
4952
"ansys-platform-instancemanagement>=1.0.3,<2",
53+
"ansys-tools-visualization-interface>=0.2.6,<1",
5054
"docker>=6.0.1,<8",
55+
"pygltflib>=1.16,<2",
5156
"pyvista[jupyter]>=0.38.1,<1",
57+
"vtk>=9,<10",
5258
]
5359
tests = [
5460
"ansys-platform-instancemanagement==1.1.2",
@@ -59,6 +65,7 @@ tests = [
5965
"geomdl==5.3.1",
6066
"grpcio==1.67.1",
6167
"grpcio-health-checking==1.67.1",
68+
"matplotlib==3.10.0",
6269
"numpy==2.2.3",
6370
"Pint==0.24.4",
6471
"protobuf==5.29.3",
@@ -92,6 +99,7 @@ doc = [
9299
"ipyvtklink==0.2.3",
93100
"jupyter_sphinx==0.5.3",
94101
"jupytext==1.16.7",
102+
"matplotlib==3.10.0",
95103
"myst-parser==4.0.1",
96104
"nbconvert==7.16.6",
97105
"nbsphinx==0.9.6",
@@ -101,6 +109,7 @@ doc = [
101109
"panel==1.6.1",
102110
"Pint==0.24.4",
103111
"protobuf==5.29.3",
112+
"pygltflib==1.16.3",
104113
"pyvista[jupyter]==0.44.2",
105114
"requests==2.32.3",
106115
"scipy==1.15.2",

pytest-nographics.ini

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
[pytest]
2+
minversion = 7.1
3+
addopts = -ra --cov=ansys.geometry --cov-report html:.cov/html --cov-report xml:.cov/xml --cov-report term -vv
4+
testpaths = ["tests"]

src/ansys/geometry/core/connection/conversions.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,7 @@
5656
from ansys.geometry.core.math.plane import Plane
5757
from ansys.geometry.core.math.point import Point2D, Point3D
5858
from ansys.geometry.core.math.vector import UnitVector3D
59+
from ansys.geometry.core.misc.checks import graphics_required
5960
from ansys.geometry.core.misc.measurements import DEFAULT_UNITS, UNITS
6061
from ansys.geometry.core.shapes.curves.circle import Circle
6162
from ansys.geometry.core.shapes.curves.curve import Curve
@@ -404,6 +405,7 @@ def sketch_segment_to_grpc_line(segment: SketchSegment, plane: Plane) -> GRPCLin
404405
)
405406

406407

408+
@graphics_required
407409
def tess_to_pd(tess: Tessellation) -> "PolyData":
408410
"""Convert an ``ansys.api.geometry.Tessellation`` to ``pyvista.PolyData``."""
409411
# lazy imports here to improve initial load

src/ansys/geometry/core/designer/body.py

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -80,19 +80,20 @@
8080
from ansys.geometry.core.math.point import Point3D
8181
from ansys.geometry.core.math.vector import UnitVector3D
8282
from ansys.geometry.core.misc.auxiliary import (
83+
DEFAULT_COLOR,
8384
convert_color_to_hex,
8485
get_design_from_body,
8586
)
8687
from ansys.geometry.core.misc.checks import (
8788
check_type,
8889
check_type_all_elements_in_iterable,
8990
ensure_design_is_active,
91+
graphics_required,
9092
min_backend_version,
9193
)
9294
from ansys.geometry.core.misc.measurements import DEFAULT_UNITS, Angle, Distance
9395
from ansys.geometry.core.sketch.sketch import Sketch
9496
from ansys.geometry.core.typing import Real
95-
from ansys.tools.visualization_interface.utils.color import Color
9697

9798
if TYPE_CHECKING: # pragma: no cover
9899
from pyvista import MultiBlock, PolyData
@@ -865,7 +866,7 @@ def color(self) -> str: # noqa: D102
865866
"""Get the current color of the body."""
866867
if self._color is None and self.is_alive:
867868
# Assigning default value first
868-
self._color = Color.DEFAULT.value
869+
self._color = DEFAULT_COLOR
869870

870871
if self._grpc_client.backend_version < (25, 1, 0): # pragma: no cover
871872
# Server does not support color retrieval before version 25.1.0
@@ -1209,6 +1210,7 @@ def copy(self, parent: "Component", name: str = None) -> "Body": # noqa: D102
12091210
return Body(body_id, response.name, parent, tb)
12101211

12111212
@protect_grpc
1213+
@graphics_required
12121214
def tessellate( # noqa: D102
12131215
self, merge: bool = False, transform: Matrix44 = IDENTITY_MATRIX44
12141216
) -> Union["PolyData", "MultiBlock"]:
@@ -1724,6 +1726,7 @@ def shell_body(self, offset: Real) -> bool: # noqa: D102
17241726
def remove_faces(self, selection: Face | Iterable[Face], offset: Real) -> bool: # noqa: D102
17251727
return self._template.remove_faces(selection, offset)
17261728

1729+
@graphics_required
17271730
def plot( # noqa: D102
17281731
self,
17291732
merge: bool = True,

src/ansys/geometry/core/designer/component.py

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,11 @@
7575
from ansys.geometry.core.math.matrix import Matrix44
7676
from ansys.geometry.core.math.point import Point3D
7777
from ansys.geometry.core.math.vector import UnitVector3D, Vector3D
78-
from ansys.geometry.core.misc.checks import ensure_design_is_active, min_backend_version
78+
from ansys.geometry.core.misc.checks import (
79+
ensure_design_is_active,
80+
graphics_required,
81+
min_backend_version,
82+
)
7983
from ansys.geometry.core.misc.measurements import DEFAULT_UNITS, Angle, Distance
8084
from ansys.geometry.core.shapes.curves.circle import Circle
8185
from ansys.geometry.core.shapes.curves.trimmed_curve import TrimmedCurve
@@ -1448,6 +1452,7 @@ def _kill_component_on_client(self) -> None:
14481452
# Kill itself
14491453
self._is_alive = False
14501454

1455+
@graphics_required
14511456
def tessellate(self, _recursive_call: bool = False) -> Union["PolyData", list["MultiBlock"]]:
14521457
"""Tessellate the component.
14531458
@@ -1485,6 +1490,7 @@ def tessellate(self, _recursive_call: bool = False) -> Union["PolyData", list["M
14851490
ugrid = pv.MultiBlock(datasets).combine()
14861491
return pv.PolyData(var_inp=ugrid.points, faces=ugrid.cells)
14871492

1493+
@graphics_required
14881494
def plot(
14891495
self,
14901496
merge_component: bool = True,

src/ansys/geometry/core/designer/designpoint.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@
2424
from typing import TYPE_CHECKING
2525

2626
from ansys.geometry.core.math.point import Point3D
27-
from ansys.geometry.core.misc.checks import check_type
27+
from ansys.geometry.core.misc.checks import check_type, graphics_required
2828
from ansys.geometry.core.misc.units import UNITS
2929

3030
if TYPE_CHECKING: # pragma: no cover
@@ -89,6 +89,7 @@ def __repr__(self) -> str:
8989
lines.append(f" Design Point : {self.value}")
9090
return "\n".join(lines)
9191

92+
@graphics_required
9293
def _to_polydata(self) -> "pv.PolyData":
9394
"""Get polydata from DesignPoint object."""
9495
import pyvista as pv

0 commit comments

Comments
 (0)