Skip to content
Open
Show file tree
Hide file tree
Changes from 67 commits
Commits
Show all changes
72 commits
Select commit Hold shift + click to select a range
4f2c990
Add type level support for passing Path instances to download_file
Gobot1234 Sep 19, 2025
1ddf8e8
Add typing_extensions
Gobot1234 Sep 23, 2025
7825ff4
Fix inheritance for Meshing
Gobot1234 Sep 23, 2025
90d69a0
Fix create_launcher allowing None
Gobot1234 Sep 23, 2025
654deb4
Update launchers typing to be more specific
Gobot1234 Sep 23, 2025
ec258c3
Fix ci
Gobot1234 Sep 24, 2025
00c3a85
Fix ci again
Gobot1234 Sep 24, 2025
b6d2e3e
remove accidental commits
Gobot1234 Nov 5, 2025
0a48f90
run pyupgrade for moving typing to builtins and a couple of other things
Gobot1234 Nov 14, 2025
7b36a1c
fix some np.arrays that are meant to be ndarrays in types
Gobot1234 Dec 18, 2025
c04b413
pre-fix the conflict that will happen
Gobot1234 Jan 5, 2026
08e5525
add types for services
Gobot1234 Jan 12, 2026
7c2e9c3
Merge branch 'jhilton/typing-improvements' of https://github.com/ansy…
Gobot1234 Jan 12, 2026
0acf4ea
fix some low hanging fruit
Gobot1234 Jan 15, 2026
e6a7bf9
Merge remote-tracking branch 'origin/main' into jhilton/typing-improv…
Gobot1234 Jan 15, 2026
2ea0029
fix broken imports
Gobot1234 Jan 15, 2026
f28ce78
chore: adding changelog file 4761.added.md [dependabot-skip]
pyansys-ci-bot Jan 15, 2026
316128d
make the other imported modules not show up in __all__
Gobot1234 Jan 15, 2026
79956f3
pass bool
Gobot1234 Jan 19, 2026
4984170
respond to some review
Gobot1234 Jan 19, 2026
e130f13
add project infra for typechecking
Gobot1234 Jan 19, 2026
ee72ce6
test
Gobot1234 Jan 30, 2026
6e30e69
Merge branch 'main' into jhilton/typing-improvements
Gobot1234 Jan 30, 2026
0c7fb4b
Merge branch 'jhilton/typing-improvements' of https://github.com/ansy…
Gobot1234 Jan 30, 2026
f67ef50
gitattributes: enforce UTF-8 (no BOM) for patch and diff files
Gobot1234 Jan 30, 2026
e0ce93b
Add: public API regression test and fix type annotation issues
mayankansys Feb 3, 2026
912a036
Merge branch 'main' into jhilton/typing-improvements
Gobot1234 Feb 3, 2026
dc85158
Update ci.yml
Gobot1234 Feb 3, 2026
9a58a1e
Revert ci stuff
Gobot1234 Feb 3, 2026
e5309b7
Merge branch 'jhilton/typing-improvements' of https://github.com/ansy…
Gobot1234 Feb 3, 2026
3d37b81
no idea if this fixes ci
Gobot1234 Feb 3, 2026
6c5e692
Apply suggestions from code review
Gobot1234 Feb 3, 2026
b8a4a85
Update src/ansys/fluent/core/launcher/watchdog.py
Gobot1234 Feb 4, 2026
b38db19
fix ci up slightly
Gobot1234 Feb 4, 2026
5395956
fix launching and make it more type safe
Gobot1234 Feb 10, 2026
eae0f5b
misc changes
Gobot1234 Feb 10, 2026
7338cf9
Fix ci issues
Gobot1234 Feb 10, 2026
5bdade1
fix more stuff?
Gobot1234 Feb 10, 2026
ab34346
more typing fixes ci is still confusing me
Gobot1234 Feb 10, 2026
c4f0732
far too conservative
Gobot1234 Feb 10, 2026
a82d391
fix object installer types
Gobot1234 Feb 11, 2026
535c6b7
fix ci and mode related bug
Gobot1234 Feb 12, 2026
f6feab8
more ci work (api codegen check types)
Gobot1234 Feb 12, 2026
77e9854
fix ci
Gobot1234 Feb 12, 2026
f9b639a
fix not passing down all params in from_connection
Gobot1234 Feb 12, 2026
d1c6f53
run pyright
Gobot1234 Feb 12, 2026
dc6ec0b
Merge branch 'main' into jhilton/typing-improvements
Gobot1234 Feb 12, 2026
feac0d2
Update src/ansys/fluent/core/launcher/standalone_launcher.py
Gobot1234 Feb 12, 2026
e8cb20f
downgrade to 261 type checking for now
Gobot1234 Feb 12, 2026
57bd15c
Try logging in first
Gobot1234 Feb 13, 2026
58aefc4
cache for code style changes
Gobot1234 Feb 13, 2026
1809f84
fix some implicit optional parameters & other bits and bobs
Gobot1234 Feb 13, 2026
e050944
fix invocation of python
Gobot1234 Feb 13, 2026
dedba6c
gen certs
Gobot1234 Feb 16, 2026
13c8692
Merge branch 'main' into jhilton/typing-improvements
Gobot1234 Feb 16, 2026
3decd50
bump pytest in ci_types
Gobot1234 Feb 16, 2026
96e56a8
typing ci fixes
Gobot1234 Feb 16, 2026
1bb1408
add more deps?
Gobot1234 Feb 17, 2026
1f07cca
idk what else is missing here
Gobot1234 Feb 17, 2026
120f42d
Fix certificate generation script for Windows
Gobot1234 Feb 17, 2026
61b6806
chore: adding changelog file 4761.added.md [dependabot-skip]
pyansys-ci-bot Feb 17, 2026
4c1cb41
hopefully fix all the other issues
Gobot1234 Feb 17, 2026
3ac6141
Merge branch 'jhilton/typing-improvements' of https://github.com/ansy…
Gobot1234 Feb 17, 2026
d5596c6
Merge branch 'main' into jhilton/typing-improvements
Gobot1234 Feb 17, 2026
ba011d9
fix ci
Gobot1234 Feb 17, 2026
6e8cd22
okay for real this time
Gobot1234 Feb 17, 2026
b0aa392
I hope this fixes it
Gobot1234 Feb 17, 2026
83c443d
more errors
Gobot1234 Feb 17, 2026
bc787f1
fix the typing only symbol
Gobot1234 Feb 17, 2026
2de9fc2
Update slightly silly test
Gobot1234 Feb 18, 2026
c8e8999
Update examples/00-fluent/DOE_ML.py
Gobot1234 Feb 18, 2026
9517350
Update examples/00-fluent/DOE_ML.py
Gobot1234 Feb 18, 2026
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
128,230 changes: 128,230 additions & 0 deletions .ci/basedpyright.json

Large diffs are not rendered by default.

7 changes: 7 additions & 0 deletions .github/dependabot.yml
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,13 @@ updates:
- dependency-name: "pyansys-tools-report"
- dependency-name: "pyyaml"
- dependency-name: "h5py"
- dependency-name: "tensorflow"
- dependency-name: "matplotlib"
- dependency-name: "plotly"
- dependency-name: "scikit-learn"
- dependency-name: "seaborn"
- dependency-name: "xgboost"
- dependency-name: "imageio"
groups:
dependencies:
patterns:
Expand Down
43 changes: 43 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -85,9 +85,52 @@ jobs:
code-style:
name: Code style
runs-on: ubuntu-latest
env:
FLUENT_IMAGE_TAG: v26.1.latest

steps:
- name: "Run PyAnsys code style checks"
uses: ansys/actions/code-style@v10.2
with:
python-version: ${{ env.MAIN_PYTHON_VERSION }}
skip-install: false

- name: "Make venv"
run: uv venv --clear

- name: "Install extras"
run: uv pip install -e ".[ci_types]"

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

- name: Login to GitHub Container Registry
uses: docker/login-action@5e57cd118135c172c3672efd75eb46360885c0ef # v3.6.0
with:
registry: ghcr.io
username: ansys-bot
password: ${{ secrets.GITHUB_TOKEN }}

- name: Cache API Code
uses: actions/cache@9255dc7a253b0ccc959486e2bca901246202afeb # v5.0.1
id: cache-api-code
with:
path: |
src/ansys/fluent/core/generated
key: API-Code-v${{ env.API_CODE_CACHE }}-${{ steps.version.outputs.PYFLUENT_VERSION }}-${{ env.FLUENT_IMAGE_TAG }}-${{ hashFiles('src/ansys/fluent/core/codegen/**') }}
lookup-only: false # zizmor: ignore[cache-poisoning]

- name: "Generate the certificates"
run: bash .ci/generate_certs.sh

- name: "Regenerate API codegen"
run: uv run codegen/allapigen.py

- name: "Check type hints"
run: uv run basedpyright --baselinemode=auto

commit-style:
name: "Run commit style checks"
Expand Down
2 changes: 1 addition & 1 deletion .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ repos:
--statistics,
--max-complexity, "10",
--max-line-length, "88",
--extend-ignore, E203 E501 C901 B007 B009 B010 B011 B028,
--extend-ignore, E203 E501 C901 B007 B009 B010 B011 B028 F403 F405 F401 E402,
src, doc, examples, tests
]

Expand Down
Empty file added README.md
Empty file.
7 changes: 3 additions & 4 deletions devel/undocumented_fields/search_undocumented_fields.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@

import os
import sys
from typing import Dict, Set

import ast_comments as ast

Expand Down Expand Up @@ -121,7 +120,7 @@ def visit_FunctionDef(self, node):
self.classes[self.current_class].add(child.target.attr)


def analyze_file(file_path: str) -> Dict[str, Set[str]]:
def analyze_file(file_path: str) -> dict[str, set[str]]:
"""Analyze a Python file and return classes with their public fields."""
with open(file_path, "r", encoding="utf-8") as file:
try:
Expand All @@ -134,7 +133,7 @@ def analyze_file(file_path: str) -> Dict[str, Set[str]]:
return {}


def analyze_package(package_path: str) -> Dict[str, Dict[str, Set[str]]]:
def analyze_package(package_path: str) -> dict[str, dict[str, set[str]]]:
"""Analyze all Python files in a package directory."""
result = {}

Expand All @@ -160,7 +159,7 @@ def analyze_package(package_path: str) -> Dict[str, Dict[str, Set[str]]]:
return result


def write_results(results: Dict[str, Dict[str, Set[str]]], f) -> str:
def write_results(results: dict[str, dict[str, set[str]]], f) -> None:
"""Format the analysis results."""
for module_name, classes in sorted(results.items()):

Expand Down
1 change: 1 addition & 0 deletions doc/changelog.d/4761.added.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Initial bulk of type checking + setup
2 changes: 1 addition & 1 deletion doc/modify_html.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ def modify_html(soup: BeautifulSoup) -> None:
/ "settings"
)
for html_file in html_dir.glob("*.html"):
with open(html_file, "r", encoding="utf-8") as f:
with open(html_file, encoding="utf-8") as f:
soup = BeautifulSoup(f, "html.parser", from_encoding="utf-8")

modify_html(soup)
Expand Down
63 changes: 38 additions & 25 deletions examples/00-fluent/DOE_ML.py
Original file line number Diff line number Diff line change
Expand Up @@ -63,10 +63,11 @@
# flake8: noqa: E402

import os
from pathlib import Path
from typing import TypeAlias, cast

import matplotlib.pyplot as plt
import numpy as np
import numpy.typing as npt
import pandas as pd
import plotly.express as px
import plotly.graph_objects as go
Expand Down Expand Up @@ -234,8 +235,10 @@

train_set, test_set = train_test_split(df, test_size=0.2, random_state=42)

X_train = x_ct.fit_transform(train_set)
X_test = x_ct.fit_transform(test_set)
# cast is a function that improves intellisense by saying we know the data returned by
# fit_transform is an ndarray
X_train = cast(npt.NDArray[np.float64], x_ct.fit_transform(train_set))
X_test = cast(npt.NDArray[np.float64], x_ct.fit_transform(test_set))

y_train = train_set["Result"]
y_test = test_set["Result"]
Expand Down Expand Up @@ -264,8 +267,8 @@
def display_scores(scores):
"""Display scores."""
print("\nCross-Validation Scores:", scores)
print("Mean:%0.2f" % (scores.mean()))
print("Std. Dev.:%0.2f" % (scores.std()))
print(f"Mean:{scores.mean():0.2f}")
print(f"Std. Dev.:{scores.std():0.2f}")


def fit_and_predict(model):
Expand All @@ -282,8 +285,8 @@ def fit_and_predict(model):
test_predictions = model.predict(X_test)
print(train_predictions.shape[0])
print("\n\nCoefficient Of Determination")
print("Train Data R2 Score: %0.3f" % (r2_score(train_predictions, y_train)))
print("Test Data R2 Score: %0.3f" % (r2_score(test_predictions, y_test)))
print(f"Train Data R2 Score: {r2_score(train_predictions, y_train):0.3f}")
print(f"Test Data R2 Score: {r2_score(test_predictions, y_test):0.3f}")
print(
"\n\nPredictions - Ground Truth (Kelvin): ", (test_predictions - y_test), "\n"
)
Expand Down Expand Up @@ -399,21 +402,31 @@ def fit_and_predict(model):
np.random.seed(42)
tf.random.set_seed(42)

model = keras.models.Sequential(
[
keras.layers.Dense(
20,
activation="relu",
input_shape=X_train.shape[1:],
kernel_initializer="lecun_normal",
),
keras.layers.BatchNormalization(),
keras.layers.Dense(20, activation="relu", kernel_initializer="lecun_normal"),
keras.layers.BatchNormalization(),
keras.layers.Dense(20, activation="relu", kernel_initializer="lecun_normal"),
keras.layers.BatchNormalization(),
keras.layers.Dense(1),
]
ModelType: TypeAlias = keras.models.Model[
npt.NDArray[np.float64], npt.NDArray[np.float64]
]
model = cast(
ModelType,
keras.models.Sequential(
[
keras.layers.Dense(
20,
activation="relu",
input_shape=X_train.shape[1:],
kernel_initializer="lecun_normal",
),
keras.layers.BatchNormalization(),
keras.layers.Dense(
20, activation="relu", kernel_initializer="lecun_normal"
),
keras.layers.BatchNormalization(),
keras.layers.Dense(
20, activation="relu", kernel_initializer="lecun_normal"
),
keras.layers.BatchNormalization(),
keras.layers.Dense(1),
]
),
)

optimizer = tf.keras.optimizers.Adam(learning_rate=0.1, beta_1=0.9, beta_2=0.999)
Expand All @@ -437,7 +450,7 @@ def fit_and_predict(model):
validation_split=0.2,
callbacks=[checkpoint_cb, early_stopping_cb],
)
model = keras.models.load_model("my_keras_model.h5")
model = cast(ModelType, keras.models.load_model("my_keras_model.h5"))

print(history.params)

Expand All @@ -451,8 +464,8 @@ def fit_and_predict(model):
test_predictions = np.ravel(test_predictions.T)
print(test_predictions.shape)

print("\n\nTrain R2: %0.3f" % (r2_score(train_predictions, y_train)))
print("Test R2: %0.3f" % (r2_score(test_predictions, y_test)))
print(f"\n\nTrain R2: {r2_score(train_predictions, y_train):0.3f}")
print(f"Test R2: {r2_score(test_predictions, y_test):0.3f}")
print("Predictions - Ground Truth (Kelvin): ", (test_predictions - y_test))

fig = plt.figure(figsize=(12, 5))
Expand Down
29 changes: 29 additions & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,9 @@ dependencies = [
"nltk>=3.9.1",
"numpy>=1.14.0,<3.0.0",
"pandas>=1.1.0,<3.0.0",
"pandas-stubs>=1.1.0,<3.0.0",
"pyyaml>=6.0",
"typing-extensions>=4.12"
]
dynamic = ["version"]

Expand Down Expand Up @@ -76,6 +78,23 @@ docs = [
"pdf2image==1.17.0",
"seaborn>=0.13.2",
]
ci_types = [
"basedpyright==1.38.0",
"ansys-fluent-visualization",
"h5py",
"pytest",
"pytest-cov",
"pytest-mock",
"pytest-xdist",
"pyfakefs",
"tensorflow",
"matplotlib",
"plotly",
"scikit-learn",
"seaborn",
"xgboost",
"imageio",
]

[tool.flit.module]
name = "ansys.fluent.core"
Expand Down Expand Up @@ -233,3 +252,13 @@ skips = [
"B604",
"B607",
]

[tool.basedpyright]
reportAny = false
reportUnknownMemberType = false
reportExplicitAny = false
reportPrivateUsage = false
reportUnusedCallResult = false
reportUnannotatedClassAttribute = false
ignore = ["doc", "src/ansys/fluent/core/generated"]
baselineFile = ".ci/basedpyright.json"
Loading
Loading