Skip to content

feat: allow logos Linux 26 1 #2048

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

Draft
wants to merge 11 commits into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions doc/changelog.d/2048.added.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Allow logos linux 26 1
12 changes: 8 additions & 4 deletions src/ansys/geometry/core/tools/prepare_tools.py
Original file line number Diff line number Diff line change
Expand Up @@ -300,8 +300,10 @@ def find_logos(
"""
from ansys.geometry.core.designer.body import Body

if BackendType.is_linux_service(self._grpc_client.backend_type):
# not yet available in Linux
if BackendType.is_linux_service(
self._grpc_client.backend_type
) and self._grpc_client.backend_version < (26, 1, 0):
# not yet available on Linux until 26.1.0
LOG.warning("Logo detection not available on Linux")
return

Expand Down Expand Up @@ -346,8 +348,10 @@ def find_and_remove_logos(
"""
from ansys.geometry.core.designer.body import Body

if BackendType.is_linux_service(self._grpc_client.backend_type):
# not yet available in Linux
if BackendType.is_linux_service(
self._grpc_client.backend_type
) and self._grpc_client.backend_version < (26, 1, 0):
# not yet available on Linux until 26.1.0
LOG.warning("Logo detection not available on Linux")
return

Expand Down
7 changes: 0 additions & 7 deletions tests/integration/test_prepare_tools.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@

from pint import Quantity

from ansys.geometry.core.connection.backend import BackendType
from ansys.geometry.core.math.point import Point2D
from ansys.geometry.core.misc.measurements import UNITS
from ansys.geometry.core.modeler import Modeler
Expand Down Expand Up @@ -126,9 +125,6 @@ def test_enhanced_share_topology(modeler: Modeler):

def test_detect_logos(modeler: Modeler):
"""Test logos are detected and deleted."""
if BackendType.is_linux_service(modeler.client.backend_type):
# not yet available in Linux
return
design = modeler.open_file(FILES_DIR / "partWithLogos.scdocx")
component = [c for c in design.components if c.name == "Default"][0]
body = [b for b in component.bodies if b.name == "Solid3"][0]
Expand All @@ -151,9 +147,6 @@ def test_detect_logos(modeler: Modeler):

def test_detect_and_fix_logo_as_problem_area(modeler: Modeler):
"""Test logos are detected and deleted as problem area"""
if BackendType.is_linux_service(modeler.client.backend_type):
# not yet available in Linux
return
design = modeler.open_file(FILES_DIR / "partWithLogos.scdocx")
# Get the component named "Default"
component = [c for c in design.components if c.name == "Default"][0]
Expand Down
59 changes: 58 additions & 1 deletion tests/test_connection.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,13 +20,15 @@
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
# SOFTWARE.

import os

from beartype.roar import BeartypeCallHintParamViolation
import grpc
import numpy as np
from pint import Quantity
import pytest

from ansys.geometry.core.connection.backend import ApiVersions
from ansys.geometry.core.connection.backend import ApiVersions, BackendType
from ansys.geometry.core.connection.client import GrpcClient, wait_until_healthy
from ansys.geometry.core.connection.conversions import (
frame_to_grpc_frame,
Expand All @@ -40,6 +42,10 @@
sketch_segment_to_grpc_line,
unit_vector_to_grpc_direction,
)
from ansys.geometry.core.connection.product_instance import (
ProductInstance,
prepare_and_start_backend,
)
from ansys.geometry.core.math import Frame, Plane, Point2D, Point3D, UnitVector3D
from ansys.geometry.core.misc import UNITS, Angle
from ansys.geometry.core.sketch import Arc, Polygon, SketchCircle, SketchEllipse, SketchSegment
Expand Down Expand Up @@ -360,3 +366,54 @@ def test_api_versions_reader():

with pytest.raises(ValueError, match="0 is not a valid ApiVersions"): # Invalid version number
ApiVersions.parse_input(0)


def test_product_instance_initialization():
"""Test the initialization of the ProductInstance class."""
pid = -1234 # Example process ID
product_instance = ProductInstance(pid)
# Assert that the _pid attribute is correctly set
assert product_instance._pid == pid
assert product_instance.close() is False


def test_prepare_and_start_backend_conflicting_versions():
"""Test that providing both 'product_version' and 'version' raises a ValueError."""
with pytest.raises(
ValueError,
match="Both 'product_version' and 'version' arguments are provided."
" Please use only 'version'.",
):
prepare_and_start_backend(
backend_type=BackendType.WINDOWS_SERVICE, version=1900, product_version=1901
)


@pytest.mark.skipif(
os.name != "nt",
reason="Test skipped on Linux because it is specific to Windows backends.",
)
def test_prepare_and_start_backend_unavailable_version():
"""Test that an unavailable product version raises a SystemError."""
with pytest.raises(
SystemError,
match="The requested Ansys product's version 1901 is not available,"
" please specify a different version.",
):
prepare_and_start_backend(backend_type=BackendType.WINDOWS_SERVICE, product_version=1901)


@pytest.mark.skipif(
os.name != "nt",
reason="Test skipped on Linux because it is specific to Windows backends.",
)
def test_prepare_and_start_backend_invalid_version():
"""Test that a non-integer 'version' raises a ValueError."""
with pytest.raises(
ValueError,
match="The 'version' argument must be an integer representing the product version.",
):
prepare_and_start_backend(
backend_type=BackendType.WINDOWS_SERVICE,
version="invalid_version", # Pass a non-integer value for version
)
Loading