Skip to content
Merged
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
42 changes: 42 additions & 0 deletions .ci/start_fluent.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
import os
import subprocess
import sys
import tempfile
import time

from ansys.fluent.core import EXAMPLES_PATH


def start_fluent_container(args):
fd, sifile = tempfile.mkstemp(
suffix=".txt", prefix="serverinfo-", dir=EXAMPLES_PATH
)
os.close(fd)
timeout = 100
license_server = os.environ["ANSYSLMD_LICENSE_FILE"]
port = os.environ["PYFLUENT_FLUENT_PORT"]

subprocess.run(["docker", "run", "--name", "fluent_server", "-d", "--rm",
Copy link
Contributor Author

@mkundu1 mkundu1 Mar 29, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

These scripts are specific for CI runs. There is an assumption that the host OS is linux (-v assumes same unix path format for the container and host OS).

"-p", f"{port}:{port}",
"-v", f"{EXAMPLES_PATH}:{EXAMPLES_PATH}",
"-e", f"ANSYSLMD_LICENSE_FILE={license_server}",
"-e", f"REMOTING_PORTS={port}/portspan=2",
"-e", "FLUENT_LAUNCHED_FROM_PYFLUENT=1",
"ghcr.io/pyansys/pyfluent",
"-g", f"-sifile={sifile}"] + args)

sifile_last_mtime = os.stat(sifile).st_mtime
while True:
if os.stat(sifile).st_mtime > sifile_last_mtime:
time.sleep(1)
break
if timeout == 0:
break
time.sleep(1)
timeout -= 1
if os.path.exists(sifile):
os.remove(sifile)


if __name__ == "__main__":
start_fluent_container(sys.argv[1:])
9 changes: 9 additions & 0 deletions .ci/stop_fluent.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
import subprocess


def stop_fluent_container():
subprocess.run(["docker", "stop", "fluent_server"])


if __name__ == "__main__":
stop_fluent_container()
17 changes: 17 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,10 @@ on:
branches:
- main

concurrency:
group: ${{ github.ref }}
cancel-in-progress: true
Copy link
Contributor Author

@mkundu1 mkundu1 Mar 24, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.


jobs:
stylecheck:
name: Style Check
Expand Down Expand Up @@ -119,12 +123,25 @@ jobs:
- name: Install pyfluent with post module
run: make install-post

- name: Login to GitHub Container Registry
uses: docker/login-action@v1
with:
registry: ghcr.io
username: ${{ secrets.GH_USERNAME }}
password: ${{ secrets.REPO_DOWNLOAD_PAT }}

- name: Pull Fluent docker image
run: make docker-pull

- name: Build Documentation
run: |
pip install -r requirements_docs.txt
make -C doc html
touch doc/_build/html/.nojekyll
echo "fluentdocs.pyansys.com" >> doc/_build/html/CNAME
env:
ANSYSLMD_LICENSE_FILE: ${{ format('1055@{0}', secrets.LICENSE_SERVER) }}
PYFLUENT_FLUENT_PORT: 63084

- name: Upload HTML Documentation
uses: actions/upload-artifact@v2
Expand Down
13 changes: 13 additions & 0 deletions .github/workflows/nightly-doc-build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -33,12 +33,25 @@ jobs:
- name: Install pyfluent with post module
run: make install-post

- name: Login to GitHub Container Registry
uses: docker/login-action@v1
with:
registry: ghcr.io
username: ${{ secrets.GH_USERNAME }}
password: ${{ secrets.REPO_DOWNLOAD_PAT }}

- name: Pull Fluent docker image
run: make docker-pull

- name: Build Documentation
run: |
pip install -r requirements_docs.txt
make -C doc html
touch doc/_build/html/.nojekyll
echo "dev.fluentdocs.pyansys.com" >> doc/_build/html/CNAME
env:
ANSYSLMD_LICENSE_FILE: ${{ format('1055@{0}', secrets.LICENSE_SERVER) }}
PYFLUENT_FLUENT_PORT: 63084

- name: Deploy
uses: JamesIves/[email protected]
Expand Down
3 changes: 3 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,9 @@ install-pyvistaqt-requirements:
@sudo apt-get update
@sudo apt-get install libegl1 -y

docker-pull:
@docker pull ghcr.io/pyansys/pyfluent:latest

test-import:
@python -c "import ansys.fluent.core as pyfluent"

Expand Down
24 changes: 24 additions & 0 deletions doc/source/conf.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
"""Sphinx documentation configuration file."""
from datetime import datetime
import os
import subprocess
import sys

from pyansys_sphinx_theme import pyansys_logo_black
from sphinx_gallery.sorting import FileNameSortKey
Expand Down Expand Up @@ -93,6 +96,25 @@
copybutton_prompt_is_regexp = True


_THIS_DIR = os.path.dirname(__file__)
_START_FLUENT_FILE = os.path.normpath(
os.path.join(_THIS_DIR, "..", "..", ".ci", "start_fluent.py")
)
_STOP_FLUENT_FILE = os.path.normpath(
os.path.join(_THIS_DIR, "..", "..", ".ci", "stop_fluent.py")
)


def _start_or_stop_fluent_container(gallery_conf, fname, when):
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

runs before and after each example script

if when == "before":
if fname in ["mixing_elbow_settings_api.py",
"mixing_elbow_tui_api.py"]:
args = ["3ddp", "-t4", "-meshing"]
subprocess.run([sys.executable, _START_FLUENT_FILE] + args)
elif when == "after":
subprocess.run([sys.executable, _STOP_FLUENT_FILE])


# -- Sphinx Gallery Options ---------------------------------------------------
sphinx_gallery_conf = {
# convert rst to md for ipynb
Expand All @@ -113,6 +135,8 @@
"doc_module": "ansys-fluent-core",
"ignore_pattern": "flycheck*",
"thumbnail_size": (350, 350),
'reset_modules_order': 'both',
'reset_modules': (_start_or_stop_fluent_container),
}


Expand Down
Loading