Skip to content
1 change: 1 addition & 0 deletions .github/workflows/ci_cd.yml
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,7 @@ jobs:
library-name: ${{ env.PACKAGE_NAME }}
operating-system: ${{ matrix.os }}
python-version: ${{ matrix.python-version }}
whitelist-license-check: 'attrs'

docker-style:
name: Docker Style Check
Expand Down
1 change: 1 addition & 0 deletions doc/changelog.d/1692.added.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
is_core_service BackendType static method
23 changes: 23 additions & 0 deletions src/ansys/geometry/core/connection/backend.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,29 @@ class BackendType(Enum):
SPACECLAIM = 1
WINDOWS_SERVICE = 2
LINUX_SERVICE = 3
CORE_WINDOWS = 4
CORE_LINUX = 5
DISCOVERY_HEADLESS = 6

@staticmethod
def is_core_service(backend_type: "BackendType") -> bool:
"""Determine whether the backend is CoreService based or not.

Parameters
----------
backend_type : BackendType
The backend type to check whether or not it's a CoreService type.

Returns
-------
bool
True if the backend is CoreService based, False otherwise.
"""
return backend_type in (
BackendType.LINUX_SERVICE,
BackendType.CORE_WINDOWS,
BackendType.CORE_LINUX,
)


class ApiVersions(Enum):
Expand Down
17 changes: 16 additions & 1 deletion src/ansys/geometry/core/connection/client.py
Original file line number Diff line number Diff line change
Expand Up @@ -215,11 +215,26 @@ def __init__(
backend_type = BackendType.WINDOWS_SERVICE
elif grpc_backend_type == GRPCBackendType.LINUX_DMS:
backend_type = BackendType.LINUX_SERVICE
elif grpc_backend_type == GRPCBackendType.CORE_SERVICE_LINUX:
backend_type = BackendType.CORE_LINUX
elif grpc_backend_type == GRPCBackendType.CORE_SERVICE_WINDOWS:
backend_type = BackendType.CORE_WINDOWS
elif grpc_backend_type == GRPCBackendType.DISCOVERY_HEADLESS:
backend_type = BackendType.DISCOVERY_HEADLESS

# Store the backend type
self._backend_type = backend_type
self._multiple_designs_allowed = (
False if backend_type in (BackendType.DISCOVERY, BackendType.LINUX_SERVICE) else True
False
if backend_type
in (
BackendType.DISCOVERY,
BackendType.LINUX_SERVICE,
BackendType.CORE_LINUX,
BackendType.CORE_WINDOWS,
BackendType.DISCOVERY_HEADLESS,
)
else True
)

# retrieve the backend version
Expand Down
7 changes: 5 additions & 2 deletions src/ansys/geometry/core/connection/product_instance.py
Original file line number Diff line number Diff line change
Expand Up @@ -263,7 +263,10 @@ def prepare_and_start_backend(
"""
from ansys.geometry.core.modeler import Modeler

if os.name != "nt" and backend_type != BackendType.LINUX_SERVICE: # pragma: no cover
if os.name != "nt" and backend_type not in (
BackendType.LINUX_SERVICE,
BackendType.CORE_LINUX,
): # pragma: no cover
raise RuntimeError(
"Method 'prepare_and_start_backend' is only available on Windows."
"A Linux version is only available for the Core Geometry Service."
Expand Down Expand Up @@ -362,7 +365,7 @@ def prepare_and_start_backend(
)
)
# This should be modified to Windows Core Service in the future
elif backend_type == BackendType.LINUX_SERVICE:
elif BackendType.is_core_service(backend_type):
# Define several Ansys Geometry Core Service folders needed
root_service_folder = Path(installations[product_version], CORE_GEOMETRY_SERVICE_FOLDER)
native_folder = root_service_folder / "Native"
Expand Down
4 changes: 2 additions & 2 deletions src/ansys/geometry/core/modeler.py
Original file line number Diff line number Diff line change
Expand Up @@ -122,9 +122,9 @@ def __init__(
# Initialize the RepairTools - Not available on Linux
# TODO: delete "if" when Linux service is able to use repair tools
# https://github.com/ansys/pyansys-geometry/issues/1319
if self.client.backend_type == BackendType.LINUX_SERVICE:
if BackendType.is_core_service(self.client.backend_type):
self._measurement_tools = None
LOG.warning("Linux backend does not support measurement tools.")
LOG.warning("CoreService backend does not support measurement tools.")
else:
self._measurement_tools = MeasurementTools(self._grpc_client)

Expand Down
8 changes: 4 additions & 4 deletions tests/integration/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -49,11 +49,11 @@
FILES_DIR = Path(Path(__file__).parent, "files")


def skip_if_linux(modeler: Modeler, test_name: str, element_not_available: str):
"""Skip test if running on Linux."""
if modeler.client.backend_type == BackendType.LINUX_SERVICE:
def skip_if_core_service(modeler: Modeler, test_name: str, element_not_available: str):
"""Skip test if running on CoreService."""
if BackendType.is_core_service(modeler.client.backend_type):
pytest.skip(
reason=f"Skipping '{test_name}'. '{element_not_available}' not on Linux service."
reason=f"Skipping '{test_name}'. '{element_not_available}' not on CoreService."
) # skip!


Expand Down
35 changes: 21 additions & 14 deletions tests/integration/test_design.py
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@
from ansys.geometry.core.sketch import Sketch
from ansys.tools.visualization_interface.utils.color import Color

from .conftest import FILES_DIR, skip_if_linux
from .conftest import FILES_DIR, skip_if_core_service


def test_design_extrusion_and_material_assignment(modeler: Modeler):
Expand Down Expand Up @@ -911,15 +911,15 @@ def test_download_file(modeler: Modeler, tmp_path_factory: pytest.TempPathFactor
assert file.exists()

# Check that we can also save it (even if it is not accessible on the server)
if modeler.client.backend_type == BackendType.LINUX_SERVICE:
if modeler.client.backend_type in (BackendType.LINUX_SERVICE, BackendType.CORE_LINUX):
file_save = "/tmp/cylinder-temp.scdocx"
else:
file_save = tmp_path_factory.mktemp("scdoc_files_save") / "cylinder.scdocx"

design.save(file_location=file_save)

# Check for other exports - Windows backend...
if modeler.client.backend_type != BackendType.LINUX_SERVICE:
if not BackendType.is_core_service(modeler.client.backend_type):
binary_parasolid_file = tmp_path_factory.mktemp("scdoc_files_download") / "cylinder.x_b"
text_parasolid_file = tmp_path_factory.mktemp("scdoc_files_download") / "cylinder.x_t"

Expand Down Expand Up @@ -1111,8 +1111,8 @@ def test_copy_body(modeler: Modeler):

def test_beams(modeler: Modeler):
"""Test beam creation."""
# Skip on Linux
skip_if_linux(modeler, test_beams.__name__, "create_beam")
# Skip on CoreService
skip_if_core_service(modeler, test_beams.__name__, "create_beam")

# Create your design on the server side
design = modeler.create_design("BeamCreation")
Expand Down Expand Up @@ -1414,8 +1414,8 @@ def test_named_selections_beams(modeler: Modeler):
"""Test for verifying the correct creation of ``NamedSelection`` with
beams.
"""
# Skip on Linux
skip_if_linux(modeler, test_named_selections_beams.__name__, "create_beam")
# Skip on CoreService
skip_if_core_service(modeler, test_named_selections_beams.__name__, "create_beam")

# Create your design on the server side
design = modeler.create_design("NamedSelectionBeams_Test")
Expand Down Expand Up @@ -2002,7 +2002,8 @@ def test_get_collision(modeler: Modeler):

def test_set_body_name(modeler: Modeler):
"""Test the setting the name of a body."""
skip_if_linux(modeler, test_set_body_name.__name__, "set_name") # Skip test on Linux
# Skip test on CoreService
skip_if_core_service(modeler, test_set_body_name.__name__, "set_name")

design = modeler.create_design("simple_cube")
unit = DEFAULT_UNITS.LENGTH
Expand All @@ -2023,7 +2024,8 @@ def test_set_body_name(modeler: Modeler):

def test_set_fill_style(modeler: Modeler):
"""Test the setting the fill style of a body."""
skip_if_linux(modeler, test_set_fill_style.__name__, "set_fill_style") # Skip test on Linux
# Skip test on CoreService
skip_if_core_service(modeler, test_set_fill_style.__name__, "set_fill_style")

design = modeler.create_design("RVE")
unit = DEFAULT_UNITS.LENGTH
Expand Down Expand Up @@ -2196,7 +2198,9 @@ def test_body_mapping(modeler: Modeler):

def test_sphere_creation(modeler: Modeler):
"""Test the creation of a sphere body with a given radius."""
skip_if_linux(modeler, test_sphere_creation.__name__, "create_sphere")
# Skip test on CoreService
skip_if_core_service(modeler, test_sphere_creation.__name__, "create_sphere")

design = modeler.create_design("Spheretest")
center_point = Point3D([10, 10, 10], UNITS.m)
radius = Distance(1, UNITS.m)
Expand All @@ -2208,7 +2212,9 @@ def test_sphere_creation(modeler: Modeler):

def test_body_mirror(modeler: Modeler):
"""Test the mirroring of a body."""
skip_if_linux(modeler, test_body_mirror.__name__, "mirror")
# Skip test on CoreService
skip_if_core_service(modeler, test_body_mirror.__name__, "mirror")

design = modeler.create_design("Design1")

# Create shape with no lines of symmetry in any axis
Expand Down Expand Up @@ -2414,7 +2420,8 @@ def test_create_body_from_loft_profile(modeler: Modeler):
"""Test the ``create_body_from_loft_profile()`` method to create a vase
shape.
"""
skip_if_linux(
# Skip test on CoreService
skip_if_core_service(
modeler, test_create_body_from_loft_profile.__name__, "'create_body_from_loft_profile'"
)
design_sketch = modeler.create_design("loftprofile")
Expand Down Expand Up @@ -2530,8 +2537,8 @@ def test_revolve_sketch_fail_invalid_path(modeler: Modeler):

def test_component_tree_print(modeler: Modeler):
"""Test for verifying the tree print for ``Component`` objects."""
# Skip on Linux
skip_if_linux(modeler, test_component_tree_print.__name__, "create_beam")
# Skip on CoreService
skip_if_core_service(modeler, test_component_tree_print.__name__, "create_beam")

def check_list_equality(lines, expected_lines):
# By doing "a in b" rather than "a == b", we can check for substrings
Expand Down
6 changes: 3 additions & 3 deletions tests/integration/test_design_export.py
Original file line number Diff line number Diff line change
Expand Up @@ -138,7 +138,7 @@ def test_export_to_parasolid_text(modeler: Modeler, tmp_path_factory: pytest.Tem
# Define the location and expected file location
location = tmp_path_factory.mktemp("test_export_to_parasolid_text")

if modeler.client.backend_type == BackendType.LINUX_SERVICE:
if BackendType.is_core_service(modeler.client.backend_type):
file_location = location / f"{design.name}.x_t"
else:
file_location = location / f"{design.name}.xmt_txt"
Expand All @@ -161,7 +161,7 @@ def test_export_to_parasolid_binary(modeler: Modeler, tmp_path_factory: pytest.T
# Define the location and expected file location
location = tmp_path_factory.mktemp("test_export_to_parasolid_binary")

if modeler.client.backend_type == BackendType.LINUX_SERVICE:
if BackendType.is_core_service(modeler.client.backend_type):
file_location = location / f"{design.name}.x_b"
else:
file_location = location / f"{design.name}.xmt_bin"
Expand Down Expand Up @@ -191,7 +191,7 @@ def test_export_to_step(modeler: Modeler, tmp_path_factory: pytest.TempPathFacto
# Check the exported file
assert file_location.exists()

if modeler.client.backend_type != BackendType.LINUX_SERVICE:
if not BackendType.is_core_service(modeler.client.backend_type):
# Import the STEP file
design_read = modeler.open_file(file_location)

Expand Down
12 changes: 6 additions & 6 deletions tests/integration/test_design_import.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@
from ansys.geometry.core.misc import UNITS
from ansys.geometry.core.sketch import Sketch

from .conftest import FILES_DIR, IMPORT_FILES_DIR, skip_if_linux
from .conftest import FILES_DIR, IMPORT_FILES_DIR, skip_if_core_service


def _checker_method(comp: Component, comp_ref: Component, precise_check: bool = True) -> None:
Expand Down Expand Up @@ -179,7 +179,7 @@ def test_open_file(modeler: Modeler, tmp_path_factory: pytest.TempPathFactory):
_checker_method(design, design2, True)

# Test HOOPS formats (Windows only)
if modeler.client.backend_type != BackendType.LINUX_SERVICE:
if not BackendType.is_core_service(modeler.client.backend_type):
# IGES
#
# TODO: Something has gone wrong with IGES
Expand Down Expand Up @@ -226,8 +226,8 @@ def test_open_file(modeler: Modeler, tmp_path_factory: pytest.TempPathFactory):

def test_design_insert(modeler: Modeler):
"""Test inserting a file into the design."""
# Skip for Linux service
skip_if_linux(modeler, test_design_insert.__name__, "insert_file")
# Skip for CoreService
skip_if_core_service(modeler, test_design_insert.__name__, "insert_file")

# Create a design and sketch a circle
design = modeler.create_design("Insert")
Expand All @@ -249,8 +249,8 @@ def test_design_insert_with_import(modeler: Modeler):
"""Test inserting a file into the design through the external format import
process.
"""
# Skip for Linux service
skip_if_linux(modeler, test_design_insert_with_import.__name__, "insert_file")
# Skip for CoreService
skip_if_core_service(modeler, test_design_insert_with_import.__name__, "insert_file")

# Create a design and sketch a circle
design = modeler.create_design("Insert")
Expand Down
8 changes: 4 additions & 4 deletions tests/integration/test_issues.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@
from ansys.geometry.core.modeler import Modeler
from ansys.geometry.core.sketch import Sketch

from .conftest import FILES_DIR, skip_if_linux
from .conftest import FILES_DIR, skip_if_core_service


def test_issue_834_design_import_with_surfaces(modeler: Modeler):
Expand All @@ -48,7 +48,7 @@ def test_issue_834_design_import_with_surfaces(modeler: Modeler):
"""
# TODO: to be reactivated
# https://github.com/ansys/pyansys-geometry/issues/799
skip_if_linux(modeler, test_issue_834_design_import_with_surfaces.__name__, "open_file")
skip_if_core_service(modeler, test_issue_834_design_import_with_surfaces.__name__, "open_file")

# Open the design
design = modeler.open_file(Path(FILES_DIR, "DuplicateFacesDesignBefore.scdocx"))
Expand Down Expand Up @@ -86,8 +86,8 @@ def test_issue_1184_sphere_creation_crashes(modeler: Modeler):
For more info see
https://github.com/ansys/pyansys-geometry/issues/1184
"""
# Skip this test on Linux since it is not implemented yet
skip_if_linux(modeler, test_issue_1184_sphere_creation_crashes.__name__, "create_sphere")
# Skip this test on CoreService since it is not implemented yet
skip_if_core_service(modeler, test_issue_1184_sphere_creation_crashes.__name__, "create_sphere")

design = modeler.create_design("SphereCreationIssue")

Expand Down
6 changes: 3 additions & 3 deletions tests/integration/test_measurement_tools.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
from ansys.geometry.core.modeler import Modeler
from ansys.geometry.core.tools.measurement_tools import Gap

from .conftest import FILES_DIR, skip_if_linux
from .conftest import FILES_DIR, skip_if_core_service


def test_distance_property(modeler: Modeler):
Expand All @@ -36,9 +36,9 @@ def test_distance_property(modeler: Modeler):

def test_min_distance_between_objects(modeler: Modeler):
"""Test if split edge problem areas are detectable."""
skip_if_linux(
skip_if_core_service(
modeler, test_min_distance_between_objects.__name__, "measurement_tools"
) # Skip test on Linux
) # Skip test on CoreService
design = modeler.open_file(FILES_DIR / "MixingTank.scdocx")
gap = modeler.measurement_tools.min_distance_between_objects(design.bodies[2], design.bodies[1])
assert abs(gap.distance._value - 0.0892) <= 0.01
5 changes: 3 additions & 2 deletions tests/integration/test_prepare_tools.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@

from ansys.geometry.core.modeler import Modeler

from .conftest import FILES_DIR, skip_if_linux
from .conftest import FILES_DIR, skip_if_core_service


def test_volume_extract_from_faces(modeler: Modeler):
Expand Down Expand Up @@ -53,7 +53,8 @@ def test_volume_extract_from_edge_loops(modeler: Modeler):

def test_share_topology(modeler: Modeler):
"""Test share topology operation is between two bodies."""
skip_if_linux(modeler, test_share_topology.__name__, "prepare_tools") # Skip test on Linux
# Skip test on CoreService
skip_if_core_service(modeler, test_share_topology.__name__, "prepare_tools")
design = modeler.open_file(FILES_DIR / "MixingTank.scdocx")

assert modeler.prepare_tools.share_topology(design.bodies)
Loading
Loading