Skip to content

Upgrade to Python 3.14#171

Merged
alongd merged 6 commits into
mainfrom
py314
Jun 6, 2026
Merged

Upgrade to Python 3.14#171
alongd merged 6 commits into
mainfrom
py314

Conversation

@alongd

@alongd alongd commented Jun 6, 2026

Copy link
Copy Markdown
Member

Bumps T3 to Python 3.14.

Changes

  • Runtime → 3.14: environment.yml + pyproject.toml (cython ≥3.1, rdkit ≥2026.03, ruff target-version = py314). Added the danagroup channel for openbabel and py-rdl, which have no py314
    builds on conda-forge.
  • cantera/numpy-2.x fix: the simulate adapters indexed thermo[species_names_list].X, which triggers numpy 2.x's stricter ndarray.resize check and breaks every cantera run on 3.14.
    Switched to indexing the full mole-fraction array (batch + both PFR adapters).
  • Type hints modernized to PEP 585/604 (List→list, Optional[X]→X | None, …); ruff check . passes.
  • CI: dropped the redundant PyRDL step (now in environment.yml) and pointed RMG-Py at main (xTB is merged upstream).
  • Docs: Python badge + prerequisites → 3.14+.

alongd and others added 4 commits June 6, 2026 14:20
Bump the runtime to Python 3.14, mirroring ARC:
- environment.yml: python =3.14, cython >=3.1, rdkit >=2026.03
- pyproject.toml: requires-python >=3.14, ruff target-version py314

Add the danagroup channel for openbabel and py-rdl, which have no py314
builds on conda-forge (the same builds ARC uses). cantera stays a loose
>=3.2.0 core dep (conda-forge has a py314 build).

CI: drop the now-redundant install_pyrdl.sh step (py-rdl is provided by
environment.yml) and check out RMG-Py main for rmg_env (the xTB feature
is merged upstream).

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
cantera's Solution.__getitem__ with a list of species names sets
selected_species, which calls ndarray.resize(); numpy 2.x rejects this
with "cannot resize an array that may be referenced by another object",
breaking every cantera simulation (batch + PFR) on the Python 3.14 stack.

Index the full mole-fraction array via species_index instead, which is
equivalent (species_names_list is the full model species set) and avoids
the resize path. Applied to the batch base adapter and both PFR adapters.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
List/Dict/Tuple -> list/dict/tuple, Optional[X] -> X | None,
Union[X, Y] -> X | Y, and drop the now-unused typing imports
(ruff UP006/UP007/UP035/UP045 + F401). ~500 annotation rewrites.
`ruff check .` passes under target-version py314.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Update the Python badge and the Prerequisites line from 3.12+ to 3.14+.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Pull request overview

Upgrades T3’s supported runtime to Python 3.14, modernizes type annotations to PEP 585/604, and includes a Cantera/Numpy 2.x compatibility fix in the simulation adapters, along with corresponding environment/CI/docs updates.

Changes:

  • Bump declared Python support to 3.14 (packaging + conda env + docs + ruff target version).
  • Update many type hints to built-in generics and X | None unions.
  • Fix Cantera adapter species mole-fraction collection to avoid Numpy 2.x resize() refcheck failures.

Reviewed changes

Copilot reviewed 25 out of 25 changed files in this pull request and generated 4 comments.

Show a summary per file
File Description
tests/test_utils/test_libraries.py Update typing annotations to built-in generics.
tests/test_logger.py Replace Optional[...] hints with `X
tests/common.py Modernize optional type hints.
t3/utils/rmg_shim.py Remove legacy typing imports; modernize hints across shim dataclasses/APIs.
t3/utils/rmg_sa_parser.py Modernize return/variable annotations to built-in generics.
t3/utils/libraries.py Modernize typing and dict/list annotations; lock/util signatures updated.
t3/utils/flux.py Update function signatures and typing to built-in generics/PEP 604.
t3/utils/fix_cantera.py Modernize typing for traceback/duplicate-reaction helpers.
t3/utils/cantera_parser.py Modernize typing for YAML parsing helpers.
t3/simulate/rmg_constant_tp.py Update adapter typing annotations (observables, SA return types).
t3/simulate/factory.py Update adapter registration/factory typing (type[...], `X
t3/simulate/cantera_pfr.py Change species mole-fraction indexing to avoid Cantera __getitem__ path.
t3/simulate/cantera_pfr_t_profile.py Same Cantera mole-fraction indexing adjustment as other adapters.
t3/simulate/cantera_base.py Apply the Cantera/Numpy 2.x-safe mole-fraction indexing in base simulate loop.
t3/schema.py Modernize Pydantic model field type annotations to PEP 604/built-in generics.
t3/runners/rmg_runner.py Modernize runner function annotations and return types.
t3/runners/rmg_incore_sa.py Update return typing to built-in generics.
t3/main.py Modernize optional and collection type hints.
t3/logger.py Update typed container annotations for log helpers.
t3/common.py Modernize typing; update helper signatures/return types.
t3/chem.py Modernize typing in core Species/Reaction wrappers.
README.md Update Python version badge and prerequisites to 3.14+.
pyproject.toml Set requires-python >=3.14 and ruff target-version = py314.
environment.yml Pin python to 3.14, bump deps, add danagroup channel and packages.
.github/workflows/ci.yml Point RMG-Py checkout to main and remove redundant PyRDL install step.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread t3/utils/libraries.py Outdated


def check_race_condition(race_path: str, logger: Optional["Logger"] = None) -> bool:
def check_race_condition(race_path: str, logger: "Logger" | None = None) -> bool:
Comment thread t3/utils/libraries.py
Comment on lines 194 to 197
def load_rmg_species_dictionary_file(
dict_path: str,
logger: Optional["Logger"] = None,
logger: "Logger" | None = None,
*,
Comment thread t3/common.py
Comment on lines 28 to 31
def get_species_by_label(label: str,
species_list: list['T3Species'],
) -> Optional['T3Species']:
) -> 'T3Species' | None:
"""
Comment thread t3/runners/rmg_runner.py
Comment on lines 456 to 460
def run_arkane_job(input_file: str,
output_directory: str,
plot: bool = False,
logger: Optional['Logger'] = None,
logger: 'Logger' | None = None,
) -> bool:
alongd and others added 2 commits June 6, 2026 14:31
The ruff UP045 sweep turned Optional["Logger"] into the partially-quoted
union "Logger" | None, which evaluates str.__or__(None) -> TypeError if
the annotation is ever introspected (get_type_hints / pydantic / inspect).
Python 3.14 defers annotation evaluation so import doesn't crash, but the
form is still invalid. Quote the entire union ("Logger | None",
'T3Species | None') so it resolves correctly for TYPE_CHECKING forward refs.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
RMG main now writes the chemkin-translated model to
RMG/cantera_from_ck/chem_annotated.yaml instead of RMG/cantera/.
Point set_paths at the new location and migrate the committed
test fixtures to match.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
@codecov-commenter

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 72.08%. Comparing base (4b53415) to head (9aa5fb0).

Additional details and impacted files
@@            Coverage Diff             @@
##             main     #171      +/-   ##
==========================================
- Coverage   72.37%   72.08%   -0.29%     
==========================================
  Files          35       35              
  Lines        4727     4678      -49     
  Branches      998      998              
==========================================
- Hits         3421     3372      -49     
  Misses        968      968              
  Partials      338      338              
Flag Coverage Δ
unittests 72.08% <ø> (-0.29%) ⬇️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@alongd alongd merged commit 25e1636 into main Jun 6, 2026
4 checks passed
@alongd alongd deleted the py314 branch June 6, 2026 21:34
alongd added a commit that referenced this pull request Jun 6, 2026
Rebased idt onto main (post py314 merge, PR #171). Integration fixes:

- rmg_runner.fix_cantera_model_files: read RMG cantera output from
  'cantera_from_ck/' instead of 'cantera/' (main moved it in 9aa5fb0)
- migrate IDT test fixtures iteration_{0..4}/RMG/cantera ->
  cantera_from_ck to match the new layout
- modernize idt type hints to PEP 585/604 (main removed the typing
  imports the idt code relied on, surfacing F821)

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants