Skip to content

feat: Add Python 3.14 compatibility - #288

Open
mitchnegus wants to merge 8 commits into
sandialabs:mainfrom
mitchnegus:support-py314
Open

feat: Add Python 3.14 compatibility#288
mitchnegus wants to merge 8 commits into
sandialabs:mainfrom
mitchnegus:support-py314

Conversation

@mitchnegus

@mitchnegus mitchnegus commented Jun 9, 2026

Copy link
Copy Markdown
Member

feat: Add Python 3.14 compatibility

(Pardon the AI language style in the MR, but generating it this way from the patch files is so much faster...)

Description

This MR updates FIREWHEEL to support Python 3.14. It primarily addresses multiprocessing compatibility (due to updates to picklability of objects). The changes address Python 3.14 pickling behavior by moving multiprocessing target functions out of local scope and into module-level functions so they can be safely serialized. In particular:

  • ExperimentGraph shortest-path worker logic was refactored to use a top-level helper function and stable graph node IDs instead of locally scoped closures.
  • minimegaAPI._check_version() was updated to use a top-level worker target and pickle-safe arguments for compatibility checks.
  • ExperimentGraph multiprocessing usage was updated to use an explicit multiprocessing context for queue and process creation.
  • Additional robustness was added around spawned process lifecycle management through a reusable context manager that ensures cleanup of processes and queues.
  • minimega API code was further improved with type annotations and some small cleanup/refactoring for readability and maintainability. (To pass linting checks.)
  • Docstrings were cleaned up for consistency.
  • Tests and project metadata were updated to indicate and validate support for Python 3.14.

Motivation and context

Python 3.14 changes multiprocessing/pickling behavior in a way that breaks some existing patterns used in FIREWHEEL, specifically locally defined functions used as multiprocessing targets. (See the commentary on forkserver restrictions in the 3.14 Changelog. It is in the section on concurrent futures, which may be a better way to handle this pattern eventually, at least in the minimega/api module.)

These changes caused compatibility issues in code paths that spawn child processes for graph traversal and minimega binding/version validation.

This MR resolves that problem by:

  • Replacing non-pickleable local worker functions with top-level helpers
  • Passing only pickleable data into child processes
  • Making process/queue management more robust

Other additions for Python 3.14 support include:

  • Updating tests to reflect current Python behavior around decorated special methods
  • Formally adding Python 3.14 to CI, packaging metadata, and documentation

Together, these changes allow FIREWHEEL to run and test cleanly under Python 3.14 while also improving maintainability of the affected code.

Type of Change

  • Other (please describe): Python 3.14 compatibility and internal refactoring

Checklist

  • This PR conforms to the process detailed in the Contributing Guide.
  • I have included no proprietary/sensitive information in my code.
  • A human has performed a self-review of my code.
  • I have commented my code, particularly in hard-to-understand areas.
  • I have made corresponding changes to the documentation.
  • I have made corresponding changes to the documentation.
  • My changes generate no new warnings.
  • I have tested my code with the functional test suite, and it passed.

Additional Notes

Notable implementation details:

  • The ExperimentGraph worker refactor precomputes filtered vertex IDs in the parent process and sends only graph IDs to workers.
  • The minimega compatibility check now uses a dedicated worker plus a safe process context manager to ensure proper termination and queue cleanup on timeout or error.
  • The decorator-related unit test was updated to reflect Python’s special-method lookup semantics, which are especially relevant when validating behavior under newer Python versions.
  • Project metadata and CI now explicitly include Python 3.14 support.

@github-actions github-actions Bot added documentation Improvements or additions to documentation fix Something isn't working labels Jun 9, 2026
@mitchnegus mitchnegus added feature New feature or request and removed fix Something isn't working documentation Improvements or additions to documentation labels Jun 9, 2026
@mitchnegus mitchnegus changed the title fix: Add Python 3.14 compatibility feat: Add Python 3.14 compatibility Jun 9, 2026
@github-actions github-actions Bot added the documentation Improvements or additions to documentation label Jun 9, 2026
@mitchnegus
mitchnegus force-pushed the support-py314 branch 2 times, most recently from 3efb6eb to 01a7877 Compare June 11, 2026 00:07
@mitchnegus
mitchnegus force-pushed the support-py314 branch 7 times, most recently from 1ceda89 to 4038fdf Compare June 29, 2026 23:59
@mitchnegus
mitchnegus requested review from gregjacobus and sdelliot and removed request for sdelliot June 30, 2026 01:14
Python 3.14 changes the default method for launching processes via
the multiprocessing module (including how pickling is handled). This
This means that locally defined functions passed to our
multiprocessing target functions are unable to be properly pickled.
This commit moves these targets to be top level functions and to use
use pickleable arguments (e.g., graph IDs). It forces the forkserver
method of launching processes (the new default and preferred method)
so that this behavior will be explicit and consistent across
Python versions.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

documentation Improvements or additions to documentation feature New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant