-
Notifications
You must be signed in to change notification settings - Fork 56
Connect with docker session in examples #222
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
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| 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", | ||
| "-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:]) | ||
| 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() |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -10,6 +10,10 @@ on: | |
| branches: | ||
| - main | ||
|
|
||
| concurrency: | ||
| group: ${{ github.ref }} | ||
| cancel-in-progress: true | ||
|
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This will automatically cancel any in-progress run when pushed (https://docs.github.com/en/actions/using-workflows/workflow-syntax-for-github-actions#example-using-concurrency-to-cancel-any-in-progress-job-or-run) |
||
|
|
||
| jobs: | ||
| stylecheck: | ||
| name: Style Check | ||
|
|
@@ -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 | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -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] | ||
|
|
||
| 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 | ||
|
|
@@ -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): | ||
|
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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 | ||
|
|
@@ -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), | ||
| } | ||
|
|
||
|
|
||
|
|
||
Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
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 (
-vassumes same unix path format for the container and host OS).