Skip to content

ADD: pySpeos pyoptiSLang workflow example #77

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 8 commits into
base: main
Choose a base branch
from
Open
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
149 changes: 149 additions & 0 deletions .github/workflows/speos-optislang.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,149 @@
name: Speos Optislang Workflow

on:
workflow_dispatch:
inputs:
doc-build:
required: false
default: false
type: boolean
description: 'Whether to build the documentation'
workflow_call:
inputs:
doc-build:
required: false
default: false
type: boolean
description: 'Whether to build the documentation'
push:
branches:
- main
pull_request:
paths:
- 'speos-optislang/**'

env:
MAIN_PYTHON_VERSION: '3.12'
OPTISLANG_DOCKER_IMAGE: 'ghcr.io/ansys/optislang'
SPEOS_DOCKER_IMAGE: 'ghcr.io/ansys/speos-rpc'
ANSYSLMD_LICENSE_FILE: ${{ format('1055@{0}', secrets.LICENSE_SERVER )}}
ANSYS_RELEASE_FOR_DOCS: 25.2
RUN_DOC_BUILD: false

jobs:

speos-optislang:
name: Speos Optislang
runs-on: ubuntu-22.04
strategy:
fail-fast: false
matrix:
ansys-release: [25.2.0]
container:
image: ${{ format('ghcr.io/ansys/optislang:{0}-jammy', matrix.ansys-release) }}
credentials:
username: ansys-bot
password: ${{ secrets.GITHUB_TOKEN }}
steps:
- name: Checkout code
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
with:
sparse-checkout: |
speos-optislang
doc

- name: Set up Python ${{ env.MAIN_PYTHON_VERSION }}
uses: actions/setup-python@a26af69be951a213d495a4c3e4e4022e16d87065 # v5.6.0
with:
python-version: ${{ env.MAIN_PYTHON_VERSION }}

- name: Set up environment variables
shell: bash
run: |
VERSION="${{ matrix.ansys-release }}"
ANSYS_RELEASE_SHORT="${VERSION%.*}"
echo "ANSYS_RELEASE_SHORT=$ANSYS_RELEASE_SHORT" >> $GITHUB_ENV
ANSYS_RELEASE_COMPACT="${ANSYS_RELEASE_SHORT//./}"
echo "ANSYS_RELEASE_COMPACT=$ANSYS_RELEASE_COMPACT" >> $GITHUB_ENV

- name: Install dependencies
shell: bash
run: |
python -m pip install --upgrade pip
python -m venv .venv
. .venv/bin/activate
pip install -r speos-optislang/requirements_${{ env.ANSYS_RELEASE_SHORT }}.txt

- name: Login to GitHub Container Registry
uses: docker/login-action@74a5d142397b4f367a81961eba4e8cd7edddf772 # v3.4.0
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}

- name: Download and run Speos service image
shell: bash
run: |
$env:ANSYS_SPEOS_RELEASE = "${{ env.SPEOS_DOCKER_IMAGE }}:${{ env.ANSYS_RELEASE_COMPACT }}"
echo "Download Speos service image: $env:ANSYS_SPEOS_RELEASE"

# Pull the image
docker pull $env:ANSYS_SPEOS_RELEASE

# Run the container
docker run --detach --name speos-rpc -p 50098:50098 -e SPEOS_LOG_LEVEL=2 -e ANSYSLMD_LICENSE_FILE=${{ env.ANSYSLMD_LICENSE_FILE }} --entrypoint /app/SpeosRPC_Server.x ghcr.io/ansys/speos-rpc:${{ env.ANSYS_RELEASE_NO_DOT }} -m 25000000

- name: Run the workflow script
shell: bash
run: |
. .venv/bin/activate
python speos-optislang/wf_so_01_light_guide_robustness_study.py

# - name: Store the outputs
# uses: actions/upload-artifact@v4
# with:
# name: ...
# path: ...

- name: (DOCS) Check if docs should be built
if: (github.event_name == 'workflow_dispatch' || github.event_name == 'schedule') && inputs.doc-build
shell: bash
run: |
echo "Requested to build docs..."
if [ "${{ matrix.ansys-release }}" = "$ANSYS_RELEASE_FOR_DOCS" ]; then
echo "Building docs"
echo "RUN_DOC_BUILD=true" >> $GITHUB_ENV
else
echo "Not building docs - since not primary release"
echo "RUN_DOC_BUILD=false" >> $GITHUB_ENV
fi

- name: (DOCS) Build the documentation (only on ${{ env.ANSYS_RELEASE_FOR_DOCS}})
if: ${{ env.RUN_DOC_BUILD == 'true' }}
env:
BUILD_DOCS_SCRIPT: 'geometry-mesh/wf_gm_01_geometry.py'
shell: bash
run: |
. .venv/bin/activate
cd doc
pip install -r requirements.txt
./make.bat html

- name: (DOCS) Upload docs artifacts
if: ${{ env.RUN_DOC_BUILD == 'true' }}
uses: actions/upload-artifact@v4
with:
name: geometry-mesh-docs-stage-geometry
path: |
doc/_build/
doc/source/examples/speos-optislang/

- name: Stop any remaining containers
if: always()
shell: bash
run: |
dockerContainers=$(docker ps -a -q)
if [ -n "$dockerContainers" ]; then
docker stop $dockerContainers
docker rm $dockerContainers
fi
2 changes: 2 additions & 0 deletions doc/source/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -138,12 +138,14 @@ def examples_gallery_dirs_and_filename_pattern():
"../../geometry-mechanical-dpf",
"../../geometry-mesh",
"../../geometry-mesh-fluent",
"../../speos-optislang",
]
gallery_dirs = [
"examples/fluent-mechanical",
"examples/geometry-mechanical-dpf",
"examples/geometry-mesh",
"examples/geometry-mesh-fluent",
"examples/speos-optislang",
]

return examples_dirs, gallery_dirs, filename_pattern
Expand Down
Loading
Loading