Skip to content

Commit

Permalink
REFACTOR!: Architecture to match pyansys guide lines (#4849)
Browse files Browse the repository at this point in the history
Co-authored-by: Samuel Lopez <[email protected]>
Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
Co-authored-by: Matthew Young <[email protected]>
  • Loading branch information
4 people authored Aug 16, 2024
1 parent ca17b80 commit cbad1a0
Show file tree
Hide file tree
Showing 689 changed files with 37,143 additions and 3,972 deletions.
6 changes: 3 additions & 3 deletions .github/CODEOWNERS
Validating CODEOWNERS rules …
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
.github/* @MaxJPRey @maxcapodi78 @Samuelopez-ansys

/_unittest/test_26_emit.py @jsalant22 @myoung301
/pyaedt/emit.py @jsalant22 @myoung301
/pyaedt/emit_core/ @jsalant22 @myoung301
/pyaedt/modeler/circuits/PrimitivesEmit.py @jsalant22 @myoung301
/src/ansys/aedt/core/emit.py @jsalant22 @myoung301
/src/ansys/aedt/core/emit_core/ @jsalant22 @myoung301
/src/ansys/aedt/core/modeler/circuits/PrimitivesEmit.py @jsalant22 @myoung301
/examples/07-EMIT/ @jsalant22 @myoung301
53 changes: 12 additions & 41 deletions .github/workflows/ci_cd.yml
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ jobs:

- name: Import python package
run: |
python -c "import pyaedt; from pyaedt import __version__"
python -c "import ansys.aedt.core; from ansys.aedt.core import __version__"
# TODO: Update to ansys/actions/doc-build@v6 once we remove examples
doc-build:
Expand All @@ -93,8 +93,8 @@ jobs:
- name: Retrieve PyAEDT version
id: version
run: |
echo "PYAEDT_VERSION=$(python -c 'from pyaedt import __version__; print(__version__)')" >> $GITHUB_OUTPUT
echo "PyAEDT version is: $(python -c "from pyaedt import __version__; print(__version__)")"
echo "PYAEDT_VERSION=$(python -c 'from ansys.aedt.core import __version__; print(__version__)')" >> $GITHUB_OUTPUT
echo "PyAEDT version is: $(python -c "from ansys.aedt.core import __version__; print(__version__)")"
- name: Install doc build requirements
run: |
Expand Down Expand Up @@ -166,8 +166,8 @@ jobs:
id: version
run: |
.venv\Scripts\Activate.ps1
echo "PYAEDT_VERSION=$(python -c 'from pyaedt import __version__; print(__version__)')" >> $GITHUB_OUTPUT
echo "PyAEDT version is: $(python -c "from pyaedt import __version__; print(__version__)")"
echo "PYAEDT_VERSION=$(python -c 'from ansys.aedt.core import __version__; print(__version__)')" >> $GITHUB_OUTPUT
echo "PyAEDT version is: $(python -c "from ansys.aedt.core import __version__; print(__version__)")"
- name: Install CI dependencies (e.g. vtk-osmesa)
run: |
Expand Down Expand Up @@ -264,7 +264,7 @@ jobs:
PYTHONMALLOC: malloc
run: |
.venv\Scripts\Activate.ps1
pytest --durations=50 -v --cov=pyaedt --cov-report=xml --cov-report=html --junitxml=junit/test-results.xml _unittest_solvers
pytest --durations=50 -v --cov=ansys.aedt.core --cov-report=xml --cov-report=html --junitxml=junit/test-results.xml _unittest_solvers
- uses: codecov/codecov-action@v4
with:
Expand Down Expand Up @@ -321,7 +321,7 @@ jobs:
run: |
export LD_LIBRARY_PATH=${{ env.ANSYSEM_ROOT242 }}/common/mono/Linux64/lib64:${{ env.ANSYSEM_ROOT242 }}/Delcross:$LD_LIBRARY_PATH
source .venv/bin/activate
pytest --durations=50 -v --cov=pyaedt --cov-report=xml --cov-report=html --junitxml=junit/test-results.xml _unittest_solvers
pytest --durations=50 -v --cov=ansys.aedt.core --cov-report=xml --cov-report=html --junitxml=junit/test-results.xml _unittest_solvers
- uses: codecov/codecov-action@v4
with:
Expand Down Expand Up @@ -385,7 +385,7 @@ jobs:
timeout_minutes: 50
command: |
.venv\Scripts\Activate.ps1
pytest -n 4 --dist loadfile --durations=50 -v --cov=pyaedt --cov-report=xml --cov-report=html --junitxml=junit/test-results.xml _unittest
pytest -n 4 --dist loadfile --durations=50 -v --cov=ansys.aedt.core --cov-report=xml --cov-report=html --junitxml=junit/test-results.xml _unittest
- uses: codecov/codecov-action@v4
with:
Expand Down Expand Up @@ -454,7 +454,7 @@ jobs:
command: |
export LD_LIBRARY_PATH=${{ env.ANSYSEM_ROOT242 }}/common/mono/Linux64/lib64:${{ env.ANSYSEM_ROOT242 }}/Delcross:$LD_LIBRARY_PATH
source .venv/bin/activate
pytest -n 2 --dist loadfile --durations=50 -v --cov=pyaedt --cov-report=xml --cov-report=html --junitxml=junit/test-results.xml _unittest
pytest -n 2 --dist loadfile --durations=50 -v --cov=ansys.aedt.core --cov-report=xml --cov-report=html --junitxml=junit/test-results.xml _unittest
- uses: codecov/codecov-action@v4
with:
Expand All @@ -470,38 +470,9 @@ jobs:
path: junit/test-results.xml
if: ${{ always() }}

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

test-ironpython-windows:
name: Testing IronPython and coverage (Windows)
needs: [smoke-tests]
runs-on: [ self-hosted, Windows, pyaedt ]
steps:
- uses: actions/checkout@v4

- name: Run Ironpython tests
timeout-minutes: 5
run: |
$processA = start-process 'cmd' -ArgumentList '/c .\_unittest_ironpython\run_unittests_batchmode.cmd' -PassThru
$processA.WaitForExit()
- name: Get log content
run: |
get-content .\_unittest_ironpython\pyaedt_unit_test_ironpython.log
- name: Check for errors
run: |
$test_errors_failures = Select-String -Path .\_unittest_ironpython\pyaedt_unit_test_ironpython.log -Pattern "TextTestResult errors="
if ($test_errors_failures -ne $null)
{
exit 1
}
package:
name: Package library
needs: [test-windows, test-solvers-windows, test-ironpython-windows, test-linux, test-solvers-linux, doc-build]
needs: [test-windows, test-solvers-windows, test-linux, test-solvers-linux, doc-build]
runs-on: ubuntu-latest
steps:
- name: Build library source and wheel artifacts
Expand Down Expand Up @@ -556,8 +527,8 @@ jobs:

- name: Get the version to PyMeilisearch
run: |
VERSION=$(python -c "from pyaedt import __version__; print('.'.join(__version__.split('.')[:2]))")
VERSION_MEILI=$(python -c "from pyaedt import __version__; print('-'.join(__version__.split('.')[:2]))")
VERSION=$(python -c "from ansys.aedt.core import __version__; print('.'.join(__version__.split('.')[:2]))")
VERSION_MEILI=$(python -c "from ansys.aedt.core import __version__; print('-'.join(__version__.split('.')[:2]))")
echo "Calculated VERSION: $VERSION"
echo "Calculated VERSION_MEILI: $VERSION_MEILI"
echo "VERSION=$VERSION" >> $GITHUB_ENV
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/nightly-docs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -49,8 +49,8 @@ jobs:
id: version
run: |
.venv\Scripts\Activate.ps1
echo "PYAEDT_VERSION=$(python -c 'from pyaedt import __version__; print(__version__)')" >> $GITHUB_OUTPUT
echo "PyAEDT version is: $(python -c "from pyaedt import __version__; print(__version__)")"
echo "PYAEDT_VERSION=$(python -c 'from ansys.aedt.core import __version__; print(__version__)')" >> $GITHUB_OUTPUT
echo "PyAEDT version is: $(python -c "from ansys.aedt.core import __version__; print(__version__)")"
- name: Install CI dependencies (e.g. vtk-osmesa)
run: |
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/unit_test_prerelease.yml
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ jobs:
Copy-Item -Path "C:\actions-runner\local_config.json" -Destination "_unittest" -Force
mkdir tmp
cd tmp
python -c "import pyaedt; print('Imported pyaedt')"
python -c "import ansys.aedt.core; print('Imported pyaedt')"
# - name: "Check licences of packages"
# uses: pyansys/pydpf-actions/[email protected]
Expand All @@ -71,7 +71,7 @@ jobs:
run: |
testenv\Scripts\Activate.ps1
Set-Item -Path env:PYTHONMALLOC -Value "malloc"
pytest --tx 6*popen --durations=50 --dist loadfile -v --cov=pyaedt --cov-report=xml --junitxml=junit/test-results.xml --cov-report=html _unittest
pytest --tx 6*popen --durations=50 --dist loadfile -v --cov=ansys.aedt.core --cov-report=xml --junitxml=junit/test-results.xml --cov-report=html _unittest
- uses: codecov/codecov-action@v4
env:
Expand Down
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -361,7 +361,7 @@ doc/build_errors.txt
_autosummary/

# pip files
*.egg-info/*
*.egg-info*
build/
dist/

Expand Down
9 changes: 4 additions & 5 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -1,13 +1,12 @@
files: |
(?x)(
^pyaedt/|
^src/ansys/aedt/core/|
_unittest/
)
exclude: |
(?x)(
^pyaedt/rpc/|
^pyaedt/sbrplus/matlab/|
pyaedt/conftest.py|
^src/ansys/aedt/core/rpc/|
^src/ansys/aedt/core/sbrplus/matlab/|
_unittest/example_models/
)
Expand Down Expand Up @@ -69,7 +68,7 @@ repos:
rev: v0.4.3
hooks:
- id: add-license-headers
files: '(pyaedt|examples|_unittest|_unittest_ironpython|_unittest_solvers)/.*\.(py)'
files: '(src|examples|_unittest|_unittest_ironpython|_unittest_solvers)/.*\.(py)'
args:
- --custom_template=mit_license.jinja2
- --start_year=2021
Expand Down
1 change: 1 addition & 0 deletions MANIFEST.in
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
global-include ansys.aedt.core *.txt *.md *.toml *.json *.png *.xml *.areg *.joblib *.acf *.m *.ipynb *.py_build
4 changes: 2 additions & 2 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# Simple makefile to simplify repetitive build env management tasks under posix

CODESPELL_DIRS ?= ./pyaedt
CODESPELL_SKIP ?= "*.pyc,*.aedt,*.xml,*.txt,*.gif,*.png,*.jpg,*.js,*.html,*.doctree,*.ttf,*.woff,*.woff2,*.eot,*.mp4,*.inv,*.pickle,*.ipynb,flycheck*,./.git/*,./.hypothesis/*,*.yml,./docs/build/*,./docs/images/*,./dist/*,*~,.hypothesis*,./pyaedt/third_party,./docs/source/examples/*,*cover,*.dat,*.mac,\#*,PKG-INFO,*.mypy_cache/*,*.xml,*.aedt,*.svg"
CODESPELL_DIRS ?= ./src/ansys/aedt/core
CODESPELL_SKIP ?= "*.pyc,*.aedt,*.xml,*.txt,*.gif,*.png,*.jpg,*.js,*.html,*.doctree,*.ttf,*.woff,*.woff2,*.eot,*.mp4,*.inv,*.pickle,*.ipynb,flycheck*,./.git/*,./.hypothesis/*,*.yml,./docs/build/*,./docs/images/*,./dist/*,*~,.hypothesis*,./src/ansys/aedt/core/third_party,./docs/source/examples/*,*cover,*.dat,*.mac,\#*,PKG-INFO,*.mypy_cache/*,*.xml,*.aedt,*.svg"
CODESPELL_IGNORE ?= "ignore_words.txt"

all: doctest flake8
Expand Down
12 changes: 6 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -203,7 +203,7 @@ Usage examples follow.
``` python
# Launch AEDT 2022 R2 in non-graphical mode

from pyaedt import Desktop, Circuit
from ansys.aedt.core import Desktop, Circuit
with Desktop(specified_version="2022.2",
non_graphical=False, new_desktop_session=True,
close_on_exit=True, student_version=False):
Expand All @@ -220,7 +220,7 @@ Usage examples follow.
``` python
# Launch the latest installed version of AEDT in graphical mode

from pyaedt import Circuit
from ansys.aedt.core import Circuit
with Circuit(specified_version="2022.2",
non_graphical=False) as circuit:
...
Expand All @@ -240,14 +240,14 @@ On a CPython Server:
``` python
# Launch PyAEDT remote server on CPython

from pyaedt.common_rpc import pyaedt_service_manager
from ansys.aedt.core.common_rpc import pyaedt_service_manager
pyaedt_service_manager()
```

On any Windows client machine:

``` python
from pyaedt.common_rpc import create_session
from ansys.aedt.core.common_rpc import create_session
cl1 = create_session("server_name")
cl1.aedt(port=50000, non_graphical=False)
hfss = Hfss(machine="server_name", port=50000)
Expand All @@ -257,7 +257,7 @@ On any Windows client machine:
## Variables

``` python
from pyaedt.HFSS import HFSS
from ansys.aedt.core.HFSS import HFSS
with HFSS as hfss:
hfss["dim"] = "1mm" # design variable
hfss["$dim"] = "1mm" # project variable
Expand All @@ -268,7 +268,7 @@ On any Windows client machine:
``` python
# Create a box, assign variables, and assign materials.

from pyaedt.hfss import Hfss
from ansys.aedt.core.hfss import Hfss
with Hfss as hfss:
hfss.modeler.create_box([0, 0, 0], [10, "dim", 10],
"mybox", "aluminum")
Expand Down
12 changes: 6 additions & 6 deletions README_CN.md
Original file line number Diff line number Diff line change
Expand Up @@ -132,7 +132,7 @@ pip install pyaedt[all]
``` python
# 以非图形模式启动 AEDT 2022 R2

from pyaedt import Desktop, Circuit
from ansys.aedt.core import Desktop, Circuit
with Desktop(specified_version="2022.2",
non_graphical=False, new_desktop_session=True,
close_on_exit=True, student_version=False):
Expand All @@ -149,7 +149,7 @@ pip install pyaedt[all]
``` python
# Launch the latest installed version of AEDT in graphical mode

from pyaedt import Circuit
from ansys.aedt.core import Circuit
with Circuit(specified_version="2022.2",
non_graphical=False) as circuit:
...
Expand All @@ -168,14 +168,14 @@ CPython 服务器:
``` python
# 在CPython上启动PyAEDT远程服务器

from pyaedt.common_rpc import pyaedt_service_manager
from ansys.aedt.core.common_rpc import pyaedt_service_manager
pyaedt_service_manager()
```

任意的 Windows 客户端:

``` python
from pyaedt.common_rpc import create_session
from ansys.aedt.core.common_rpc import create_session
cl1 = create_session("server_name")
cl1.aedt(port=50000, non_graphical=False)
hfss = Hfss(machine="server_name", port=50000)
Expand All @@ -185,7 +185,7 @@ CPython 服务器:
## 变量 Variables

``` python
from pyaedt.HFSS import HFSS
from ansys.aedt.core.HFSS import HFSS
with HFSS as hfss:
hfss["dim"] = "1mm" # design variable
hfss["$dim"] = "1mm" # project variable
Expand All @@ -196,7 +196,7 @@ CPython 服务器:
``` python
# 创建BOX、分配变量和指定材料。

from pyaedt.hfss import Hfss
from ansys.aedt.core.hfss import Hfss
with Hfss as hfss:
hfss.modeler.create_box([0, 0, 0], [10, "dim", 10],
"mybox", "aluminum")
Expand Down
25 changes: 12 additions & 13 deletions _unittest/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@
Description
===========
This module contains the configuration and fixture for the pytest-based unit tests for pyaedt.
This module contains the configuration and fixture for the pytest-based unit tests for PyAEDT.
The default configuration can be changed by placing a file called local_config.json in the same
directory as this module. An example of the contents of local_config.json
Expand All @@ -51,10 +51,9 @@
import tempfile
import time

from ansys.aedt.core.generic.settings import settings
import pytest

from pyaedt.generic.settings import settings

settings.enable_local_log_file = False
settings.enable_global_log_file = False
settings.number_of_grpc_api_retries = 6
Expand All @@ -64,16 +63,16 @@
settings.desktop_launch_timeout = 180
settings.release_on_exception = False

from pyaedt import Edb
from pyaedt import Hfss
from pyaedt.aedt_logger import pyaedt_logger
from pyaedt.desktop import Desktop
from pyaedt.desktop import _delete_objects
from pyaedt.generic.desktop_sessions import _desktop_sessions
from pyaedt.generic.filesystem import Scratch
from pyaedt.generic.general_methods import generate_unique_name
from pyaedt.generic.general_methods import inside_desktop
from pyaedt.misc.misc import list_installed_ansysem
from ansys.aedt.core import Edb
from ansys.aedt.core import Hfss
from ansys.aedt.core.aedt_logger import pyaedt_logger
from ansys.aedt.core.desktop import Desktop
from ansys.aedt.core.desktop import _delete_objects
from ansys.aedt.core.generic.desktop_sessions import _desktop_sessions
from ansys.aedt.core.generic.filesystem import Scratch
from ansys.aedt.core.generic.general_methods import generate_unique_name
from ansys.aedt.core.generic.general_methods import inside_desktop
from ansys.aedt.core.misc.misc import list_installed_ansysem

local_path = os.path.dirname(os.path.realpath(__file__))
sys.path.append(local_path)
Expand Down
5 changes: 2 additions & 3 deletions _unittest/test_01_3dlayout_edb.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,11 +26,10 @@

from _unittest.conftest import config
from _unittest.conftest import local_path
from ansys.aedt.core import Hfss3dLayout
from ansys.aedt.core.generic.settings import is_linux
import pytest

from pyaedt import Hfss3dLayout
from pyaedt.generic.settings import is_linux

test_subfolder = "T40"
original_project_name = "ANSYS-HSD_V1"

Expand Down
Loading

0 comments on commit cbad1a0

Please sign in to comment.