Skip to content
Merged
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
2 changes: 1 addition & 1 deletion .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ exclude: '^tests/embedding/assets/.*$|^tests/parts/.*$'
repos:

- repo: https://github.com/astral-sh/ruff-pre-commit
rev: v0.8.6
rev: v0.14.3
hooks:
- id: ruff
- id: ruff-format
Expand Down
1 change: 1 addition & 0 deletions doc/changelog.d/1381.maintenance.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Pre-commit automatic update
6 changes: 3 additions & 3 deletions examples/01_basic/fracture_analysis_contact_debonding.py
Original file line number Diff line number Diff line change
Expand Up @@ -495,9 +495,9 @@ def add_displacement(
static_structural_analysis_solution.Solve(True)

# sphinx_gallery_start_ignore
assert (
static_structural_analysis_solution.Status == SolutionStatusType.Done
), "Solution status is not 'Done'"
assert static_structural_analysis_solution.Status == SolutionStatusType.Done, (
"Solution status is not 'Done'"
)
# sphinx_gallery_end_ignore

# %%
Expand Down
3 changes: 1 addition & 2 deletions src/ansys/mechanical/core/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,9 +26,8 @@
import os
from pathlib import Path

import appdirs

from ansys.tools.path import find_mechanical
import appdirs

USER_DATA_PATH = Path(appdirs.user_data_dir(appname="ansys_mechanical_core", appauthor="Ansys"))
"""User data directory."""
Expand Down
3 changes: 2 additions & 1 deletion src/ansys/mechanical/core/embedding/app_libraries.py
Original file line number Diff line number Diff line change
Expand Up @@ -53,9 +53,10 @@
import sys
import warnings

from ansys.mechanical.core.embedding.app import App
from ansys.tools.path import get_mechanical_path

from ansys.mechanical.core.embedding.app import App


def add_mechanical_python_libraries(app_or_version):
"""Add the Mechanical libraries path to sys.path."""
Expand Down
3 changes: 1 addition & 2 deletions src/ansys/mechanical/core/embedding/find_mechanical.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,9 +25,8 @@
from pathlib import Path
import sys

import click

import ansys.tools.path as atp
import click


@click.command()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,12 +32,11 @@

if TYPE_CHECKING:
from ansys.mechanical.core.embedding import App
from ansys.tools.visualization_interface import Plotter
import clr
import numpy as np
import pyvista as pv

from ansys.tools.visualization_interface import Plotter

from .utils import (
bgr_to_rgb_tuple,
get_line_nodes_and_coords,
Expand Down
6 changes: 3 additions & 3 deletions src/ansys/mechanical/core/embedding/logger/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -64,9 +64,9 @@
"""Constant for logging context."""


def _get_backend() -> (
typing.Union[windows_api.APIBackend, linux_api.APIBackend, environ.EnvironBackend]
):
def _get_backend() -> typing.Union[
windows_api.APIBackend, linux_api.APIBackend, environ.EnvironBackend
]:
"""Get the appropriate logger backend.

Before embedding is initialized, logging is configured via environment variables.
Expand Down
2 changes: 1 addition & 1 deletion src/ansys/mechanical/core/errors.py
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ def __init__(self, msg="Mechanical has exited."):
# handler for protect_grpc
def handler(sig, frame): # pragma: no cover
"""Pass signal to custom interrupt handler."""
LOG.info("KeyboardInterrupt received. Waiting until Mechanical " "execution finishes")
LOG.info("KeyboardInterrupt received. Waiting until Mechanical execution finishes")
SIGINT_TRACKER.append(True)


Expand Down
3 changes: 1 addition & 2 deletions src/ansys/mechanical/core/ide_config.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,9 +30,8 @@
import sys
import warnings

import click

import ansys.tools.path as atp
import click


def get_stubs_location():
Expand Down
8 changes: 4 additions & 4 deletions src/ansys/mechanical/core/mechanical.py
Original file line number Diff line number Diff line change
Expand Up @@ -41,10 +41,11 @@
import warnings
import weakref

import grpc

import ansys.api.mechanical.v0.mechanical_pb2 as mechanical_pb2
import ansys.api.mechanical.v0.mechanical_pb2_grpc as mechanical_pb2_grpc
import ansys.tools.path as atp
import grpc

import ansys.mechanical.core as pymechanical
from ansys.mechanical.core import LOG
from ansys.mechanical.core.errors import (
Expand All @@ -60,7 +61,6 @@
check_valid_start_instance,
threaded,
)
import ansys.tools.path as atp

# Check if PyPIM is installed
try:
Expand Down Expand Up @@ -882,7 +882,7 @@ def wait_till_mechanical_is_ready(self, wait_time=-1):
f"before throwing the error."
)
raise RuntimeError(
f"Couldn't connect to Mechanical. " f"Waited for {time_interval_seconds}s."
f"Couldn't connect to Mechanical. Waited for {time_interval_seconds}s."
)

time.sleep(sleep_time)
Expand Down
3 changes: 2 additions & 1 deletion src/ansys/mechanical/core/pool.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,8 @@
import time
import warnings

from ansys.tools.path import version_from_path

from ansys.mechanical.core.errors import VersionError
from ansys.mechanical.core.mechanical import (
_HAS_TQDM,
Expand All @@ -36,7 +38,6 @@
port_in_use,
)
from ansys.mechanical.core.misc import threaded, threaded_daemon
from ansys.tools.path import version_from_path

if _HAS_TQDM:
from tqdm import tqdm
Expand Down
2 changes: 1 addition & 1 deletion src/ansys/mechanical/core/run.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,11 +28,11 @@
import sys
import typing

import ansys.tools.path as atp
import click

from ansys.mechanical.core.embedding.appdata import UniqueUserProfile
from ansys.mechanical.core.feature_flags import get_command_line_arguments, get_feature_flag_names
import ansys.tools.path as atp

DRY_RUN = False
"""Dry run constant."""
Expand Down
8 changes: 4 additions & 4 deletions tests/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@
import sys
import time

import ansys.tools.path as atp
import pytest

import ansys.mechanical.core as pymechanical
Expand All @@ -41,7 +42,6 @@
from ansys.mechanical.core.examples import download_file
from ansys.mechanical.core.misc import get_mechanical_bin
import ansys.mechanical.core.run
import ansys.tools.path as atp

# to run tests with multiple markers
# pytest -q --collect-only -m "remote_session_launch"
Expand Down Expand Up @@ -131,9 +131,9 @@ def start_embedding_app(version, pytestconfig) -> datetime.timedelta:
config = AddinConfiguration(pytestconfig.getoption("addin_configuration"))

EMBEDDED_APP = App(version=int(version))
assert (
not EMBEDDED_APP.readonly
), "Can't run test cases, Mechanical is in readonly mode! Check license configuration."
assert not EMBEDDED_APP.readonly, (
"Can't run test cases, Mechanical is in readonly mode! Check license configuration."
)
startup_time = (datetime.datetime.now() - start).total_seconds()
num_cores = os.environ.get("NUM_CORES", None)
if num_cores is not None:
Expand Down
2 changes: 1 addition & 1 deletion tests/embedding/test_app_libraries.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,10 +26,10 @@
from pathlib import Path
import sys

from ansys.tools.path import get_mechanical_path
import pytest

from ansys.mechanical.core.embedding import add_mechanical_python_libraries
from ansys.tools.path import get_mechanical_path


@pytest.mark.embedding
Expand Down
18 changes: 9 additions & 9 deletions tests/embedding/test_license_manager.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,21 +36,21 @@ def test_license_manager(embedded_app, capsys):

# Enable and disable specific license
status = embedded_app.license_manager.get_license_status(test_license)
assert (
status == embedded_app.license_manager._license_status.Enabled
), "License should be enabled"
assert status == embedded_app.license_manager._license_status.Enabled, (
"License should be enabled"
)

embedded_app.license_manager.set_license_status(test_license, False)
status = embedded_app.license_manager.get_license_status(test_license)
assert (
status == embedded_app.license_manager._license_status.Disabled
), "License should be disabled"
assert status == embedded_app.license_manager._license_status.Disabled, (
"License should be disabled"
)

embedded_app.license_manager.set_license_status(test_license, True)
status = embedded_app.license_manager.get_license_status(test_license)
assert (
status == embedded_app.license_manager._license_status.Enabled
), "License should be enabled"
assert status == embedded_app.license_manager._license_status.Enabled, (
"License should be enabled"
)

license_list = embedded_app.license_manager.get_all_licenses()
assert license_list.index(test_license) == 1, "License should be at index 1"
Expand Down
36 changes: 18 additions & 18 deletions tests/embedding/test_qk_eng_wb2.py
Original file line number Diff line number Diff line change
Expand Up @@ -302,33 +302,33 @@ def _innertest():
MODEL.Solve(True)

FAT_Tool_1_LIFE = LIFE.Minimum.Value
assert FAT_Tool_1_LIFE == pytest.approx(
1628.0823, rel=0.08
), "Minimum Life For Fatigue Tool 1"
assert FAT_Tool_1_LIFE == pytest.approx(1628.0823, rel=0.08), (
"Minimum Life For Fatigue Tool 1"
)

FAT_TOOL_1_DAMAGE = DAMAGE.Maximum.Value
assert FAT_TOOL_1_DAMAGE == pytest.approx(
614.2195, rel=0.08
), "Maximum Damage For Fatigue Tool 1"
assert FAT_TOOL_1_DAMAGE == pytest.approx(614.2195, rel=0.08), (
"Maximum Damage For Fatigue Tool 1"
)

FAT_TOOL_1_Safety_Factor = safetyFactor.Minimum.Value
assert FAT_TOOL_1_Safety_Factor == pytest.approx(
0.0122, rel=0.08
), "Minimum Safety Factor For Fatigue Tool 1"
assert FAT_TOOL_1_Safety_Factor == pytest.approx(0.0122, rel=0.08), (
"Minimum Safety Factor For Fatigue Tool 1"
)

FAT_TOOL_2_LIFE = FAT_TOOL2.Children[0].Minimum.Value
assert FAT_TOOL_2_LIFE == pytest.approx(
1628.0823, rel=0.08
), "Minimum Life For Fatigue Tool 2"
assert FAT_TOOL_2_LIFE == pytest.approx(1628.0823, rel=0.08), (
"Minimum Life For Fatigue Tool 2"
)

FAT_TOOL_2_DAMAGE = FAT_TOOL2.Children[1].Maximum.Value
assert FAT_TOOL_2_DAMAGE == pytest.approx(
614.2195, rel=0.08
), "Maximum Damage For Fatigue Tool 2"
assert FAT_TOOL_2_DAMAGE == pytest.approx(614.2195, rel=0.08), (
"Maximum Damage For Fatigue Tool 2"
)

FAT_TOOL_2_Safety_Factor = FAT_TOOL2.Children[2].Minimum.Value
assert FAT_TOOL_2_Safety_Factor == pytest.approx(
0.0122, rel=0.08
), "Minimum Safety Factor For Fatigue Tool 2"
assert FAT_TOOL_2_Safety_Factor == pytest.approx(0.0122, rel=0.08), (
"Minimum Safety Factor For Fatigue Tool 2"
)

_innertest()
2 changes: 1 addition & 1 deletion tests/test_cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@
import subprocess
import sys

import ansys.tools.path as atp
from click.testing import CliRunner
import pytest

Expand All @@ -36,7 +37,6 @@
get_stubs_versions,
)
from ansys.mechanical.core.run import _cli_impl, cli
import ansys.tools.path as atp

STUBS_LOC = get_stubs_location()
STUBS_REVNS = get_stubs_versions(STUBS_LOC)
Expand Down
2 changes: 1 addition & 1 deletion tests/test_mechanical.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,13 +25,13 @@
from pathlib import Path
import re

import ansys.tools.path
import conftest
import pytest

import ansys.mechanical.core as pymechanical
import ansys.mechanical.core.errors as errors
import ansys.mechanical.core.misc as misc
import ansys.tools.path


def new_python_script_api(mechanical):
Expand Down