Skip to content

Commit

Permalink
Merge branch 'main' into dependabot/pip/mock-gte-5.1.0-and-lt-5.3
Browse files Browse the repository at this point in the history
  • Loading branch information
Samuelopez-ansys authored Mar 8, 2025
2 parents 9420909 + 7593557 commit ce98dd3
Show file tree
Hide file tree
Showing 142 changed files with 550 additions and 86 deletions.
142 changes: 140 additions & 2 deletions .github/workflows/ci_cd.yml
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,7 @@ jobs:
python -c "import ansys.aedt.core; from ansys.aedt.core import __version__"
unit-tests:
name: Running unit tests
needs: [smoke-tests]
Expand Down Expand Up @@ -384,7 +385,7 @@ jobs:
- uses: codecov/codecov-action@v5
with:
name: codecov-system-general-tests
name: codecov-system-general-tests-linux
files: ./coverage.xml
flags: linux_system_general

Expand All @@ -395,9 +396,146 @@ jobs:
path: junit/test-results.xml
if: ${{ always() }}


# # =================================================================================================
# # vvvvvvvvvvvvvvvvvvvvvvvvvvvvvv RUNNING ON SELF-HOSTED RUNNER vvvvvvvvvvvvvvvvvvvvvvvvvvvvvv
# # =================================================================================================

system-tests-visualization-windows:
name: Testing and coverage Visualization (Windows)
needs: [integration-tests]
if: github.event.pull_request.draft == false
runs-on: [ self-hosted, Windows, pyaedt ]
steps:
- name: Install Git and checkout project
uses: actions/checkout@v4

- name: Setup Python
uses: actions/setup-python@v5
with:
python-version: ${{ env.MAIN_PYTHON_VERSION }}

- name: Create virtual environment
run: |
python -m venv .venv
.venv\Scripts\Activate.ps1
python -m pip install pip -U
python -m pip install wheel setuptools -U
python -c "import sys; print(sys.executable)"
- name: Install pyaedt and tests dependencies
run: |
.venv\Scripts\Activate.ps1
pip install .[tests]
- name: Install CI dependencies (e.g. vtk-osmesa)
run: |
.venv\Scripts\Activate.ps1
# Uninstall conflicting dependencies
pip uninstall --yes vtk
pip install --extra-index-url https://wheels.vtk.org vtk-osmesa
- name: Run tests marked with 'visualization'
uses: nick-fields/retry@v3
env:
PYTHONMALLOC: malloc
with:
max_attempts: 2
retry_on: error
timeout_minutes: 120
command: |
.venv\Scripts\Activate.ps1
pytest ${{ env.PYTEST_ARGUMENTS }} -n 4 --dist loadfile --timeout=600 -m visualization
- uses: codecov/codecov-action@v5
with:
name: codecov-system-visualization-tests-windows
files: ./coverage.xml
flags: windows_system_visualization

- name: Upload pytest test results
uses: actions/upload-artifact@v4
with:
name: pytest-visualization-windows
path: junit/test-results.xml
if: ${{ always() }}

# # =================================================================================================
# # vvvvvvvvvvvvvvvvvvvvvvvvvvvvvv RUNNING ON SELF-HOSTED RUNNER vvvvvvvvvvvvvvvvvvvvvvvvvvvvvv
# # =================================================================================================

system-tests-visualization-linux:
name: Testing and coverage visualization(Linux)
if: github.event.pull_request.draft == false
needs: [integration-tests]
runs-on: [ self-hosted, Linux, pyaedt ]
env:
ANSYSEM_ROOT251: '/opt/AnsysEM/v251/AnsysEM'
ANS_NODEPCHECK: '1'
steps:
- name: Install Git and checkout project
uses: actions/checkout@v4

- name: Setup Python
uses: actions/setup-python@v5
with:
python-version: ${{ env.MAIN_PYTHON_VERSION }}

- name: Create virtual environment
run: |
export LD_LIBRARY_PATH=${{ env.ANSYSEM_ROOT251 }}/common/mono/Linux64/lib64:$LD_LIBRARY_PATH
python -m venv .venv
source .venv/bin/activate
python -m pip install --trusted-host pypi.org --trusted-host pypi.python.org --trusted-host files.pythonhosted.org pip -U
python -m pip install --trusted-host pypi.org --trusted-host pypi.python.org --trusted-host files.pythonhosted.org wheel setuptools -U
python -c "import sys; print(sys.executable)"
- name: Install pyaedt and tests dependencies
run: |
export LD_LIBRARY_PATH=${{ env.ANSYSEM_ROOT251 }}/common/mono/Linux64/lib64:$LD_LIBRARY_PATH
source .venv/bin/activate
pip install .[tests]
- name: Install CI dependencies (e.g. vtk-osmesa)
run: |
source .venv/bin/activate
# Uninstall conflicting dependencies
pip uninstall --yes vtk
pip install --extra-index-url https://wheels.vtk.org vtk-osmesa
- name: Run tests marked with 'visualization'
uses: nick-fields/retry@v3
with:
max_attempts: 2
retry_on: error
timeout_minutes: 120
command: |
export LD_LIBRARY_PATH=${{ env.ANSYSEM_ROOT251 }}/common/mono/Linux64/lib64:$LD_LIBRARY_PATH
source .venv/bin/activate
pytest ${{ env.PYTEST_ARGUMENTS }} -n 4 --dist loadfile --timeout=600 -m visualization
- uses: codecov/codecov-action@v5
with:
name: codecov-system-visualization-tests-linux
files: ./coverage.xml
flags: linux_system_visualization

- name: Upload pytest test results
uses: actions/upload-artifact@v4
with:
name: pytest-visualization-linux
path: junit/test-results.xml
if: ${{ always() }}

package:
name: Package library
needs: [system-tests-general-windows, system-tests-general-linux, system-tests-solvers-windows, system-tests-solvers-linux, doc-build]
needs: [system-tests-general-windows,
system-tests-general-linux,
system-tests-solvers-windows,
system-tests-solvers-linux,
system-tests-visualization-windows,
system-tests-visualization-linux,
doc-build]
runs-on: ubuntu-latest
steps:
- name: Build library source and wheel artifacts
Expand Down
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -402,3 +402,5 @@ model.index\+

# test coverage output
/.cov/
/tests/system/visualization/local_config.json
/tests/system/general/pyaedt_settings.yaml
1 change: 1 addition & 0 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ exclude: |
^src/ansys/aedt/core/sbrplus/matlab/|
^src/ansys/aedt/core/workflows/installer|
tests/system/general/example_models/|
tests/system/visualization/example_models/|
tests/system/solvers/example_models/
)
Expand Down
1 change: 1 addition & 0 deletions doc/changelog.d/5881.fixed.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Created a new visualization folder
10 changes: 7 additions & 3 deletions src/ansys/aedt/core/application/design.py
Original file line number Diff line number Diff line change
Expand Up @@ -1126,8 +1126,11 @@ def _find_design(self) -> Tuple[str, str]:
elif self._temp_solution_type in des.GetSolutionType():
valids.append(name)
if len(valids) > 1:
des_name = self.oproject.GetActiveDesign().GetName()
if des_name in valids:
try:
des_name = self.oproject.GetActiveDesign().GetName()
except Exception:
des_name = None
if des_name and des_name in valids:
activedes = self.oproject.GetActiveDesign().GetName()
else:
activedes = valids[0]
Expand Down Expand Up @@ -1244,7 +1247,8 @@ def oproject(self, proj_name=None):
path = os.path.dirname(proj_name)
self.odesktop.RestoreProjectArchive(proj_name, os.path.join(path, name), True, True)
time.sleep(0.5)
self._oproject = self.desktop_class.active_project()
proj_name = name[:-5]
self._oproject = self.desktop_class.active_project(proj_name)
self._add_handler()
self.logger.info(f"Archive {proj_name} has been restored to project {self._oproject.GetName()}")
elif ".def" in proj_name or proj_name[-5:] == ".aedb":
Expand Down
23 changes: 20 additions & 3 deletions src/ansys/aedt/core/desktop.py
Original file line number Diff line number Diff line change
Expand Up @@ -780,10 +780,22 @@ def active_design(self, project_object=None, name=None, design_type=None):
"""
if not project_object:
project_object = self.active_project()
if not project_object:
return None
if not name:
active_design = project_object.GetActiveDesign()
active_design = None
try:
active_design = project_object.GetActiveDesign()
except Exception:
active_design = project_object.SetActiveDesign(self.design_list(project_object.GetName())[0])
finally:
if not active_design and self.design_list(project_object.GetName()):
active_design = project_object.SetActiveDesign(self.design_list(project_object.GetName())[0])
else:
active_design = project_object.SetActiveDesign(name)
try:
active_design = project_object.SetActiveDesign(name)
except Exception:
return None
if is_linux and settings.aedt_version == "2024.1" and design_type == "Circuit Design": # pragma: no cover
time.sleep(1)
self.close_windows()
Expand All @@ -808,8 +820,13 @@ def active_project(self, name=None):
"""
if not name:
active_project = self.odesktop.GetActiveProject()
if not active_project and self.project_list():
active_project = self.odesktop.SetActiveProject(self.project_list()[0])
else:
active_project = self.odesktop.SetActiveProject(name)
try:
active_project = self.odesktop.SetActiveProject(name)
except Exception:
return None
if is_linux and settings.aedt_version == "2024.1": # pragma: no cover
time.sleep(1)
self.close_windows()
Expand Down
6 changes: 5 additions & 1 deletion src/ansys/aedt/core/workflows/hfss/choke_designer.py
Original file line number Diff line number Diff line change
Expand Up @@ -348,7 +348,11 @@ def main(extension_args):
design_name = active_design.GetName()

if not hfss: # pragma: no cover
hfss = Hfss(project_name, design_name)
if app.design_type(project_name, design_name) == "HFSS":
hfss = Hfss(project_name, design_name)
else:
hfss = Hfss()
hfss.save_project()

hfss.solution_type = "Terminal"

Expand Down
1 change: 1 addition & 0 deletions tests/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,3 +29,4 @@
TESTS_UNIT_PATH = TESTS_PATH / "unit"
TESTS_GENERAL_PATH = TESTS_SYSTEM_PATH / "general"
TESTS_SOLVERS_PATH = TESTS_SYSTEM_PATH / "solvers"
TESTS_VISUALIZATION_PATH = TESTS_SYSTEM_PATH / "visualization"
3 changes: 3 additions & 0 deletions tests/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@
SYSTEM_TEST_PREFIX = "tests/system"
SYSTEM_SOLVERS_TEST_PREFIX = "tests/system/solvers"
SYSTEM_GENERAL_TEST_PREFIX = "tests/system/general"
VISUALIZATION_GENERAL_TEST_PREFIX = "tests/system/visualization"


def pytest_collection_modifyitems(config: pytest.Config, items: List[pytest.Item]):
Expand All @@ -45,6 +46,8 @@ def pytest_collection_modifyitems(config: pytest.Config, items: List[pytest.Item
item.add_marker(pytest.mark.solvers)
elif item.nodeid.startswith(SYSTEM_GENERAL_TEST_PREFIX):
item.add_marker(pytest.mark.general)
elif item.nodeid.startswith(VISUALIZATION_GENERAL_TEST_PREFIX):
item.add_marker(pytest.mark.visualization)


@pytest.fixture
Expand Down
37 changes: 0 additions & 37 deletions tests/system/general/test_28_Maxwell3D.py
Original file line number Diff line number Diff line change
Expand Up @@ -513,43 +513,6 @@ def test_reduced_matrix(self, m3d_app):
out = matrix.join_parallel(["Cur5"])
assert not out[0]

@pytest.mark.skipif(is_linux, reason="Failing in Ubuntu 22.")
def test_get_solution_data(self, m3d_app):
m3d_app.solution_type = SOLUTIONS.Maxwell3d.EddyCurrent

m3d_app.modeler.create_box([0, 1.5, 0], [1, 2.5, 5], name="Coil_1", material="aluminum")
m3d_app.modeler.create_box([8.5, 1.5, 0], [1, 2.5, 5], name="Coil_2", material="aluminum")
m3d_app.modeler.create_box([16, 1.5, 0], [1, 2.5, 5], name="Coil_3", material="aluminum")
m3d_app.modeler.create_box([32, 1.5, 0], [1, 2.5, 5], name="Coil_4", material="aluminum")

rectangle1 = m3d_app.modeler.create_rectangle(0, [0.5, 1.5, 0], [2.5, 5], name="Sheet1")
rectangle2 = m3d_app.modeler.create_rectangle(0, [9, 1.5, 0], [2.5, 5], name="Sheet2")
rectangle3 = m3d_app.modeler.create_rectangle(0, [16.5, 1.5, 0], [2.5, 5], name="Sheet3")

m3d_app.assign_current(rectangle1.faces[0], amplitude=1, name="Cur1")
m3d_app.assign_current(rectangle2.faces[0], amplitude=1, name="Cur2")
m3d_app.assign_current(rectangle3.faces[0], amplitude=1, name="Cur3")

matrix = m3d_app.assign_matrix(assignment=["Cur1", "Cur2", "Cur3"], matrix_name="Matrix1")
matrix.join_series(sources=["Cur1", "Cur2"], matrix_name="ReducedMatrix1")

setup = m3d_app.create_setup(MaximumPasses=2)
m3d_app.analyze(setup=setup.name)

expressions = m3d_app.post.available_report_quantities(
report_category="EddyCurrent", display_type="Data Table", context={"Matrix1": "ReducedMatrix1"}
)
data = m3d_app.post.get_solution_data(expressions=expressions, context={"Matrix1": "ReducedMatrix1"})
assert data

expressions = m3d_app.post.available_report_quantities(report_category="EddyCurrent", display_type="Data Table")
assert isinstance(expressions, list)
expressions = m3d_app.post.available_report_quantities(
report_category="EddyCurrent", display_type="Data Table", context="Matrix1"
)
data = m3d_app.post.get_solution_data(expressions=expressions, context="Matrix1")
assert data

def test_initial_mesh_settings(self, m3d_app):
assert m3d_app.mesh.initial_mesh_settings
assert m3d_app.mesh.initial_mesh_settings.props
Expand Down
23 changes: 23 additions & 0 deletions tests/system/visualization/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
# -*- coding: utf-8 -*-
#
# Copyright (C) 2021 - 2025 ANSYS, Inc. and/or its affiliates.
# SPDX-License-Identifier: MIT
#
#
# Permission is hereby granted, free of charge, to any person obtaining a copy
# of this software and associated documentation files (the "Software"), to deal
# in the Software without restriction, including without limitation the rights
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
# copies of the Software, and to permit persons to whom the Software is
# furnished to do so, subject to the following conditions:
#
# The above copyright notice and this permission notice shall be included in all
# copies or substantial portions of the Software.
#
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
# SOFTWARE.
Loading

0 comments on commit ce98dd3

Please sign in to comment.