Skip to content

Commit ce98dd3

Browse files
Merge branch 'main' into dependabot/pip/mock-gte-5.1.0-and-lt-5.3
2 parents 9420909 + 7593557 commit ce98dd3

File tree

142 files changed

+550
-86
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

142 files changed

+550
-86
lines changed

.github/workflows/ci_cd.yml

Lines changed: 140 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -98,6 +98,7 @@ jobs:
9898
python -c "import ansys.aedt.core; from ansys.aedt.core import __version__"
9999
100100
101+
101102
unit-tests:
102103
name: Running unit tests
103104
needs: [smoke-tests]
@@ -384,7 +385,7 @@ jobs:
384385
385386
- uses: codecov/codecov-action@v5
386387
with:
387-
name: codecov-system-general-tests
388+
name: codecov-system-general-tests-linux
388389
files: ./coverage.xml
389390
flags: linux_system_general
390391

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

399+
400+
# # =================================================================================================
401+
# # vvvvvvvvvvvvvvvvvvvvvvvvvvvvvv RUNNING ON SELF-HOSTED RUNNER vvvvvvvvvvvvvvvvvvvvvvvvvvvvvv
402+
# # =================================================================================================
403+
404+
system-tests-visualization-windows:
405+
name: Testing and coverage Visualization (Windows)
406+
needs: [integration-tests]
407+
if: github.event.pull_request.draft == false
408+
runs-on: [ self-hosted, Windows, pyaedt ]
409+
steps:
410+
- name: Install Git and checkout project
411+
uses: actions/checkout@v4
412+
413+
- name: Setup Python
414+
uses: actions/setup-python@v5
415+
with:
416+
python-version: ${{ env.MAIN_PYTHON_VERSION }}
417+
418+
- name: Create virtual environment
419+
run: |
420+
python -m venv .venv
421+
.venv\Scripts\Activate.ps1
422+
python -m pip install pip -U
423+
python -m pip install wheel setuptools -U
424+
python -c "import sys; print(sys.executable)"
425+
426+
- name: Install pyaedt and tests dependencies
427+
run: |
428+
.venv\Scripts\Activate.ps1
429+
pip install .[tests]
430+
431+
- name: Install CI dependencies (e.g. vtk-osmesa)
432+
run: |
433+
.venv\Scripts\Activate.ps1
434+
# Uninstall conflicting dependencies
435+
pip uninstall --yes vtk
436+
pip install --extra-index-url https://wheels.vtk.org vtk-osmesa
437+
438+
- name: Run tests marked with 'visualization'
439+
uses: nick-fields/retry@v3
440+
env:
441+
PYTHONMALLOC: malloc
442+
with:
443+
max_attempts: 2
444+
retry_on: error
445+
timeout_minutes: 120
446+
command: |
447+
.venv\Scripts\Activate.ps1
448+
pytest ${{ env.PYTEST_ARGUMENTS }} -n 4 --dist loadfile --timeout=600 -m visualization
449+
450+
- uses: codecov/codecov-action@v5
451+
with:
452+
name: codecov-system-visualization-tests-windows
453+
files: ./coverage.xml
454+
flags: windows_system_visualization
455+
456+
- name: Upload pytest test results
457+
uses: actions/upload-artifact@v4
458+
with:
459+
name: pytest-visualization-windows
460+
path: junit/test-results.xml
461+
if: ${{ always() }}
462+
463+
# # =================================================================================================
464+
# # vvvvvvvvvvvvvvvvvvvvvvvvvvvvvv RUNNING ON SELF-HOSTED RUNNER vvvvvvvvvvvvvvvvvvvvvvvvvvvvvv
465+
# # =================================================================================================
466+
467+
system-tests-visualization-linux:
468+
name: Testing and coverage visualization(Linux)
469+
if: github.event.pull_request.draft == false
470+
needs: [integration-tests]
471+
runs-on: [ self-hosted, Linux, pyaedt ]
472+
env:
473+
ANSYSEM_ROOT251: '/opt/AnsysEM/v251/AnsysEM'
474+
ANS_NODEPCHECK: '1'
475+
steps:
476+
- name: Install Git and checkout project
477+
uses: actions/checkout@v4
478+
479+
- name: Setup Python
480+
uses: actions/setup-python@v5
481+
with:
482+
python-version: ${{ env.MAIN_PYTHON_VERSION }}
483+
484+
- name: Create virtual environment
485+
run: |
486+
export LD_LIBRARY_PATH=${{ env.ANSYSEM_ROOT251 }}/common/mono/Linux64/lib64:$LD_LIBRARY_PATH
487+
python -m venv .venv
488+
source .venv/bin/activate
489+
python -m pip install --trusted-host pypi.org --trusted-host pypi.python.org --trusted-host files.pythonhosted.org pip -U
490+
python -m pip install --trusted-host pypi.org --trusted-host pypi.python.org --trusted-host files.pythonhosted.org wheel setuptools -U
491+
python -c "import sys; print(sys.executable)"
492+
493+
- name: Install pyaedt and tests dependencies
494+
run: |
495+
export LD_LIBRARY_PATH=${{ env.ANSYSEM_ROOT251 }}/common/mono/Linux64/lib64:$LD_LIBRARY_PATH
496+
source .venv/bin/activate
497+
pip install .[tests]
498+
499+
- name: Install CI dependencies (e.g. vtk-osmesa)
500+
run: |
501+
source .venv/bin/activate
502+
# Uninstall conflicting dependencies
503+
pip uninstall --yes vtk
504+
pip install --extra-index-url https://wheels.vtk.org vtk-osmesa
505+
506+
- name: Run tests marked with 'visualization'
507+
uses: nick-fields/retry@v3
508+
with:
509+
max_attempts: 2
510+
retry_on: error
511+
timeout_minutes: 120
512+
command: |
513+
export LD_LIBRARY_PATH=${{ env.ANSYSEM_ROOT251 }}/common/mono/Linux64/lib64:$LD_LIBRARY_PATH
514+
source .venv/bin/activate
515+
pytest ${{ env.PYTEST_ARGUMENTS }} -n 4 --dist loadfile --timeout=600 -m visualization
516+
517+
- uses: codecov/codecov-action@v5
518+
with:
519+
name: codecov-system-visualization-tests-linux
520+
files: ./coverage.xml
521+
flags: linux_system_visualization
522+
523+
- name: Upload pytest test results
524+
uses: actions/upload-artifact@v4
525+
with:
526+
name: pytest-visualization-linux
527+
path: junit/test-results.xml
528+
if: ${{ always() }}
529+
398530
package:
399531
name: Package library
400-
needs: [system-tests-general-windows, system-tests-general-linux, system-tests-solvers-windows, system-tests-solvers-linux, doc-build]
532+
needs: [system-tests-general-windows,
533+
system-tests-general-linux,
534+
system-tests-solvers-windows,
535+
system-tests-solvers-linux,
536+
system-tests-visualization-windows,
537+
system-tests-visualization-linux,
538+
doc-build]
401539
runs-on: ubuntu-latest
402540
steps:
403541
- name: Build library source and wheel artifacts

.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -402,3 +402,5 @@ model.index\+
402402

403403
# test coverage output
404404
/.cov/
405+
/tests/system/visualization/local_config.json
406+
/tests/system/general/pyaedt_settings.yaml

.pre-commit-config.yaml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ exclude: |
1919
^src/ansys/aedt/core/sbrplus/matlab/|
2020
^src/ansys/aedt/core/workflows/installer|
2121
tests/system/general/example_models/|
22+
tests/system/visualization/example_models/|
2223
tests/system/solvers/example_models/
2324
)
2425

doc/changelog.d/5881.fixed.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Created a new visualization folder

src/ansys/aedt/core/application/design.py

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1126,8 +1126,11 @@ def _find_design(self) -> Tuple[str, str]:
11261126
elif self._temp_solution_type in des.GetSolutionType():
11271127
valids.append(name)
11281128
if len(valids) > 1:
1129-
des_name = self.oproject.GetActiveDesign().GetName()
1130-
if des_name in valids:
1129+
try:
1130+
des_name = self.oproject.GetActiveDesign().GetName()
1131+
except Exception:
1132+
des_name = None
1133+
if des_name and des_name in valids:
11311134
activedes = self.oproject.GetActiveDesign().GetName()
11321135
else:
11331136
activedes = valids[0]
@@ -1244,7 +1247,8 @@ def oproject(self, proj_name=None):
12441247
path = os.path.dirname(proj_name)
12451248
self.odesktop.RestoreProjectArchive(proj_name, os.path.join(path, name), True, True)
12461249
time.sleep(0.5)
1247-
self._oproject = self.desktop_class.active_project()
1250+
proj_name = name[:-5]
1251+
self._oproject = self.desktop_class.active_project(proj_name)
12481252
self._add_handler()
12491253
self.logger.info(f"Archive {proj_name} has been restored to project {self._oproject.GetName()}")
12501254
elif ".def" in proj_name or proj_name[-5:] == ".aedb":

src/ansys/aedt/core/desktop.py

Lines changed: 20 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -780,10 +780,22 @@ def active_design(self, project_object=None, name=None, design_type=None):
780780
"""
781781
if not project_object:
782782
project_object = self.active_project()
783+
if not project_object:
784+
return None
783785
if not name:
784-
active_design = project_object.GetActiveDesign()
786+
active_design = None
787+
try:
788+
active_design = project_object.GetActiveDesign()
789+
except Exception:
790+
active_design = project_object.SetActiveDesign(self.design_list(project_object.GetName())[0])
791+
finally:
792+
if not active_design and self.design_list(project_object.GetName()):
793+
active_design = project_object.SetActiveDesign(self.design_list(project_object.GetName())[0])
785794
else:
786-
active_design = project_object.SetActiveDesign(name)
795+
try:
796+
active_design = project_object.SetActiveDesign(name)
797+
except Exception:
798+
return None
787799
if is_linux and settings.aedt_version == "2024.1" and design_type == "Circuit Design": # pragma: no cover
788800
time.sleep(1)
789801
self.close_windows()
@@ -808,8 +820,13 @@ def active_project(self, name=None):
808820
"""
809821
if not name:
810822
active_project = self.odesktop.GetActiveProject()
823+
if not active_project and self.project_list():
824+
active_project = self.odesktop.SetActiveProject(self.project_list()[0])
811825
else:
812-
active_project = self.odesktop.SetActiveProject(name)
826+
try:
827+
active_project = self.odesktop.SetActiveProject(name)
828+
except Exception:
829+
return None
813830
if is_linux and settings.aedt_version == "2024.1": # pragma: no cover
814831
time.sleep(1)
815832
self.close_windows()

src/ansys/aedt/core/workflows/hfss/choke_designer.py

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -348,7 +348,11 @@ def main(extension_args):
348348
design_name = active_design.GetName()
349349

350350
if not hfss: # pragma: no cover
351-
hfss = Hfss(project_name, design_name)
351+
if app.design_type(project_name, design_name) == "HFSS":
352+
hfss = Hfss(project_name, design_name)
353+
else:
354+
hfss = Hfss()
355+
hfss.save_project()
352356

353357
hfss.solution_type = "Terminal"
354358

tests/__init__.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,3 +29,4 @@
2929
TESTS_UNIT_PATH = TESTS_PATH / "unit"
3030
TESTS_GENERAL_PATH = TESTS_SYSTEM_PATH / "general"
3131
TESTS_SOLVERS_PATH = TESTS_SYSTEM_PATH / "solvers"
32+
TESTS_VISUALIZATION_PATH = TESTS_SYSTEM_PATH / "visualization"

tests/conftest.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@
3030
SYSTEM_TEST_PREFIX = "tests/system"
3131
SYSTEM_SOLVERS_TEST_PREFIX = "tests/system/solvers"
3232
SYSTEM_GENERAL_TEST_PREFIX = "tests/system/general"
33+
VISUALIZATION_GENERAL_TEST_PREFIX = "tests/system/visualization"
3334

3435

3536
def pytest_collection_modifyitems(config: pytest.Config, items: List[pytest.Item]):
@@ -45,6 +46,8 @@ def pytest_collection_modifyitems(config: pytest.Config, items: List[pytest.Item
4546
item.add_marker(pytest.mark.solvers)
4647
elif item.nodeid.startswith(SYSTEM_GENERAL_TEST_PREFIX):
4748
item.add_marker(pytest.mark.general)
49+
elif item.nodeid.startswith(VISUALIZATION_GENERAL_TEST_PREFIX):
50+
item.add_marker(pytest.mark.visualization)
4851

4952

5053
@pytest.fixture

tests/system/general/test_28_Maxwell3D.py

Lines changed: 0 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -513,43 +513,6 @@ def test_reduced_matrix(self, m3d_app):
513513
out = matrix.join_parallel(["Cur5"])
514514
assert not out[0]
515515

516-
@pytest.mark.skipif(is_linux, reason="Failing in Ubuntu 22.")
517-
def test_get_solution_data(self, m3d_app):
518-
m3d_app.solution_type = SOLUTIONS.Maxwell3d.EddyCurrent
519-
520-
m3d_app.modeler.create_box([0, 1.5, 0], [1, 2.5, 5], name="Coil_1", material="aluminum")
521-
m3d_app.modeler.create_box([8.5, 1.5, 0], [1, 2.5, 5], name="Coil_2", material="aluminum")
522-
m3d_app.modeler.create_box([16, 1.5, 0], [1, 2.5, 5], name="Coil_3", material="aluminum")
523-
m3d_app.modeler.create_box([32, 1.5, 0], [1, 2.5, 5], name="Coil_4", material="aluminum")
524-
525-
rectangle1 = m3d_app.modeler.create_rectangle(0, [0.5, 1.5, 0], [2.5, 5], name="Sheet1")
526-
rectangle2 = m3d_app.modeler.create_rectangle(0, [9, 1.5, 0], [2.5, 5], name="Sheet2")
527-
rectangle3 = m3d_app.modeler.create_rectangle(0, [16.5, 1.5, 0], [2.5, 5], name="Sheet3")
528-
529-
m3d_app.assign_current(rectangle1.faces[0], amplitude=1, name="Cur1")
530-
m3d_app.assign_current(rectangle2.faces[0], amplitude=1, name="Cur2")
531-
m3d_app.assign_current(rectangle3.faces[0], amplitude=1, name="Cur3")
532-
533-
matrix = m3d_app.assign_matrix(assignment=["Cur1", "Cur2", "Cur3"], matrix_name="Matrix1")
534-
matrix.join_series(sources=["Cur1", "Cur2"], matrix_name="ReducedMatrix1")
535-
536-
setup = m3d_app.create_setup(MaximumPasses=2)
537-
m3d_app.analyze(setup=setup.name)
538-
539-
expressions = m3d_app.post.available_report_quantities(
540-
report_category="EddyCurrent", display_type="Data Table", context={"Matrix1": "ReducedMatrix1"}
541-
)
542-
data = m3d_app.post.get_solution_data(expressions=expressions, context={"Matrix1": "ReducedMatrix1"})
543-
assert data
544-
545-
expressions = m3d_app.post.available_report_quantities(report_category="EddyCurrent", display_type="Data Table")
546-
assert isinstance(expressions, list)
547-
expressions = m3d_app.post.available_report_quantities(
548-
report_category="EddyCurrent", display_type="Data Table", context="Matrix1"
549-
)
550-
data = m3d_app.post.get_solution_data(expressions=expressions, context="Matrix1")
551-
assert data
552-
553516
def test_initial_mesh_settings(self, m3d_app):
554517
assert m3d_app.mesh.initial_mesh_settings
555518
assert m3d_app.mesh.initial_mesh_settings.props

0 commit comments

Comments
 (0)