Skip to content

Initial Numba support#626

Open
wlav wants to merge 31 commits into
Framework-R-D:mainfrom
wlav:numba-support
Open

Initial Numba support#626
wlav wants to merge 31 commits into
Framework-R-D:mainfrom
wlav:numba-support

Conversation

@wlav

@wlav wlav commented Jun 2, 2026

Copy link
Copy Markdown
Contributor

This PR adds "native" Numba support to phlex.

Numba was usable out-of-the-box already, through Python, but even if the Numba function itself didn't use the GIL, it still needed it at the start of every call (through the wrapper) and all Python/C++ converters required them, too. The implementation in this PR allows for calling the Numba JITed C-function directly, using converters that do not involve Python, and a dispatch through libffi. That sets up a workflow that doesn't require the GIL anywhere beyond configuration/registration time, thus enabling strong scaling (as far as Phlex is concerned) during graph execution.

This PR is for transforms only (observers and providers to follow) and only supports builtin types. Arrays and PODs (by member copy) should be doable as well, but Numba does not support arbitrary C++ classes.

The code in the module wrapper was significantly refactored, to maximize code reuse.

Note: it requires libffi, which will be available on most Linux boxes, but probably needs to be installed with spack in other places, so the spack recipe would need updating as well.

Build System

  • Updated Python plugin CMake configuration to add libffi dependency via PkgConfig discovery and validation
  • Added src/dyncall.cpp to pymodule library sources
  • Linked pymodule with PkgConfig::FFI alongside existing dependencies (Phlex, Python, NumPy)

Type System & Type Mappings

  • Extended Python-to-C++ type mapping (_PY2CPP) with Numba-specific scalar types (boolean, integer, float, void)
  • Added explicit platform-type mappings: "float32""float" and "float64""double" to handle Numba's distinction between Float and float32 types
  • Conditional imports from numba.core.types with fallback when Numba unavailable

Core Feature Implementation (Numba JIT Support)

  • New libffi-based dynamic calling interface:

    • Introduced phlex::experimental::dcarg struct: type-erased argument container backed by std::variant of supported primitive/FFI types
    • Added dcarg::from_str() string-to-typed factory for runtime type conversion
    • Implemented phlex::experimental::dyncall() function that dispatches C functions via libffi ffi_call, supporting both fixed and variadic signatures
  • Refactored module wrapper code (modulewrap.cpp):

    • Replaced template-based py_callback/callv approach with new py_callback_base, py_callback_impl, and jit_callback_impl implementations
    • Introduced MAX_SUPPORTED_ARGS limit (3 arguments)
    • Added is_numba_cfunc helper to detect Numba CFunc types via attribute lookup
    • Enhanced annotation parsing to extract signature info from Numba callables when __annotations__ unavailable
    • Updated selector validation flow: replaced "query" validation with new validate_selector helper
    • Converter generation macros (BASIC_CONVERTER, VECTOR_CONVERTER, NUMPY_ARRAY_CONVERTER) refactored to operate on dcarg values with explicit Python list handling for numpy conversion
  • Graph wiring changes:

    • insert_converter now passes hardcoded concurrency level (16) to transform
    • parse_args extended to accept optional concurrency parameter and produce input_selectors (instead of input_queries)
    • md_transform and md_observe rewritten to use unroll_switch helper for callback registration with 1-3 inputs
    • Support for both Python callbacks and JIT callbacks when Numba C functions detected
    • sc_provide output validation switched to validate_selector

Testing

  • Added conditional Numba test suite (py:jited) in CMake configuration, active when numba is available
  • Created test/python/jited.py: Test registration module defining supported numeric type pairs and registering Numba cfunc algorithms as transformation nodes with corresponding observer nodes
  • Added test/python/pyjited.jsonnet: Configuration file for Numba test driver with layer generation, event layer, and Python module enabling

CI & Security

  • Resolved 7 CodeQL alerts: Pinned unpinned third-party Actions in GitHub Actions workflow files:
    • .github/actions/prepare-check-outputs/action.yaml: get-pr-info and detect-act-env
    • .github/actions/prepare-fix-outputs/action.yaml: get-pr-info
    • .github/actions/run-change-detection/action.yaml: detect-relevant-changes
    • .github/actions/workflow-setup/action.yaml: prepare-check-outputs, prepare-fix-outputs, and run-change-detection

API Alignment

  • Framework API change: Renamed "query" concept to "selector" throughout validation and graph wiring logic

@greenc-FNAL

greenc-FNAL commented Jun 2, 2026

Copy link
Copy Markdown
Contributor

31 fixed, 0 new since branch point (cb81c8b)
31 fixed, 0 new since previous report on PR (af07260)

✅ 31 CodeQL alerts resolved since the previous PR commit

  • Warning # 196 actions/untrusted-checkout-toctou/critical at .github/workflows/clang-tidy-fix.yaml:109:9 — Insufficient protection against execution of untrusted code on a privileged workflow (issue_comment).
  • Warning # 197 actions/untrusted-checkout-toctou/critical at .github/workflows/clang-tidy-fix.yaml:137:9 — Insufficient protection against execution of untrusted code on a privileged workflow (issue_comment).
  • Warning # 198 actions/untrusted-checkout-toctou/critical at .github/workflows/clang-tidy-fix.yaml:157:9 — Insufficient protection against execution of untrusted code on a privileged workflow (issue_comment).
  • Warning # 199 actions/untrusted-checkout-toctou/critical at .github/workflows/clang-tidy-fix.yaml:201:9 — Insufficient protection against execution of untrusted code on a privileged workflow (issue_comment).
  • Warning # 200 actions/untrusted-checkout-toctou/critical at .github/workflows/coverage.yaml:166:9 — Insufficient protection against execution of untrusted code on a privileged workflow (issue_comment).
  • Warning # 201 actions/untrusted-checkout-toctou/critical at .github/workflows/coverage.yaml:188:9 — Insufficient protection against execution of untrusted code on a privileged workflow (issue_comment).
  • Warning # 202 actions/untrusted-checkout-toctou/critical at .github/workflows/coverage.yaml:207:9 — Insufficient protection against execution of untrusted code on a privileged workflow (issue_comment).
  • Warning # 203 actions/untrusted-checkout-toctou/critical at .github/workflows/coverage.yaml:226:9 — Insufficient protection against execution of untrusted code on a privileged workflow (issue_comment).
  • Warning # 204 actions/untrusted-checkout-toctou/critical at .github/workflows/coverage.yaml:251:9 — Insufficient protection against execution of untrusted code on a privileged workflow (issue_comment).
  • Warning # 205 actions/untrusted-checkout-toctou/critical at .github/workflows/header-guards-fix.yaml:107:9 — Insufficient protection against execution of untrusted code on a privileged workflow (issue_comment).
    Insufficient protection against execution of untrusted code on a privileged workflow (issue_comment).
  • Warning # 206 actions/untrusted-checkout-toctou/critical at .github/workflows/markdown-fix.yaml:107:9 — Insufficient protection against execution of untrusted code on a privileged workflow (issue_comment).
    Insufficient protection against execution of untrusted code on a privileged workflow (issue_comment).
  • Warning # 207 actions/untrusted-checkout-toctou/critical at .github/workflows/yaml-fix.yaml:108:9 — Insufficient protection against execution of untrusted code on a privileged workflow (issue_comment).
    Insufficient protection against execution of untrusted code on a privileged workflow (issue_comment).
  • Warning # 208 actions/untrusted-checkout-toctou/critical at .github/workflows/yaml-fix.yaml:111:9 — Insufficient protection against execution of untrusted code on a privileged workflow (issue_comment).
    Insufficient protection against execution of untrusted code on a privileged workflow (issue_comment).
  • Warning # 209 actions/untrusted-checkout-toctou/high at .github/workflows/clang-format-fix.yaml:94:9 — Insufficient protection against execution of untrusted code on a privileged workflow (issue_comment).
    Insufficient protection against execution of untrusted code on a privileged workflow (issue_comment).
  • Warning # 210 actions/untrusted-checkout-toctou/high at .github/workflows/cmake-format-fix.yaml:94:9 — Insufficient protection against execution of untrusted code on a privileged workflow (issue_comment).
    Insufficient protection against execution of untrusted code on a privileged workflow (issue_comment).
  • Warning # 211 actions/untrusted-checkout-toctou/high at .github/workflows/jsonnet-format-fix.yaml:95:9 — Insufficient protection against execution of untrusted code on a privileged workflow (issue_comment).
    Insufficient protection against execution of untrusted code on a privileged workflow (issue_comment).
  • Warning # 212 actions/untrusted-checkout-toctou/high at .github/workflows/python-fix.yaml:94:9 — Insufficient protection against execution of untrusted code on a privileged workflow (issue_comment).
    Insufficient protection against execution of untrusted code on a privileged workflow (issue_comment).
  • Warning # 213 actions/untrusted-checkout/high at .github/workflows/clang-format-fix.yaml:94:9 — Checkout of untrusted code in a privileged workflow with later potential execution (event trigger: issue_comment).
    Checkout of untrusted code in a privileged workflow with later potential execution (event trigger: issue_comment).
  • Warning # 214 actions/untrusted-checkout/high at .github/workflows/cmake-format-fix.yaml:94:9 — Checkout of untrusted code in a privileged workflow with later potential execution (event trigger: issue_comment).
    Checkout of untrusted code in a privileged workflow with later potential execution (event trigger: issue_comment).
  • Warning # 215 actions/untrusted-checkout/high at .github/workflows/jsonnet-format-fix.yaml:95:9 — Checkout of untrusted code in a privileged workflow with later potential execution (event trigger: issue_comment).
    Checkout of untrusted code in a privileged workflow with later potential execution (event trigger: issue_comment).
  • ✅ …and 11 more alerts (see Code Scanning for the full list).

✅ 31 CodeQL alerts resolved since the branch point

  • Warning # 196 actions/untrusted-checkout-toctou/critical at .github/workflows/clang-tidy-fix.yaml:109:9 — Insufficient protection against execution of untrusted code on a privileged workflow (issue_comment).
  • Warning # 197 actions/untrusted-checkout-toctou/critical at .github/workflows/clang-tidy-fix.yaml:137:9 — Insufficient protection against execution of untrusted code on a privileged workflow (issue_comment).
  • Warning # 198 actions/untrusted-checkout-toctou/critical at .github/workflows/clang-tidy-fix.yaml:157:9 — Insufficient protection against execution of untrusted code on a privileged workflow (issue_comment).
  • Warning # 199 actions/untrusted-checkout-toctou/critical at .github/workflows/clang-tidy-fix.yaml:201:9 — Insufficient protection against execution of untrusted code on a privileged workflow (issue_comment).
  • Warning # 200 actions/untrusted-checkout-toctou/critical at .github/workflows/coverage.yaml:166:9 — Insufficient protection against execution of untrusted code on a privileged workflow (issue_comment).
  • Warning # 201 actions/untrusted-checkout-toctou/critical at .github/workflows/coverage.yaml:188:9 — Insufficient protection against execution of untrusted code on a privileged workflow (issue_comment).
  • Warning # 202 actions/untrusted-checkout-toctou/critical at .github/workflows/coverage.yaml:207:9 — Insufficient protection against execution of untrusted code on a privileged workflow (issue_comment).
  • Warning # 203 actions/untrusted-checkout-toctou/critical at .github/workflows/coverage.yaml:226:9 — Insufficient protection against execution of untrusted code on a privileged workflow (issue_comment).
  • Warning # 204 actions/untrusted-checkout-toctou/critical at .github/workflows/coverage.yaml:251:9 — Insufficient protection against execution of untrusted code on a privileged workflow (issue_comment).
  • Warning # 205 actions/untrusted-checkout-toctou/critical at .github/workflows/header-guards-fix.yaml:107:9 — Insufficient protection against execution of untrusted code on a privileged workflow (issue_comment).
    Insufficient protection against execution of untrusted code on a privileged workflow (issue_comment).
  • Warning # 206 actions/untrusted-checkout-toctou/critical at .github/workflows/markdown-fix.yaml:107:9 — Insufficient protection against execution of untrusted code on a privileged workflow (issue_comment).
    Insufficient protection against execution of untrusted code on a privileged workflow (issue_comment).
  • Warning # 207 actions/untrusted-checkout-toctou/critical at .github/workflows/yaml-fix.yaml:108:9 — Insufficient protection against execution of untrusted code on a privileged workflow (issue_comment).
    Insufficient protection against execution of untrusted code on a privileged workflow (issue_comment).
  • Warning # 208 actions/untrusted-checkout-toctou/critical at .github/workflows/yaml-fix.yaml:111:9 — Insufficient protection against execution of untrusted code on a privileged workflow (issue_comment).
    Insufficient protection against execution of untrusted code on a privileged workflow (issue_comment).
  • Warning # 209 actions/untrusted-checkout-toctou/high at .github/workflows/clang-format-fix.yaml:94:9 — Insufficient protection against execution of untrusted code on a privileged workflow (issue_comment).
    Insufficient protection against execution of untrusted code on a privileged workflow (issue_comment).
  • Warning # 210 actions/untrusted-checkout-toctou/high at .github/workflows/cmake-format-fix.yaml:94:9 — Insufficient protection against execution of untrusted code on a privileged workflow (issue_comment).
    Insufficient protection against execution of untrusted code on a privileged workflow (issue_comment).
  • Warning # 211 actions/untrusted-checkout-toctou/high at .github/workflows/jsonnet-format-fix.yaml:95:9 — Insufficient protection against execution of untrusted code on a privileged workflow (issue_comment).
    Insufficient protection against execution of untrusted code on a privileged workflow (issue_comment).
  • Warning # 212 actions/untrusted-checkout-toctou/high at .github/workflows/python-fix.yaml:94:9 — Insufficient protection against execution of untrusted code on a privileged workflow (issue_comment).
    Insufficient protection against execution of untrusted code on a privileged workflow (issue_comment).
  • Warning # 213 actions/untrusted-checkout/high at .github/workflows/clang-format-fix.yaml:94:9 — Checkout of untrusted code in a privileged workflow with later potential execution (event trigger: issue_comment).
    Checkout of untrusted code in a privileged workflow with later potential execution (event trigger: issue_comment).
  • Warning # 214 actions/untrusted-checkout/high at .github/workflows/cmake-format-fix.yaml:94:9 — Checkout of untrusted code in a privileged workflow with later potential execution (event trigger: issue_comment).
    Checkout of untrusted code in a privileged workflow with later potential execution (event trigger: issue_comment).
  • Warning # 215 actions/untrusted-checkout/high at .github/workflows/jsonnet-format-fix.yaml:95:9 — Checkout of untrusted code in a privileged workflow with later potential execution (event trigger: issue_comment).
    Checkout of untrusted code in a privileged workflow with later potential execution (event trigger: issue_comment).
  • ✅ …and 11 more alerts (see Code Scanning for the full list).

Review the full CodeQL report for details.

@github-actions

github-actions Bot commented Jun 2, 2026

Copy link
Copy Markdown
Contributor

Clang-Tidy Check Results

55 new issue(s) introduced by this patch (5842 total).

New issues on modified lines:

  • /__w/phlex/phlex/phlex-src/plugins/python/src/dyncall.cpp:17: warning: variable 'ffi_t' is non-const and globally accessible, consider making it const
  • /__w/phlex/phlex/phlex-src/plugins/python/src/dyncall.cpp:62: warning: do not use array subscript when the index is not an integer constant expression
  • /__w/phlex/phlex/phlex-src/plugins/python/src/dyncall.cpp:67: warning: variable 'status' is not initialized
  • /__w/phlex/phlex/phlex-src/plugins/python/src/dyncall.cpp:69: warning: do not use array subscript when the index is not an integer constant expression
  • /__w/phlex/phlex/phlex-src/plugins/python/src/dyncall.cpp:71: warning: do not use array subscript when the index is not an integer constant expression
  • /__w/phlex/phlex/phlex-src/plugins/python/src/dyncall.cpp:76: warning: do not use C-style cast to convert between unrelated types
  • /__w/phlex/phlex/phlex-src/plugins/python/src/dyncall.hpp:72: warning: do not access members of unions; consider using (boost::)variant instead
  • /__w/phlex/phlex/phlex-src/plugins/python/src/dyncall.hpp:73: warning: do not access members of unions; consider using (boost::)variant instead
  • /__w/phlex/phlex/phlex-src/plugins/python/src/dyncall.hpp:74: warning: do not access members of unions; consider using (boost::)variant instead
  • /__w/phlex/phlex/phlex-src/plugins/python/src/dyncall.hpp:75: warning: do not access members of unions; consider using (boost::)variant instead
  • /__w/phlex/phlex/phlex-src/plugins/python/src/dyncall.hpp:76: warning: do not access members of unions; consider using (boost::)variant instead
  • /__w/phlex/phlex/phlex-src/plugins/python/src/dyncall.hpp:77: warning: do not access members of unions; consider using (boost::)variant instead
  • /__w/phlex/phlex/phlex-src/plugins/python/src/dyncall.hpp:78: warning: do not access members of unions; consider using (boost::)variant instead
  • /__w/phlex/phlex/phlex-src/plugins/python/src/dyncall.hpp:79: warning: do not access members of unions; consider using (boost::)variant instead
  • /__w/phlex/phlex/phlex-src/plugins/python/src/dyncall.hpp:80: warning: do not access members of unions; consider using (boost::)variant instead
  • /__w/phlex/phlex/phlex-src/plugins/python/src/dyncall.hpp:81: warning: do not access members of unions; consider using (boost::)variant instead
  • /__w/phlex/phlex/phlex-src/plugins/python/src/dyncall.hpp:82: warning: do not access members of unions; consider using (boost::)variant instead
  • /__w/phlex/phlex/phlex-src/plugins/python/src/dyncall.hpp:83: warning: do not access members of unions; consider using (boost::)variant instead
  • /__w/phlex/phlex/phlex-src/plugins/python/src/dyncall.hpp:84: warning: do not access members of unions; consider using (boost::)variant instead
  • /__w/phlex/phlex/phlex-src/plugins/python/src/dyncall.hpp:89: warning: do not access members of unions; consider using (boost::)variant instead
  • /__w/phlex/phlex/phlex-src/plugins/python/src/dyncall.hpp:90: warning: do not access members of unions; consider using (boost::)variant instead
  • /__w/phlex/phlex/phlex-src/plugins/python/src/dyncall.hpp:91: warning: do not access members of unions; consider using (boost::)variant instead
  • /__w/phlex/phlex/phlex-src/plugins/python/src/dyncall.hpp:92: warning: do not access members of unions; consider using (boost::)variant instead
  • /__w/phlex/phlex/phlex-src/plugins/python/src/dyncall.hpp:93: warning: do not access members of unions; consider using (boost::)variant instead
  • /__w/phlex/phlex/phlex-src/plugins/python/src/dyncall.hpp:94: warning: do not access members of unions; consider using (boost::)variant instead
  • /__w/phlex/phlex/phlex-src/plugins/python/src/dyncall.hpp:95: warning: do not access members of unions; consider using (boost::)variant instead
  • /__w/phlex/phlex/phlex-src/plugins/python/src/dyncall.hpp:96: warning: do not access members of unions; consider using (boost::)variant instead
  • /__w/phlex/phlex/phlex-src/plugins/python/src/dyncall.hpp:96: warning: integer literal has suffix 'l', which is not uppercase
  • /__w/phlex/phlex/phlex-src/plugins/python/src/dyncall.hpp:97: warning: do not access members of unions; consider using (boost::)variant instead
  • /__w/phlex/phlex/phlex-src/plugins/python/src/dyncall.hpp:98: warning: do not access members of unions; consider using (boost::)variant instead
  • /__w/phlex/phlex/phlex-src/plugins/python/src/dyncall.hpp:99: warning: do not access members of unions; consider using (boost::)variant instead
  • /__w/phlex/phlex/phlex-src/plugins/python/src/dyncall.hpp:100: warning: do not access members of unions; consider using (boost::)variant instead
  • /__w/phlex/phlex/phlex-src/plugins/python/src/dyncall.hpp:108: warning: multilevel pointer conversion from 'void **' to 'void *', please use explicit cast
  • /__w/phlex/phlex/phlex-src/plugins/python/src/dyncall.hpp:108: warning: do not access members of unions; consider using (boost::)variant instead
  • /__w/phlex/phlex/phlex-src/plugins/python/src/dyncall.hpp:110: warning: do not access members of unions; consider using (boost::)variant instead
  • /__w/phlex/phlex/phlex-src/plugins/python/src/dyncall.hpp:112: warning: do not access members of unions; consider using (boost::)variant instead
  • /__w/phlex/phlex/phlex-src/plugins/python/src/dyncall.hpp:114: warning: do not access members of unions; consider using (boost::)variant instead
  • /__w/phlex/phlex/phlex-src/plugins/python/src/dyncall.hpp:116: warning: do not access members of unions; consider using (boost::)variant instead
  • /__w/phlex/phlex/phlex-src/plugins/python/src/dyncall.hpp:118: warning: do not access members of unions; consider using (boost::)variant instead
  • /__w/phlex/phlex/phlex-src/plugins/python/src/dyncall.hpp:120: warning: do not access members of unions; consider using (boost::)variant instead
  • /__w/phlex/phlex/phlex-src/plugins/python/src/dyncall.hpp:122: warning: do not access members of unions; consider using (boost::)variant instead
  • /__w/phlex/phlex/phlex-src/plugins/python/src/dyncall.hpp:124: warning: do not access members of unions; consider using (boost::)variant instead
  • /__w/phlex/phlex/phlex-src/plugins/python/src/dyncall.hpp:126: warning: do not access members of unions; consider using (boost::)variant instead
  • /__w/phlex/phlex/phlex-src/plugins/python/src/dyncall.hpp:128: warning: do not access members of unions; consider using (boost::)variant instead
  • /__w/phlex/phlex/phlex-src/plugins/python/src/dyncall.hpp:130: warning: do not access members of unions; consider using (boost::)variant instead
  • /__w/phlex/phlex/phlex-src/plugins/python/src/modulewrap.cpp:110: warning: do not access members of unions; consider using (boost::)variant instead
  • /__w/phlex/phlex/phlex-src/plugins/python/src/modulewrap.cpp:169: warning: do not use C-style cast to convert between unrelated types
  • /__w/phlex/phlex/phlex-src/plugins/python/src/modulewrap.cpp:187: warning: do not access members of unions; consider using (boost::)variant instead
  • /__w/phlex/phlex/phlex-src/plugins/python/src/modulewrap.cpp:200: warning: do not use C-style cast to convert between unrelated types
  • /__w/phlex/phlex/phlex-src/plugins/python/src/modulewrap.cpp:200: warning: do not access members of unions; consider using (boost::)variant instead
  • /__w/phlex/phlex/phlex-src/plugins/python/src/modulewrap.cpp:208: warning: do not access members of unions; consider using (boost::)variant instead
  • /__w/phlex/phlex/phlex-src/plugins/python/src/modulewrap.cpp:222: warning: 'm_rtype' should be initialized in a member initializer of the constructor
  • /__w/phlex/phlex/phlex-src/plugins/python/src/modulewrap.cpp:602: warning: do not access members of unions; consider using (boost::)variant instead
  • /__w/phlex/phlex/phlex-src/plugins/python/src/modulewrap.cpp:603: warning: do not access members of unions; consider using (boost::)variant instead
  • /__w/phlex/phlex/phlex-src/plugins/python/src/modulewrap.cpp:976: warning: 'func' used after it was forwarded

All issues by check:

  • readability-identifier-naming: 1826
  • readability-redundant-typename: 1217
  • readability-redundant-member-init: 1138
  • performance-unnecessary-value-param: 478
  • readability-avoid-const-params-in-decls: 239
  • modernize-pass-by-value: 199
  • readability-braces-around-statements: 129
  • cppcoreguidelines-pro-type-union-access: 91
  • readability-convert-member-functions-to-static: 79
  • modernize-use-designated-initializers: 72
  • readability-const-return-type: 47
  • modernize-avoid-c-style-cast: 33
  • modernize-use-auto: 28
  • readability-inconsistent-ifelse-braces: 21
  • readability-qualified-auto: 20
  • modernize-use-using: 19
  • readability-redundant-control-flow: 19
  • modernize-avoid-c-arrays: 18
  • readability-math-missing-parentheses: 17
  • modernize-use-equals-default: 14
  • readability-function-size: 13
  • readability-static-definition-in-anonymous-namespace: 13
  • modernize-return-braced-init-list: 10
  • modernize-concat-nested-namespaces: 10
  • cppcoreguidelines-pro-type-cstyle-cast: 9
  • readability-isolate-declaration: 8
  • readability-inconsistent-declaration-parameter-name: 7
  • cppcoreguidelines-special-member-functions: 7
  • readability-container-contains: 7
  • modernize-use-starts-ends-with: 6
  • readability-redundant-casting: 5
  • readability-redundant-access-specifiers: 5
  • modernize-use-ranges: 5
  • readability-container-size-empty: 5
  • bugprone-branch-clone: 3
  • cppcoreguidelines-pro-bounds-constant-array-index: 3
  • modernize-use-std-numbers: 3
  • readability-else-after-return: 2
  • cert-dcl16-c: 2
  • bugprone-multi-level-implicit-pointer-conversion: 2
  • clang-analyzer-security.ArrayBound: 2
  • modernize-make-shared: 1
  • cppcoreguidelines-avoid-non-const-global-variables: 1
  • cppcoreguidelines-init-variables: 1
  • modernize-use-emplace: 1
  • cppcoreguidelines-prefer-member-initializer: 1
  • readability-simplify-boolean-expr: 1
  • modernize-use-integer-sign-comparison: 1
  • readability-use-anyofallof: 1
  • bugprone-use-after-move: 1
  • modernize-redundant-void-arg: 1
  • readability-redundant-string-init: 1

See inline comments for details. Comment @phlexbot tidy-fix to auto-fix.

@codecov

codecov Bot commented Jun 2, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 79.86577% with 60 lines in your changes missing coverage. Please review.

Files with missing lines Patch % Lines
plugins/python/src/modulewrap.cpp 80.55% 19 Missing and 23 partials ⚠️
plugins/python/src/dyncall.cpp 81.66% 8 Missing and 3 partials ⚠️
plugins/python/src/dyncall.hpp 66.66% 5 Missing ⚠️
plugins/python/python/phlex/_typing.py 71.42% 2 Missing ⚠️
@@            Coverage Diff             @@
##             main     #626      +/-   ##
==========================================
- Coverage   83.27%   83.21%   -0.06%     
==========================================
  Files         162      172      +10     
  Lines        5912     6725     +813     
  Branches      670      825     +155     
==========================================
+ Hits         4923     5596     +673     
- Misses        796      851      +55     
- Partials      193      278      +85     
Flag Coverage Δ
scripts 78.86% <ø> (+2.49%) ⬆️
unittests 85.20% <79.86%> (-1.66%) ⬇️

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

Files with missing lines Coverage Δ
plugins/python/python/phlex/_typing.py 92.30% <71.42%> (-2.06%) ⬇️
plugins/python/src/dyncall.hpp 66.66% <66.66%> (ø)
plugins/python/src/dyncall.cpp 81.66% <81.66%> (ø)
plugins/python/src/modulewrap.cpp 76.72% <80.55%> (-3.89%) ⬇️

... and 20 files with indirect coverage changes


Continue to review full report in Codecov by Harness.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update a98ac3d...025390c. Read the comment docs.

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

@github-actions

github-actions Bot commented Jun 3, 2026

Copy link
Copy Markdown
Contributor

Clang-Tidy Check Results

3 new issue(s) introduced by this patch (5777 total).

New issues on modified lines:

  • /__w/phlex/phlex/phlex-src/plugins/python/src/dyncall.hpp:35: warning: declaration uses identifier '_object', which is reserved in the global namespace
  • /__w/phlex/phlex/phlex-src/plugins/python/src/modulewrap.cpp:969: warning: forwarding reference parameter 'func' is never forwarded inside the function body
  • /__w/phlex/phlex/phlex-src/plugins/python/src/dyncall.cpp:66: warning: repeated branch body in conditional chain

All issues by check:

  • readability-identifier-naming: 1807
  • readability-redundant-typename: 1217
  • readability-redundant-member-init: 1138
  • performance-unnecessary-value-param: 479
  • readability-avoid-const-params-in-decls: 257
  • modernize-pass-by-value: 200
  • readability-braces-around-statements: 116
  • readability-convert-member-functions-to-static: 80
  • modernize-use-designated-initializers: 72
  • readability-use-concise-preprocessor-directives: 60
  • readability-const-return-type: 47
  • modernize-avoid-c-style-cast: 27
  • modernize-use-auto: 26
  • modernize-use-using: 21
  • readability-inconsistent-ifelse-braces: 21
  • readability-qualified-auto: 20
  • readability-redundant-control-flow: 19
  • readability-math-missing-parentheses: 17
  • modernize-avoid-c-arrays: 16
  • modernize-use-equals-default: 14
  • readability-static-definition-in-anonymous-namespace: 14
  • readability-function-size: 12
  • modernize-concat-nested-namespaces: 10
  • modernize-return-braced-init-list: 10
  • readability-isolate-declaration: 8
  • readability-inconsistent-declaration-parameter-name: 7
  • readability-container-contains: 7
  • cppcoreguidelines-special-member-functions: 7
  • modernize-use-starts-ends-with: 6
  • modernize-use-ranges: 5
  • readability-redundant-casting: 5
  • readability-container-size-empty: 5
  • readability-redundant-access-specifiers: 5
  • bugprone-branch-clone: 4
  • modernize-use-std-numbers: 3
  • readability-else-after-return: 2
  • clang-analyzer-security.ArrayBound: 2
  • bugprone-reserved-identifier: 2
  • modernize-redundant-void-arg: 1
  • modernize-make-shared: 1
  • readability-redundant-string-init: 1
  • modernize-use-emplace: 1
  • readability-simplify-boolean-expr: 1
  • modernize-use-integer-sign-comparison: 1
  • readability-use-anyofallof: 1
  • cppcoreguidelines-missing-std-forward: 1
  • performance-move-const-arg: 1

See inline comments for details. Comment @phlexbot tidy-fix to auto-fix.

@github-actions

github-actions Bot commented Jun 3, 2026

Copy link
Copy Markdown
Contributor

Clang-Tidy Check Results

2 new issue(s) introduced by this patch (5769 total).

New issues on modified lines:

  • /__w/phlex/phlex/phlex-src/plugins/python/src/dyncall.cpp:67: warning: repeated branch body in conditional chain
  • /__w/phlex/phlex/phlex-src/plugins/python/src/modulewrap.cpp:978: warning: 'func' used after it was forwarded

All issues by check:

  • readability-identifier-naming: 1804
  • readability-redundant-typename: 1217
  • readability-redundant-member-init: 1138
  • performance-unnecessary-value-param: 479
  • readability-avoid-const-params-in-decls: 257
  • modernize-pass-by-value: 200
  • readability-braces-around-statements: 116
  • readability-convert-member-functions-to-static: 80
  • modernize-use-designated-initializers: 72
  • readability-use-concise-preprocessor-directives: 60
  • readability-const-return-type: 47
  • modernize-avoid-c-style-cast: 27
  • modernize-use-auto: 26
  • readability-inconsistent-ifelse-braces: 21
  • readability-qualified-auto: 20
  • modernize-use-using: 19
  • readability-redundant-control-flow: 19
  • readability-math-missing-parentheses: 17
  • modernize-avoid-c-arrays: 15
  • readability-static-definition-in-anonymous-namespace: 14
  • modernize-use-equals-default: 14
  • readability-function-size: 12
  • modernize-return-braced-init-list: 10
  • modernize-concat-nested-namespaces: 10
  • readability-isolate-declaration: 8
  • readability-inconsistent-declaration-parameter-name: 7
  • cppcoreguidelines-special-member-functions: 7
  • readability-container-contains: 7
  • modernize-use-starts-ends-with: 6
  • readability-redundant-casting: 5
  • readability-redundant-access-specifiers: 5
  • modernize-use-ranges: 5
  • readability-container-size-empty: 5
  • bugprone-branch-clone: 4
  • modernize-use-std-numbers: 3
  • readability-else-after-return: 2
  • clang-analyzer-security.ArrayBound: 2
  • readability-redundant-string-init: 1
  • performance-move-const-arg: 1
  • modernize-make-shared: 1
  • modernize-use-emplace: 1
  • readability-simplify-boolean-expr: 1
  • modernize-use-integer-sign-comparison: 1
  • readability-use-anyofallof: 1
  • bugprone-use-after-move: 1
  • modernize-redundant-void-arg: 1

See inline comments for details. Comment @phlexbot tidy-fix to auto-fix.

@wlav

wlav commented Jun 3, 2026

Copy link
Copy Markdown
Contributor Author

@phlexbot header-guards-fix

@github-actions

github-actions Bot commented Jun 3, 2026

Copy link
Copy Markdown
Contributor

Automatic header-guards fixes pushed (commit ea7dff7).
⚠️ Note: Some issues may require manual review and fixing.

@github-actions

github-actions Bot commented Jun 3, 2026

Copy link
Copy Markdown
Contributor

Clang-Tidy Check Results

2 new issue(s) introduced by this patch (5767 total).

New issues on modified lines:

  • /__w/phlex/phlex/phlex-src/plugins/python/src/dyncall.cpp:67: warning: repeated branch body in conditional chain
  • /__w/phlex/phlex/phlex-src/plugins/python/src/modulewrap.cpp:978: warning: 'func' used after it was forwarded

All issues by check:

  • readability-identifier-naming: 1802
  • readability-redundant-typename: 1217
  • readability-redundant-member-init: 1138
  • performance-unnecessary-value-param: 479
  • readability-avoid-const-params-in-decls: 257
  • modernize-pass-by-value: 200
  • readability-braces-around-statements: 116
  • readability-convert-member-functions-to-static: 80
  • modernize-use-designated-initializers: 72
  • readability-use-concise-preprocessor-directives: 60
  • readability-const-return-type: 47
  • modernize-avoid-c-style-cast: 27
  • modernize-use-auto: 26
  • readability-inconsistent-ifelse-braces: 21
  • readability-qualified-auto: 20
  • modernize-use-using: 19
  • readability-redundant-control-flow: 19
  • readability-math-missing-parentheses: 17
  • modernize-avoid-c-arrays: 15
  • modernize-use-equals-default: 14
  • readability-static-definition-in-anonymous-namespace: 14
  • readability-function-size: 12
  • modernize-concat-nested-namespaces: 10
  • modernize-return-braced-init-list: 10
  • readability-isolate-declaration: 8
  • readability-container-contains: 7
  • readability-inconsistent-declaration-parameter-name: 7
  • cppcoreguidelines-special-member-functions: 7
  • modernize-use-starts-ends-with: 6
  • readability-redundant-access-specifiers: 5
  • modernize-use-ranges: 5
  • readability-container-size-empty: 5
  • readability-redundant-casting: 5
  • bugprone-branch-clone: 4
  • modernize-use-std-numbers: 3
  • clang-analyzer-security.ArrayBound: 2
  • readability-else-after-return: 2
  • modernize-redundant-void-arg: 1
  • modernize-use-emplace: 1
  • readability-simplify-boolean-expr: 1
  • modernize-use-integer-sign-comparison: 1
  • readability-use-anyofallof: 1
  • bugprone-use-after-move: 1
  • modernize-make-shared: 1
  • performance-move-const-arg: 1
  • readability-redundant-string-init: 1

See inline comments for details. Comment @phlexbot tidy-fix to auto-fix.

Comment thread plugins/python/src/modulewrap.cpp
@coderabbitai

coderabbitai Bot commented Jun 18, 2026

Copy link
Copy Markdown

Review Change Stack

Important

Review skipped

Auto incremental reviews are disabled on this repository.

Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

⚙️ Run configuration

Configuration used: Organization UI

Review profile: ASSERTIVE

Plan: Pro Plus

Run ID: 56dac91e-d495-4133-9067-a23fed333042

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Use the checkbox below for a quick retry:

  • 🔍 Trigger review
📝 Walkthrough

Walkthrough

Adds Numba JIT cfunc support to the Phlex Python plugin. A new dcarg/dyncall layer backed by libffi enables runtime dynamic dispatch of typed C function pointers. modulewrap.cpp is refactored to route callbacks through either py_callback_impl (Python callables) or jit_callback_impl (Numba cfuncs), with selector-based input validation and unroll_switch-driven N=1..3 registration. Type mappings and tests are extended to cover Numba primitives.

Changes

Numba JIT cfunc Integration

Layer / File(s) Summary
Build: libffi discovery and dyncall.cpp wiring
plugins/python/CMakeLists.txt
Adds find_package(PkgConfig), requires libffi via pkg_check_modules(FFI REQUIRED libffi), adds src/dyncall.cpp to pymodule sources, and links pymodule against PkgConfig::FFI.
dcarg/dyncall contract and implementation
plugins/python/src/dyncall.hpp, plugins/python/src/dyncall.cpp
Defines the dcarg variant-based argument wrapper (from_str, value_ptr, get<T>(), PyObject* specialization) and dyncall function; implements get_ffi_type mapping, ffi_prep_cif/ffi_prep_cif_var preparation, and ffi_call dispatch.
Python type mapping: Numba primitives
plugins/python/python/phlex/_typing.py
Conditionally imports numba.core.types and extends _PY2CPP with Numba scalar/void mappings; adds float32float and float64double to _C2C.
modulewrap.cpp: dcarg-based callback/converter infrastructure
plugins/python/src/modulewrap.cpp
Introduces MAX_SUPPORTED_ARGS=3; replaces raw pointer/template callback approach with py_callback_base/py_callback_impl/jit_callback_impl; adds validate_selector, is_numba_cfunc, and rewrites annotations_to_strings for Numba sigs; ports all converter macros (BASIC_CONVERTER, VECTOR_CONVERTER, NUMPY_ARRAY_CONVERTER) to dcarg.
modulewrap.cpp: graph wiring
plugins/python/src/modulewrap.cpp
Refactors parse_args to emit input_selectors and nconcur; adds unroll_switch helper; rewrites md_transform and md_observe to detect Numba cfuncs, use ispy direction flags in converter insertion, and register N=1..3 callbacks; updates sc_provide to use validate_selector.
Test: Numba cfunc integration test and CMake wiring
test/python/CMakeLists.txt, test/python/jited.py, test/python/pyjited.jsonnet
Adds jited.py registering Numba cfunc add transforms and observers across numeric dtype specs; adds pyjited.jsonnet test config; gates the new py:jited test behind HAS_NUMBA in CMake and relocates the HAS_CPPYY block.

Sequence Diagram(s)

sequenceDiagram
  rect rgba(30, 120, 200, 0.5)
    Note over Phlex,ffi: Python callback path
    Phlex->>modulewrap: md_transform(callable, input_selectors, ...)
    modulewrap->>modulewrap: parse_args → input_selectors, nconcur
    modulewrap->>modulewrap: is_numba_cfunc(callable)?
  end
  alt Numba cfunc detected
    rect rgba(180, 80, 30, 0.5)
      Note over modulewrap,ffi: JIT dispatch path
      modulewrap->>jit_callback_impl: register jit_callback<RetT, N>
      jit_callback_impl->>dcarg: build dcargs_t from typed inputs
      jit_callback_impl->>dyncall: dyncall(fn_ptr, result, args)
      dyncall->>ffi: ffi_prep_cif + ffi_call
      ffi-->>jit_callback_impl: result dcarg
    end
  else Python callable
    rect rgba(30, 160, 80, 0.5)
      Note over modulewrap,CPython: Python dispatch path
      modulewrap->>py_callback_impl: register py_callback<RetT, N>
      py_callback_impl->>CPython: lifeline_transform + PyObject_Call
      py_callback_impl->>dyncall: dyncall for return type extraction
      dyncall->>ffi: ffi_prep_cif + ffi_call
      ffi-->>py_callback_impl: result dcarg
    end
  end
  modulewrap->>Phlex: insert_input_converters + insert_output_converter (ispy flag)
Loading

Estimated code review effort

🎯 5 (Critical) | ⏱️ ~120 minutes

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 16.67% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title 'Initial Numba support' directly and accurately summarizes the main change: adding native Numba support to phlex for JITed C-function calling without GIL.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

Comment @coderabbitai help to get the list of available commands.

@coderabbitai coderabbitai Bot 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.

Actionable comments posted: 15

Caution

Some comments are outside the diff and can’t be posted inline due to platform limitations.

⚠️ Outside diff range comments (1)
plugins/python/src/modulewrap.cpp (1)

283-313: ⚠️ Potential issue | 🟠 Major | ⚡ Quick win

Missing Py_DECREF(coll) — leaks the fast sequence.

PySequence_Fast returns a new reference that must be decref'd. The similar function validate_output (line 345) properly does Py_DECREF(coll), but this function doesn't. Classic copy-paste gremlin situation.

🐛 Proposed fix
     if (PyErr_Occurred())
       cargs.clear(); // error handled through Python
 
+    Py_DECREF(coll);
     return cargs;
   }
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@plugins/python/src/modulewrap.cpp` around lines 283 - 313, The validate_input
function is missing a Py_DECREF call for the coll object returned by
PySequence_Fast. PySequence_Fast creates a new reference that must be explicitly
freed before the function returns. Add Py_DECREF(coll) before the final return
statement in validate_input to properly release the reference, matching the
correct pattern used in the similar validate_output function.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@plugins/python/CMakeLists.txt`:
- Around line 10-11: The CMakeLists.txt file has formatting that does not
conform to the project's CMake style standards, causing the cmake-format-check
CI step to fail. Run the gersemi formatter on the plugins/python/CMakeLists.txt
file to automatically reformat it according to the project's CMake formatting
rules. This will fix the formatting issues in the find_package and
pkg_check_modules calls and allow the CI pipeline to pass.

In `@plugins/python/src/dyncall.cpp`:
- Around line 15-36: The from_str method in phlex::experimental::dcarg is
missing handling for four integer types that are supported elsewhere. Add four
new else if conditions to the from_str function to handle the type strings
"int8_t", "uint8_t", "int16_t", and "uint16_t", each returning a dcarg object
initialized with a zero value cast to the appropriate type. These should be
inserted before the final throw statement, following the same pattern as the
existing type cases like int32_t and uint64_t.

In `@plugins/python/src/dyncall.hpp`:
- Around line 26-34: The existing comment in the conditional type aliasing block
(lines with ifdef __APPLE__ and the typedef declarations for ph_long_t and
ph_ulong_t) describes this as a "temporary workaround" but lacks clarity on what
needs to be addressed long-term. Enhance the comment to include a specific TODO
or FIXME note that explains this code should be revisited once a proper
cross-platform type translation layer is implemented between C++ and Python,
making it clear what the eventual solution should address and when this
temporary fix can be removed.
- Around line 38-82: The template method get<T>() in the dcarg struct is missing
const qualification, preventing it from being called on const dcarg objects or
const references. Add the const qualifier to the get<T>() method signature to
allow read-only access to the value from const dcarg instances.

In `@plugins/python/src/modulewrap.cpp`:
- Around line 300-306: The comment on line 305 contains a typo referencing
"validate_selection" instead of the actual function name being called. In the
section where validate_selector function is invoked (around line 300), correct
the comment to reference validate_selector instead of validate_selection to
ensure the documentation accurately reflects the function being used.
- Around line 45-50: Fix the typo in the comment above the MAX_SUPPORTED_ARGS
constant declaration. Change "compile-timee" to "compile-time" by removing the
extra 'e' at the end of the word.
- Around line 1110-1117: In the code block where is_numba_cfunc(callable) is
checked, the pyaddr variable obtained from PyObject_GetAttrString is never
decremented, causing a memory leak. After using pyaddr with
PyLong_AsVoidPtr(pyaddr), add a Py_DECREF(pyaddr) call to properly release the
Python object reference. Place the Py_DECREF after the PyLong_AsVoidPtr call but
ensure it executes in both code paths (whether ccallf is set or not).
- Around line 1003-1010: The PyObject_GetAttrString function returns a new
reference to a PyObject that must be decremented to avoid a memory leak. In the
code block where is_numba_cfunc is true, after obtaining the pyaddr reference
and extracting its void pointer value with PyLong_AsVoidPtr, add a
Py_DECREF(pyaddr) call to release the reference. This should be done at the end
of the if (pyaddr) block after the ccallf assignment is complete to ensure the
reference is always released when pyaddr is not null.
- Around line 424-450: The PyObject reference obtained from
PyObject_GetAttrString(callable, "_sig") at the beginning of this block is not
being decreffed, causing a memory leak. While the child attributes ret and args
are properly decreffed at lines 439-440, the parent sig object is missing its
corresponding Py_XDECREF call. Add Py_XDECREF(sig) after the entire if-else
block that checks for the "_sig" attribute and its alternatives (including the
else block that handles the __call__ method) has completed, to properly release
the reference.
- Around line 147-156: The move constructor and move assignment operator in
py_callback_base are currently using default implementations, which shallow-copy
the m_callable pointer without nulling the source. This creates a latent
double-decref bug that will manifest when the destructor is fixed to properly
decref m_callable. Replace the defaulted move constructor
py_callback_base(py_callback_base&&) and move assignment operator
operator=(py_callback_base&&) with custom implementations that copy the source's
m_callable to the destination, then set the source's m_callable to nullptr to
prevent double-decref issues during cleanup.

In `@test/python/jited.py`:
- Line 25: The function PHLEX_REGISTER_ALGORITHMS lacks type hints on its
parameters and return type, which violates coding guidelines. Add type
annotations to the function signature for both the m and config parameters
(using Any if specific Phlex types are unavailable) and add a return type
annotation of None to clarify the registration hook contract. Consider adding
from __future__ import annotations at the top of the file if not already
present.
- Line 30: Fix the spelling error in the docstring around line 30 where "ouput"
is misspelled. Locate the word "ouput" in the docstring that describes producing
a sum and correct it to "output".
- Line 12: Remove the unused import statement for Variant from phlex at the top
of the file. The import `from phlex import Variant` is not referenced anywhere
in the code and violates the project's linting standards (Ruff F401). Delete
this import line entirely to resolve the linting violation.
- Line 61: The input_family parameter line exceeds the 99-character limit at
approximately 103 characters. Break this line into multiple lines by either
splitting the dictionary definition across multiple lines with proper
indentation, or by extracting the dictionary construction into a separate
variable defined above the function call. Ensure the reformatted code maintains
proper indentation and readability while keeping each line under 99 characters.

In `@test/python/pyjited.jsonnet`:
- Around line 1-18: The pyjited.jsonnet file is not formatted according to
jsonnetfmt standards, which will cause CI to fail. Run the jsonnetfmt formatter
with the in-place flag (-i) on this file to automatically reformat it to comply
with the required coding guidelines.

---

Outside diff comments:
In `@plugins/python/src/modulewrap.cpp`:
- Around line 283-313: The validate_input function is missing a Py_DECREF call
for the coll object returned by PySequence_Fast. PySequence_Fast creates a new
reference that must be explicitly freed before the function returns. Add
Py_DECREF(coll) before the final return statement in validate_input to properly
release the reference, matching the correct pattern used in the similar
validate_output function.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: ASSERTIVE

Plan: Pro Plus

Run ID: ce466e49-b930-4eca-9b30-237f5f09d379

📥 Commits

Reviewing files that changed from the base of the PR and between db22b8a and 90cc0ed.

📒 Files selected for processing (8)
  • plugins/python/CMakeLists.txt
  • plugins/python/python/phlex/_typing.py
  • plugins/python/src/dyncall.cpp
  • plugins/python/src/dyncall.hpp
  • plugins/python/src/modulewrap.cpp
  • test/python/CMakeLists.txt
  • test/python/jited.py
  • test/python/pyjited.jsonnet
🔗 Linked repositories identified

CodeRabbit considers these linked repositories for cross-repo context during reviews:

  • Framework-R-D/action-configure-cmake (auto-detected)
  • Framework-R-D/action-workflow-setup (auto-detected)
  • Framework-R-D/action-complete-pr-comment (auto-detected)
  • Framework-R-D/action-handle-fix-commit (auto-detected)
📜 Review details
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (5)
  • GitHub Check: build (gcc, none)
  • GitHub Check: Analyze cpp with CodeQL
  • GitHub Check: Analyze python with CodeQL
  • GitHub Check: coverage
  • GitHub Check: clang-tidy-check
🧰 Additional context used
📓 Path-based instructions (7)
**/*.jsonnet

📄 CodeRabbit inference engine (.github/copilot-instructions.md)

Use jsonnetfmt for consistent Jsonnet formatting; CI enforces this

Use jsonnetfmt formatting for Jsonnet files; CI enforces this

Files:

  • test/python/pyjited.jsonnet
**/*.{cpp,cc,cxx,h,hpp}

📄 CodeRabbit inference engine (.github/copilot-instructions.md)

**/*.{cpp,cc,cxx,h,hpp}: Use clang-format tool for all C++ code formatting (VS Code auto-formats on save); configuration defined in .clang-format with 100-character line limit and 2-space indentation
Follow clang-tidy recommendations defined in .clang-tidy

Files:

  • plugins/python/src/dyncall.hpp
  • plugins/python/src/dyncall.cpp
  • plugins/python/src/modulewrap.cpp
**/*.{hpp,cpp}

📄 CodeRabbit inference engine (AGENTS.md)

**/*.{hpp,cpp}: Use .hpp for header files, .cpp for implementation, and *_test.cpp for test files in C++
Enforce 100-character line limit and 2-space indentation in C++ code via .clang-format
Use QualifierAlignment: Right (east-const) style: int const x not const int x in C++
Use PointerAlignment: Left in C++ (pointer * attached to type, not variable name)
All C++ identifiers must use lower_case naming: namespaces, classes, structs, enums, functions, variables, parameters, members, and constants
Exception to C++ naming: template parameters use CamelCase
Exception to C++ naming: macros use UPPER_CASE
Private, protected, and constant members in C++ must have a trailing underscore (_), no trailing underscore on anything else
Use enum class preferred over plain enum in C++
Use std::shared_ptr for shared ownership, std::unique_ptr for exclusive ownership, raw pointers for non-owning references only in C++
Use functors with agent-noun pattern: ModelEvaluator evaluate_model(...) in C++
Apply .clang-tidy checks for bugprone, cert, clang-analyzer, concurrency, cppcoreguidelines, misc, modernize, performance, portability, and readability as defined in the .clang-tidy configuration file
Use phlex:: namespace for core code, phlex::experimental:: for experimental features in C++

Files:

  • plugins/python/src/dyncall.hpp
  • plugins/python/src/dyncall.cpp
  • plugins/python/src/modulewrap.cpp
**/*.hpp

📄 CodeRabbit inference engine (AGENTS.md)

Avoid boolean parameters in C++ interfaces; prefer enumerations instead

Files:

  • plugins/python/src/dyncall.hpp
plugins/python/**/*.cpp

📄 CodeRabbit inference engine (AGENTS.md)

plugins/python/**/*.cpp: Use std::runtime_error for C++ runtime failures; propagate Python exceptions via PyErr_SetString/PyErr_Format; return nullptr on error; call PyErr_Clear() when recovering in Python/C++ integration
Use manual Py_INCREF/Py_DECREF for reference counting and PyGILRAII RAII wrapper for GIL management in C++ code that interacts with Python
For GC-tracked Python types in C++: use Py_TPFLAGS_HAVE_GC, implement tp_traverse and tp_clear, call PyObject_GC_UnTrack before deallocation

Files:

  • plugins/python/src/dyncall.cpp
  • plugins/python/src/modulewrap.cpp
**/*.py

📄 CodeRabbit inference engine (.github/copilot-instructions.md)

**/*.py: Use ruff for Python formatting and linting (configured in pyproject.toml); follow Google-style docstring conventions; use line length of 99 characters; use double quotes for strings
Use from __future__ import annotations to enable deferred evaluation of type annotations (avoids forward-reference issues; Python >=3.12)
Type hints are recommended; mypy is configured in pyproject.toml
Avoid naming Python test scripts types.py or other names that shadow standard library modules, as this causes obscure import errors
Python test scripts should follow the test structure pattern: C++ driver provides data streams, Jsonnet config wires the graph, and Python script implements algorithms

**/*.py: Enforce 99-character line limit and double quotes in Python via ruff configured in pyproject.toml
Use Google-style docstrings in Python code
Use type hints in Python code and configure mypy for type checking
Use from __future__ import annotations in Python to enable deferred evaluation of type annotations
Use PEP 8 naming in Python: CapWords for classes, snake_case for everything else
When using the read tool for Python files, always use integer values for offset and limit parameters, never float/double values

Files:

  • test/python/jited.py
  • plugins/python/python/phlex/_typing.py
test/**/*.py

📄 CodeRabbit inference engine (AGENTS.md)

Name Python test files as test_*.py, do NOT name files after stdlib modules (e.g., types.py)

Files:

  • test/python/jited.py
🪛 Cppcheck (2.21.0)
plugins/python/src/dyncall.cpp

[style] 15-15: The function 'from_str' is never used.

(unusedFunction)


[style] 96-96: The function 'dyncall' is never used.

(unusedFunction)

🪛 GitHub Actions: wlav checking CMake format / 0_cmake-format-check.txt
plugins/python/CMakeLists.txt

[error] 1-1: gersemi --check failed: the file would be reformatted.

🪛 GitHub Actions: wlav checking CMake format / cmake-format-check
plugins/python/CMakeLists.txt

[error] 1-1: gersemi --check failed: file would be reformatted (CMakeLists.txt not following required formatting). Run 'gersemi' (or 'gersemi --write' if supported) to apply formatting.

🪛 GitHub Actions: wlav checking Python code / 1_python-check.txt
test/python/jited.py

[error] 12-12: ruff check failed (F401): phlex.Variant imported but unused. Remove unused import: phlex.Variant.

🪛 GitHub Actions: wlav checking Python code / python-check
test/python/jited.py

[error] 12-12: ruff check reported F401: phlex.Variant imported but unused. Remove unused import: phlex.Variant.

🔇 Additional comments (27)
plugins/python/CMakeLists.txt (1)

14-26: LGTM!

plugins/python/src/dyncall.hpp (2)

1-25: LGTM!


84-97: LGTM!

plugins/python/src/dyncall.cpp (3)

38-50: LGTM!


52-94: LGTM!


96-129: LGTM!

test/python/CMakeLists.txt (2)

182-187: LGTM!


289-302: LGTM!

test/python/jited.py (2)

47-62: LGTM!


14-22: No changes needed—this inconsistency is intentional. The cppsource4py provider generates ul1 and ul2 such that they always sum to 100 (ul1 = id.number() % 101, ul2 = 100ul - (id.number() % 101)), while all other type pairs are designed to sum to 1 (or 1.0). The expected result of 100 for uint64 is correct.

plugins/python/python/phlex/_typing.py (4)

17-21: LGTM!


23-28: LGTM!


123-127: LGTM!


50-65: Not an issue; nb_types.float64 and nb_types.double are identical in Numba.

Numba's type system treats float64 and double as the same underlying type (both 64-bit IEEE 754 floats). When the identity check runs (nb_types.float64 is nb_types.double), it returns True—they're literally the same object. So the single mapping for nb_types.double already covers any code that references nb_types.float64, and there's zero risk of a KeyError when processing np.float64 inputs from cfunc signatures.

			> Likely an incorrect or invalid review comment.
plugins/python/src/modulewrap.cpp (13)

108-115: LGTM!


162-209: LGTM!


211-236: LGTM!


246-281: LGTM!


357-380: LGTM!


558-604: LGTM!


605-703: LGTM!


724-728: LGTM!


732-836: LGTM!


849-911: LGTM!


913-965: LGTM!


967-984: LGTM!


1316-1323: LGTM!

Comment thread plugins/python/CMakeLists.txt
Comment thread plugins/python/src/dyncall.cpp
Comment thread plugins/python/src/dyncall.hpp
Comment thread plugins/python/src/dyncall.hpp
Comment thread plugins/python/src/modulewrap.cpp
Comment thread test/python/jited.py Outdated
Comment thread test/python/jited.py
Comment thread test/python/jited.py Outdated
Comment thread test/python/jited.py Outdated
Comment thread test/python/pyjited.jsonnet
@knoepfel knoepfel closed this Jun 24, 2026
@knoepfel knoepfel reopened this Jun 24, 2026
@Framework-R-D Framework-R-D deleted a comment from github-actions Bot Jun 24, 2026
@Framework-R-D Framework-R-D deleted a comment from github-actions Bot Jun 24, 2026
@Framework-R-D Framework-R-D deleted a comment from github-actions Bot Jun 24, 2026
@github-actions

Copy link
Copy Markdown
Contributor

Clang-Tidy Check Results

2 new issue(s) introduced by this patch (5522 total).

New issues on modified lines:

  • /__w/phlex/phlex/phlex-src/plugins/python/src/modulewrap.cpp:1010: warning: uninitialized record type: 'nconcur'
  • /__w/phlex/phlex/phlex-src/plugins/python/src/modulewrap.cpp:1119: warning: uninitialized record type: 'nconcur'

All issues by check:

  • readability-identifier-naming: 2137
  • readability-redundant-member-init: 1258
  • portability-template-virtual-member-function: 563
  • performance-unnecessary-value-param: 457
  • readability-avoid-const-params-in-decls: 269
  • modernize-pass-by-value: 206
  • readability-braces-around-statements: 121
  • modernize-use-designated-initializers: 86
  • readability-convert-member-functions-to-static: 80
  • readability-const-return-type: 50
  • modernize-use-auto: 35
  • readability-qualified-auto: 26
  • readability-redundant-control-flow: 24
  • modernize-use-using: 19
  • modernize-concat-nested-namespaces: 17
  • readability-math-missing-parentheses: 16
  • modernize-avoid-c-arrays: 15
  • modernize-use-equals-default: 15
  • readability-static-definition-in-anonymous-namespace: 14
  • readability-function-size: 14
  • bugprone-branch-clone: 12
  • modernize-return-braced-init-list: 11
  • readability-isolate-declaration: 8
  • cppcoreguidelines-special-member-functions: 8
  • readability-container-size-empty: 7
  • modernize-use-starts-ends-with: 7
  • modernize-use-ranges: 6
  • readability-redundant-access-specifiers: 5
  • readability-redundant-casting: 5
  • readability-inconsistent-declaration-parameter-name: 5
  • readability-container-contains: 5
  • modernize-use-emplace: 4
  • modernize-use-std-numbers: 3
  • modernize-use-integer-sign-comparison: 2
  • cppcoreguidelines-pro-type-member-init: 2
  • readability-else-after-return: 2
  • performance-avoid-endl: 2
  • modernize-redundant-void-arg: 1
  • readability-redundant-string-init: 1
  • readability-simplify-boolean-expr: 1
  • readability-use-anyofallof: 1
  • performance-move-const-arg: 1
  • modernize-make-shared: 1

See inline comments for details. Comment @phlexbot tidy-fix to auto-fix.

@github-actions

Copy link
Copy Markdown
Contributor

Clang-Tidy Check Results

Found 5522 issue(s); none are newly introduced by this patch.

All issues by check:

  • readability-identifier-naming: 2137
  • readability-redundant-member-init: 1258
  • portability-template-virtual-member-function: 563
  • performance-unnecessary-value-param: 457
  • readability-avoid-const-params-in-decls: 269
  • modernize-pass-by-value: 206
  • readability-braces-around-statements: 121
  • modernize-use-designated-initializers: 86
  • readability-convert-member-functions-to-static: 80
  • readability-const-return-type: 50
  • modernize-use-auto: 37
  • readability-qualified-auto: 26
  • readability-redundant-control-flow: 24
  • modernize-use-using: 19
  • modernize-concat-nested-namespaces: 17
  • readability-math-missing-parentheses: 16
  • modernize-use-equals-default: 15
  • modernize-avoid-c-arrays: 15
  • readability-function-size: 14
  • readability-static-definition-in-anonymous-namespace: 14
  • bugprone-branch-clone: 12
  • modernize-return-braced-init-list: 11
  • cppcoreguidelines-special-member-functions: 8
  • readability-isolate-declaration: 8
  • readability-container-size-empty: 7
  • modernize-use-starts-ends-with: 7
  • modernize-use-ranges: 6
  • readability-redundant-casting: 5
  • readability-redundant-access-specifiers: 5
  • readability-inconsistent-declaration-parameter-name: 5
  • readability-container-contains: 5
  • modernize-use-emplace: 4
  • modernize-use-std-numbers: 3
  • readability-else-after-return: 2
  • modernize-use-integer-sign-comparison: 2
  • performance-avoid-endl: 2
  • readability-redundant-string-init: 1
  • modernize-redundant-void-arg: 1
  • performance-move-const-arg: 1
  • modernize-make-shared: 1
  • readability-simplify-boolean-expr: 1
  • readability-use-anyofallof: 1

See inline comments for details. Comment @phlexbot tidy-fix to auto-fix.

@knoepfel knoepfel added this to the Prototype 0.3 milestone Jun 24, 2026
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.

4 participants