Skip to content

Commit

Permalink
Segregate generated files into Fluent-version-specific directories (#771
Browse files Browse the repository at this point in the history
)

* Segregate generated files into Fluent-version-specific directories
  • Loading branch information
mkundu1 authored Aug 28, 2022
1 parent cb58eed commit 775fa86
Show file tree
Hide file tree
Showing 14 changed files with 287 additions and 272 deletions.
182 changes: 58 additions & 124 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -157,11 +157,11 @@ jobs:
id: cache-api-code
with:
path: |
src/ansys/fluent/core/datamodel
src/ansys/fluent/core/fluent_version.py
src/ansys/fluent/core/meshing/tui.py
src/ansys/fluent/core/solver/settings
src/ansys/fluent/core/solver/tui.py
src/ansys/fluent/core/datamodel_222
src/ansys/fluent/core/fluent_version_222.py
src/ansys/fluent/core/meshing/tui_222.py
src/ansys/fluent/core/solver/settings_222
src/ansys/fluent/core/solver/tui_222.py
doc/source/api/core/meshing/tui
doc/source/api/core/meshing/datamodel
doc/source/api/core/solver/tui
Expand Down Expand Up @@ -230,14 +230,10 @@ jobs:
FOLDER: doc/_build/html
CLEAN: true

test:
build-test:
name: Unit Testing
needs: test-import
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
image-tag: [v22.2.0, v23.1.0]

steps:
- uses: actions/checkout@v3
Expand Down Expand Up @@ -267,165 +263,103 @@ jobs:
echo "PYFLUENT version is: $(python -c "from ansys.fluent.core import __version__; print(__version__)")"
id: version

- name: Cache API Code
- name: Cache 22.2 API Code
uses: actions/cache@v3
id: cache-api-code
id: cache-222-api-code
with:
path:
src/ansys/fluent/core/datamodel
src/ansys/fluent/core/fluent_version.py
src/ansys/fluent/core/meshing/tui.py
src/ansys/fluent/core/solver/settings
src/ansys/fluent/core/solver/tui.py
src/ansys/fluent/core/datamodel_222
src/ansys/fluent/core/fluent_version_222.py
src/ansys/fluent/core/meshing/tui_222.py
src/ansys/fluent/core/solver/settings_222
src/ansys/fluent/core/solver/tui_222.py
doc/source/api/core/meshing/tui
doc/source/api/core/meshing/datamodel
doc/source/api/core/solver/tui
doc/source/api/core/solver/datamodel
key: API-Code-v${{ env.API_CODE_CACHE }}-${{ steps.version.outputs.PYFLUENT_VERSION }}-${{ matrix.image-tag }}-${{ hashFiles('codegen/**') }}
restore-keys: API-Code-v${{ env.API_CODE_CACHE }}-${{ steps.version.outputs.PYFLUENT_VERSION }}-${{ matrix.image-tag }}
key: API-Code-v${{ env.API_CODE_CACHE }}-${{ steps.version.outputs.PYFLUENT_VERSION }}-v22.2.0-${{ hashFiles('codegen/**') }}
restore-keys: API-Code-v${{ env.API_CODE_CACHE }}-${{ steps.version.outputs.PYFLUENT_VERSION }}-v22.2.0

- name: Login to GitHub Container Registry
if: steps.cache-api-code.outputs.cache-hit != 'true'
uses: docker/login-action@v2
with:
registry: ghcr.io
username: ${{ secrets.GH_USERNAME }}
password: ${{ secrets.REPO_DOWNLOAD_PAT }}

- name: Pull Fluent docker image
if: steps.cache-api-code.outputs.cache-hit != 'true'
- name: Pull 22.2 Fluent docker image
if: steps.cache-222-api-code.outputs.cache-hit != 'true'
run: make docker-pull
env:
FLUENT_IMAGE_TAG: ${{ matrix.image-tag }}
FLUENT_IMAGE_TAG: v22.2.0

- name: Run API codegen
if: steps.cache-api-code.outputs.cache-hit != 'true'
- name: Run 22.2 API codegen
if: steps.cache-222-api-code.outputs.cache-hit != 'true'
run: make api-codegen
env:
ANSYSLMD_LICENSE_FILE: ${{ format('1055@{0}', secrets.LICENSE_SERVER) }}
PYFLUENT_START_INSTANCE: 0
PYFLUENT_LAUNCH_CONTAINER: 1
FLUENT_IMAGE_TAG: ${{ matrix.image-tag }}

- name: Install again after codegen
run: |
rm -rf dist
make install > /dev/null
- name: Unit Testing
run: make unittest
env:
ANSYSLMD_LICENSE_FILE: ${{ format('1055@{0}', secrets.LICENSE_SERVER) }}
PYFLUENT_START_INSTANCE: 0
FLUENT_IMAGE_TAG: ${{ matrix.image-tag }}

- name: Upload Coverage Results
if: matrix.image-tag == 'v22.2.0'
uses: actions/upload-artifact@v3
with:
name: HTML-Coverage-tag-${{ matrix.image-tag }}
path: cov_html
retention-days: 7

- name: Check package
if: github.event_name != 'push' || !startsWith(github.ref, 'refs/tags/v')
run: |
pip install twine
twine check dist/*
- name: Upload package
if: github.event_name != 'push' || !startsWith(github.ref, 'refs/tags/v')
uses: actions/upload-artifact@v3
with:
name: PyFluent-packages
path: |
dist/*.whl
dist/*.tar.gz
retention-days: 7

build:
name: Build for release
if: github.event_name == 'push' && startsWith(github.ref, 'refs/tags/v')
needs: test-import
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
image-tag: [v22.2.0]

steps:
- uses: actions/checkout@v3

- name: Setup Python
uses: actions/setup-python@v4
with:
python-version: 3.9
FLUENT_IMAGE_TAG: v22.2.0

- name: Cache pip
- name: Cache 23.1 API Code
uses: actions/cache@v3
with:
path: ~/.cache/pip
key: Python-${{ runner.os }}-${{ matrix.python-version }}-${{ hashFiles('setup.py') }}-${{ hashFiles('requirements/requirements_*.txt') }}
restore-keys: |
Python-${{ runner.os }}-${{ matrix.python-version }}
- name: Add version information
run: make version-info

- name: Install pyfluent
run: make install

- name: Retrieve PyFluent version
run: |
echo "::set-output name=PYFLUENT_VERSION::$(python -c "from ansys.fluent.core import __version__; print(__version__)")"
echo "PYFLUENT version is: $(python -c "from ansys.fluent.core import __version__; print(__version__)")"
id: version

- name: Cache API Code
uses: actions/cache@v3
id: cache-api-code
id: cache-231-api-code
with:
path:
src/ansys/fluent/core/datamodel
src/ansys/fluent/core/fluent_version.py
src/ansys/fluent/core/meshing/tui.py
src/ansys/fluent/core/solver/settings
src/ansys/fluent/core/solver/tui.py
src/ansys/fluent/core/datamodel_231
src/ansys/fluent/core/fluent_version_231.py
src/ansys/fluent/core/meshing/tui_231.py
src/ansys/fluent/core/solver/settings_231
src/ansys/fluent/core/solver/tui_231.py
doc/source/api/core/meshing/tui
doc/source/api/core/meshing/datamodel
doc/source/api/core/solver/tui
doc/source/api/core/solver/datamodel
key: API-Code-v${{ env.API_CODE_CACHE }}-${{ steps.version.outputs.PYFLUENT_VERSION }}-${{ matrix.image-tag }}-${{ hashFiles('codegen/**') }}
restore-keys: API-Code-v${{ env.API_CODE_CACHE }}-${{ steps.version.outputs.PYFLUENT_VERSION }}-${{ matrix.image-tag }}

- name: Login to GitHub Container Registry
if: steps.cache-api-code.outputs.cache-hit != 'true'
uses: docker/login-action@v2
with:
registry: ghcr.io
username: ${{ secrets.GH_USERNAME }}
password: ${{ secrets.REPO_DOWNLOAD_PAT }}
key: API-Code-v${{ env.API_CODE_CACHE }}-${{ steps.version.outputs.PYFLUENT_VERSION }}-v23.1.0-${{ hashFiles('codegen/**') }}
restore-keys: API-Code-v${{ env.API_CODE_CACHE }}-${{ steps.version.outputs.PYFLUENT_VERSION }}-v23.1.0

- name: Pull Fluent docker image
if: steps.cache-api-code.outputs.cache-hit != 'true'
- name: Pull 23.1 Fluent docker image
if: steps.cache-231-api-code.outputs.cache-hit != 'true'
run: make docker-pull
env:
FLUENT_IMAGE_TAG: ${{ matrix.image-tag }}
FLUENT_IMAGE_TAG: v23.1.0

- name: Run API codegen
if: steps.cache-api-code.outputs.cache-hit != 'true'
- name: Run 23.1 API codegen
if: steps.cache-231-api-code.outputs.cache-hit != 'true'
run: make api-codegen
env:
ANSYSLMD_LICENSE_FILE: ${{ format('1055@{0}', secrets.LICENSE_SERVER) }}
PYFLUENT_START_INSTANCE: 0
PYFLUENT_LAUNCH_CONTAINER: 1
FLUENT_IMAGE_TAG: ${{ matrix.image-tag }}
FLUENT_IMAGE_TAG: v23.1.0

- name: Install again after codegen
run: |
rm -rf dist
make install > /dev/null
- name: 22.2 Unit Testing
run: make unittest
env:
ANSYSLMD_LICENSE_FILE: ${{ format('1055@{0}', secrets.LICENSE_SERVER) }}
PYFLUENT_START_INSTANCE: 0
FLUENT_IMAGE_TAG: v22.2.0

- name: Upload Coverage Results
uses: actions/upload-artifact@v3
with:
name: HTML-Coverage-tag-222
path: cov_html
retention-days: 7

- name: 23.1 Unit Testing
run: make unittest
env:
ANSYSLMD_LICENSE_FILE: ${{ format('1055@{0}', secrets.LICENSE_SERVER) }}
PYFLUENT_START_INSTANCE: 0
FLUENT_IMAGE_TAG: v23.1.0

- name: Check package
run: |
pip install twine
Expand All @@ -443,7 +377,7 @@ jobs:
release:
name: Release
if: github.event_name == 'push' && startsWith(github.ref, 'refs/tags/v')
needs: [test, build]
needs: build-test
runs-on: ubuntu-latest
steps:
- name: Set up Python
Expand Down
15 changes: 10 additions & 5 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -135,8 +135,13 @@ dmypy.json
.vscode

# generated API files
src/ansys/fluent/core/fluent_version.py
src/ansys/fluent/core/meshing/tui.py
src/ansys/fluent/core/solver/tui.py
src/ansys/fluent/core/datamodel/
src/ansys/fluent/core/solver/settings/
src/ansys/fluent/core/fluent_version_222.py
src/ansys/fluent/core/meshing/tui_222.py
src/ansys/fluent/core/solver/tui_222.py
src/ansys/fluent/core/datamodel_222/
src/ansys/fluent/core/solver/settings_222/
src/ansys/fluent/core/fluent_version_231.py
src/ansys/fluent/core/meshing/tui_231.py
src/ansys/fluent/core/solver/tui_231.py
src/ansys/fluent/core/datamodel_222/
src/ansys/fluent/core/solver/settings_222/
13 changes: 6 additions & 7 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ repos:
hooks:
- id: black
args: [
--force-exclude, src/ansys/api/fluent/v0/|src/ansys/fluent/core/meshing/tui.py|src/ansys/fluent/core/solver/tui.py|src/ansys/fluent/core/solver/settings/|src/ansys/fluent/core/datamodel,
--force-exclude, src/ansys/fluent/core/meshing/tui|src/ansys/fluent/core/solver/tui|src/ansys/fluent/core/solver/settings/|src/ansys/fluent/core/datamodel,
src/ansys, codegen, doc, examples, tests
]

Expand All @@ -22,9 +22,8 @@ repos:
- id: isort
args: [
--profile, black,
--skip, src/ansys/fluent/core/meshing/tui.py,
--skip, src/ansys/fluent/core/solver/tui.py,
--skip-glob, src/ansys/api/fluent/v0/*,
--skip-glob, src/ansys/fluent/core/meshing/tui*,
--skip-glob, src/ansys/fluent/core/solver/tui*,
--skip-glob, src/ansys/fluent/core/datamodel/*,
--skip-glob, src/ansys/fluent/core/solver/settings/*,
--force-sort-within-sections,
Expand All @@ -43,7 +42,7 @@ repos:
'flake8-annotations==2.9.0'
]
args: [
--exclude, src/ansys/api/fluent/v0/* src/ansys/fluent/core/meshing/tui.py src/ansys/fluent/core/solver/tui.py src/ansys/fluent/core/datamodel/* src/ansys/fluent/core/solver/settings/*,
--exclude, src/ansys/fluent/core/meshing/tui* src/ansys/fluent/core/solver/tui* src/ansys/fluent/core/datamodel/* src/ansys/fluent/core/solver/settings/*,
--select, W191 W291 W293 W391 E115 E117 E122 E124 E125 E225 E231 E301 E303 F401 F403 N801 N802 N803 N804 N805 N806,
#--select, W191 W291 W293 W391 E115 E117 E122 E124 E125 E225 E231 E301 E303 F401 F403 N801 N802 N803 N804 N805 N806 ANN001 ANN201 ANN205 ANN206,
--count,
Expand All @@ -59,14 +58,14 @@ repos:
hooks:
- id: codespell
args: [
--skip, "src/ansys/api/fluent/v0/*,src/ansys/fluent/core/meshing/tui.py,src/ansys/fluent/core/solver/tui.py,src/ansys/fluent/core/datamodel/*,codegen/data/fluent_gui_help.xml,src/ansys/fluent/core/solver/settings/*",
--skip, "src/ansys/fluent/core/meshing/tui*,src/ansys/fluent/core/solver/tui*,src/ansys/fluent/core/datamodel/*,codegen/data/fluent_gui_help.xml,src/ansys/fluent/core/solver/settings/*",
]

- repo: https://github.com/myint/docformatter
rev: v1.3.1
hooks:
- id: docformatter
exclude: ^(tests\/|src\/ansys\/api\/fluent\/v0\/|src\/ansys\/fluent\/core\/meshing\/tui.py|src\/ansys\/fluent\/core\/solver\/tui.py|src\/ansys\/fluent\/core\/solver\/settings\/|src\/ansys\/fluent\/core\/datamodel\/)
exclude: ^(tests\/|src\/ansys\/fluent\/core\/meshing\/tui_222.py|src\/ansys\/fluent\/core\/solver\/tui_222.py|src\/ansys\/fluent\/core\/solver\/settings_222\/|src\/ansys\/fluent\/core\/datamodel_222\/|src\/ansys\/fluent\/core\/meshing\/tui_231.py|src\/ansys\/fluent\/core\/solver\/tui_231.py|src\/ansys\/fluent\/core\/solver\/settings_231\/|src\/ansys\/fluent\/core\/datamodel_231\/)
args: [-r, --in-place]

#- repo: https://github.com/pycqa/pydocstyle
Expand Down
26 changes: 19 additions & 7 deletions codegen/datamodelgen.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@

from ansys.api.fluent.v0 import datamodel_se_pb2 as DataModelProtoModule
from ansys.fluent.core.session import _BaseSession as Session
from ansys.fluent.core.utils.fluent_version import get_version_for_filepath

_THIS_DIR = Path(__file__).parent

Expand Down Expand Up @@ -81,24 +82,35 @@ def _build_command_docstring(name: str, info: Any, indent: str):


class DataModelStaticInfo:
def __init__(self, rules: str, mode: str):
def __init__(self, rules: str, mode: str, version: str):
self.rules = rules
self.mode = mode
self.static_info = None
datamodel_dir = (
_THIS_DIR / ".." / "src" / "ansys" / "fluent" / "core" / "datamodel"
_THIS_DIR
/ ".."
/ "src"
/ "ansys"
/ "fluent"
/ "core"
/ f"datamodel_{version}"
)
datamodel_dir.mkdir(exist_ok=True)
self.filepath = (datamodel_dir / f"{rules}.py").resolve()


class DataModelGenerator:
def __init__(self):
self.version = get_version_for_filepath()
self._static_info: Dict[str, DataModelStaticInfo] = {
"workflow": DataModelStaticInfo("workflow", "meshing"),
"meshing": DataModelStaticInfo("meshing", "meshing"),
"PartManagement": DataModelStaticInfo("PartManagement", "meshing"),
"PMFileManagement": DataModelStaticInfo("PMFileManagement", "meshing"),
"workflow": DataModelStaticInfo("workflow", "meshing", self.version),
"meshing": DataModelStaticInfo("meshing", "meshing", self.version),
"PartManagement": DataModelStaticInfo(
"PartManagement", "meshing", self.version
),
"PMFileManagement": DataModelStaticInfo(
"PMFileManagement", "meshing", self.version
),
}
self._delete_generated_files()
self._populate_static_info()
Expand Down Expand Up @@ -301,7 +313,7 @@ def write_static_info(self) -> None:
info.static_info,
doc_dir / name,
f"{info.mode}.datamodel.{name}",
f"ansys.fluent.core.datamodel.{name}",
f"ansys.fluent.core.datamodel_{self.version}.{name}",
"Root",
)

Expand Down
Loading

0 comments on commit 775fa86

Please sign in to comment.