Skip to content

Commit

Permalink
CI: add pyaedt integration examples (#89)
Browse files Browse the repository at this point in the history
* MISC: move example in pyaedt integration

* MISC: use non_graphical in pyaedt examples

Note: current CI does not work when non_graphical is set to
False as the runner isn't available to launch the AEDT Desktop
application.

* MISC: add forgotten import in example

* CI: fix nightly commit counter with pyaedt

* CI: removing examples from ci_cd

* CI: adding nightly workflow of examples

* CI: change workflow name

* CI: deactivate doc index jobs

* CI: fix job needs
  • Loading branch information
SMoraisAnsys authored Dec 23, 2023
1 parent c0d2944 commit 8242672
Show file tree
Hide file tree
Showing 9 changed files with 152 additions and 120 deletions.
150 changes: 43 additions & 107 deletions .github/workflows/ci_cd.yml
Original file line number Diff line number Diff line change
Expand Up @@ -121,71 +121,6 @@ jobs:
with:
files: .cov/xml

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

legacy-examples:
name: "Check legacy examples"
needs: [legacy-tests]
runs-on: [ windows, pyedb, self-hosted ]
env:
PYEDB_CI_NO_DISPLAY: '1'
steps:
- name: "Install Git and clone project"
uses: actions/checkout@v4

- name: "Set up Python"
uses: ansys/actions/_setup-python@main
with:
python-version: ${{ env.MAIN_PYTHON_VERSION_WINDOWS_SELFHOSTED }}
use-cache: false

- name: Create Python venv
run: |
python -m venv .venv
. .venv\Scripts\Activate.ps1
- name: "Update pip"
run: |
. .venv\Scripts\Activate.ps1
python -m pip install -U pip
- name: Install pyedb
run: |
. .venv\Scripts\Activate.ps1
pip install .[full]
- name: Execute legacy examples (except pyaedt related and 01)
run: |
. .venv\Scripts\Activate.ps1
$excluded_example = "01_edb_example.py"
# TODO: once pyaedt examples are passing, use -Recurse to cover them
Get-ChildItem -Path examples/legacy -Filter *.py -File | ? { $_.Name -ne $excluded_example } | ForEach-Object {
Write-Host "Executing example $($_.FullName)"
python $_.FullName
}
# - name: "Clone pyaedt on specific branch"
# uses: actions/checkout@v4
# with:
# repository: ansys/pyaedt
# path: "external/pyaedt"
# ref: "maint/use_pyedb"

# - name: "Install Pyaedt"
# run: |
# .\.venv\Scripts\Activate.ps1
# pip install --no-cache-dir external/pyaedt[full]

# - name: Execute legacy pyaedt integration examples
# run: |
# . .venv\Scripts\Activate.ps1
# Get-ChildItem -Path examples/legacy/pyaedt_integration -Filter *.py -File | ? { $_.Name -ne $excluded_example } | ForEach-Object {
# Write-Host "Executing pyaedt integration example $($_.FullName)"
# python $_.FullName
# }

docs-build:
name: Build documentation
runs-on: ubuntu-20.04
Expand Down Expand Up @@ -251,7 +186,7 @@ jobs:

package:
name: Package library
needs: [legacy-tests, legacy-examples, docs-build]
needs: [legacy-tests, docs-build]
runs-on: ubuntu-latest
steps:
- name: Build library source and wheel artifacts
Expand Down Expand Up @@ -283,20 +218,20 @@ jobs:
cname: ${{ env.DOCUMENTATION_CNAME }}
token: ${{ secrets.GITHUB_TOKEN }}

doc-index-dev:
name: "Deploy dev index docs"
if: github.ref == 'refs/heads/main'
runs-on: ubuntu-latest
needs: upload-dev-docs
steps:
- name: "Deploy the latest documentation index"
uses: ansys/actions/doc-deploy-index@v5
with:
cname: ${{ env.DOCUMENTATION_CNAME }}/version/dev
index-name: pyedb-vdev
host-url: ${{ env.MEILISEARCH_HOST_URL }}
api-key: ${{ env.MEILISEARCH_API_KEY }}
python-version: ${{ env.MAIN_PYTHON_VERSION }}
# doc-index-dev:
# name: "Deploy dev index docs"
# if: github.ref == 'refs/heads/main'
# runs-on: ubuntu-latest
# needs: upload-dev-docs
# steps:
# - name: "Deploy the latest documentation index"
# uses: ansys/actions/doc-deploy-index@v5
# with:
# cname: ${{ env.DOCUMENTATION_CNAME }}/version/dev
# index-name: pyedb-vdev
# host-url: ${{ env.MEILISEARCH_HOST_URL }}
# api-key: ${{ env.MEILISEARCH_API_KEY }}
# python-version: ${{ env.MAIN_PYTHON_VERSION }}

upload-docs-release:
name: Upload release documentation
Expand All @@ -310,31 +245,32 @@ jobs:
cname: ${{ env.DOCUMENTATION_CNAME }}
token: ${{ secrets.GITHUB_TOKEN }}

doc-index-stable:
name: "Deploy stable docs index"
runs-on: ubuntu-latest
needs: upload-docs-release
steps:
- name: "Install Git and clone project"
uses: actions/checkout@v4

- name: "Install the package requirements"
run: pip install -e .
# doc-index-stable:
# name: "Deploy stable docs index"
# runs-on: ubuntu-latest
# needs: upload-docs-release
# steps:
# - name: "Install Git and clone project"
# uses: actions/checkout@v4

# - name: "Install the package requirements"
# run: pip install -e .

# - name: "Get the version to PyMeilisearch"
# run: |
# VERSION=$(python -c "from pyedb import __version__; print('.'.join(__version__.split('.')[:2]))")
# VERSION_MEILI=$(python -c "from pyedb import __version__; print('-'.join(__version__.split('.')[:2]))")
# echo "Calculated VERSION: $VERSION"
# echo "Calculated VERSION_MEILI: $VERSION_MEILI"
# echo "VERSION=$VERSION" >> $GITHUB_ENV
# echo "VERSION_MEILI=$VERSION_MEILI" >> $GITHUB_ENV

# - name: "Deploy the latest documentation index"
# uses: ansys/actions/doc-deploy-index@v5
# with:
# cname: ${{ env.DOCUMENTATION_CNAME }}/version/${{ env.VERSION }}
# index-name: pyedb-v${{ env.VERSION_MEILI }}
# host-url: ${{ env.MEILISEARCH_HOST_URL }}
# api-key: ${{ env.MEILISEARCH_API_KEY }}
# python-version: ${{ env.MAIN_PYTHON_VERSION }}

- name: "Get the version to PyMeilisearch"
run: |
VERSION=$(python -c "from pyedb import __version__; print('.'.join(__version__.split('.')[:2]))")
VERSION_MEILI=$(python -c "from pyedb import __version__; print('-'.join(__version__.split('.')[:2]))")
echo "Calculated VERSION: $VERSION"
echo "Calculated VERSION_MEILI: $VERSION_MEILI"
echo "VERSION=$VERSION" >> $GITHUB_ENV
echo "VERSION_MEILI=$VERSION_MEILI" >> $GITHUB_ENV
- name: "Deploy the latest documentation index"
uses: ansys/actions/doc-deploy-index@v5
with:
cname: ${{ env.DOCUMENTATION_CNAME }}/version/${{ env.VERSION }}
index-name: pyedb-v${{ env.VERSION_MEILI }}
host-url: ${{ env.MEILISEARCH_HOST_URL }}
api-key: ${{ env.MEILISEARCH_API_KEY }}
python-version: ${{ env.MAIN_PYTHON_VERSION }}
78 changes: 78 additions & 0 deletions .github/workflows/nightly-examples.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,78 @@
name: Nightly legacy examples

on:
# Schedule this workflow every day at UTC 2:00.
schedule:
- cron: '0 2 * * *'

env:
ANSYSLMD_LICENSE_FILE: ${{ format('1055@{0}', secrets.LICENSE_SERVER) }}
PYEDB_USE_LEGACY: '1'
PYEDB_CI_NO_DISPLAY: '1'
MAIN_PYTHON_VERSION_WINDOWS_SELFHOSTED: '3.9'
VTK_OSMESA: 'vtk-osmesa==9.2.20230527.dev0'

concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true

# A workflow run is made up of one or more jobs that can run sequentially or in parallel
jobs:

legacy-examples:
name: "Check legacy examples"
runs-on: [ windows, pyedb, self-hosted ]
steps:
- name: "Install Git and clone project"
uses: actions/checkout@v4

- name: "Set up Python"
uses: ansys/actions/_setup-python@main
with:
python-version: ${{ env.MAIN_PYTHON_VERSION_WINDOWS_SELFHOSTED }}
use-cache: false

- name: Create Python venv
run: |
python -m venv .venv
. .venv\Scripts\Activate.ps1
- name: "Update pip"
run: |
. .venv\Scripts\Activate.ps1
python -m pip install -U pip
- name: Install pyedb
run: |
. .venv\Scripts\Activate.ps1
pip install .[full]
- name: "Clone pyaedt on specific branch"
uses: actions/checkout@v4
with:
repository: ansys/pyaedt
path: "external/pyaedt"
ref: "maint/use_pyedb"

- name: "Install Pyaedt"
run: |
.\.venv\Scripts\Activate.ps1
pip install --no-cache-dir external/pyaedt[full]
- name: "Install specific vtk version with OSMesa bundled"
run: |
.\.venv\Scripts\Activate.ps1
pip uninstall vtk -y
# Note: the vtk-osmesa used is 9.2.X as 9.3.0 is not working
# well with the use of pyvista in our tests atm.
# TODO: update once a stable versio is working
pip install --extra-index-url https://wheels.vtk.org ${{ env.VTK_OSMESA }}
- name: Execute legacy examples (except pyaedt related and 01)
run: |
. .venv\Scripts\Activate.ps1
Get-ChildItem -Recurse -Path examples/legacy -Filter *.py -File | ForEach-Object {
Write-Host "Executing example $($_.FullName)"
$time = Measure-Command {python $_.FullName}
Write-Host "Time taken for example $($_.FullName): $($time.TotalSeconds) seconds"
}
6 changes: 3 additions & 3 deletions .github/workflows/nightly-test-pyaedt.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
name: Test pyedb as pyaedt dependency
name: Nightly test of pyedb as pyaedt dependency

on:
# Schedule this workflow every day at UTC 3:00.
Expand Down Expand Up @@ -80,5 +80,5 @@ jobs:
run: |
cd external/pyaedt
git fetch --all
COMMIT_COUNT=$(git rev-list --count origin/main...origin/maint/use_pyedb)
echo "Number of commits between the main branch and the one using pyedb as dependency: $COMMIT_COUNT"
$counter = git rev-list --count origin/main...origin/maint/use_pyedb
Write-Host "Number of commits between the main branch and the one using pyedb as dependency: $($counter)""
File renamed without changes.
4 changes: 2 additions & 2 deletions examples/legacy/pyaedt_integration/03_5G_antenna_example.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,9 @@
##########################################################
# Set non-graphical mode
# ~~~~~~~~~~~~~~~~~~~~~~
# Set non-graphical mode. The default is ``False``.
# Set non-graphical mode. The default is ``True``.

non_graphical = False
non_graphical = True


class Patch:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,9 +21,9 @@
##########################################################
# Set non-graphical mode
# ~~~~~~~~~~~~~~~~~~~~~~
# Set non-graphical mode. The default is ``False``.
# Set non-graphical mode. The default is ``True``.

non_graphical = False
non_graphical = True

##########################################################
# Creating data classes
Expand Down Expand Up @@ -261,7 +261,13 @@ def points(self):
# ~~~~~~~~~~~~~~
# Launch HFSS 3D.

h3d = Hfss(specified_version="2023.2", new_desktop_session=True, close_on_exit=True, solution_type="Terminal")
h3d = Hfss(
specified_version="2023.2",
new_desktop_session=True,
close_on_exit=True,
solution_type="Terminal",
non_graphical=non_graphical,
)


###############################################################################
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,9 +23,9 @@
##########################################################
# Set non-graphical mode
# ~~~~~~~~~~~~~~~~~~~~~~
# Set non-graphical mode. The default is ``False``.
# Set non-graphical mode. The default is ``True``.

non_graphical = False
non_graphical = True

##########################################################
# Launch EDB
Expand Down
2 changes: 2 additions & 0 deletions examples/legacy/pyaedt_integration/09_Configuration.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@

import os

from pyaedt import Hfss3dLayout

import pyedb
from pyedb.generic.general_methods import generate_unique_folder_name
from pyedb.legacy.downloads import download_file
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,10 +36,20 @@
)
from pyedb.legacy.downloads import download_file

ansys_version = "2023.2"
##########################################################
# Set non-graphical mode
# ~~~~~~~~~~~~~~~~~~~~~~
# Set non-graphical mode. The default is ``True``.

non_graphical = True

###############################################################################
# Launch EDB
# ~~~~~~~~~~
# Launch the :class:`pyedb.Edb` class, using EDB 2023 R2.

aedb_path = os.path.join(generate_unique_folder_name(), generate_unique_name("pcb") + ".aedb")
edb = pyedb.Edb(edbpath=aedb_path, edbversion=ansys_version)
edb = pyedb.Edb(edbpath=aedb_path, edbversion="2023.2")
print("EDB is located at {}".format(aedb_path))

#####################
Expand Down Expand Up @@ -177,7 +187,7 @@
# Launch Hfss3dLayout
# ~~~~~~~~~~~~~~~~~~~

h3d = Hfss3dLayout(aedb_path, specified_version=ansys_version, new_desktop_session=True)
h3d = Hfss3dLayout(aedb_path, specified_version="2023.2", new_desktop_session=True, non_graphical=non_graphical)

####################
# Place 3D component
Expand Down

0 comments on commit 8242672

Please sign in to comment.