Skip to content

Detect kernel dependencies imported via 'from x_kernels import func' - #661

Merged
max-models merged 1 commit into
develfrom
fix-undetected-dependencies
Oct 2, 2026
Merged

max-models merged 1 commit into
develfrom
fix-undetected-dependencies

Conversation

@spossann

@spossann spossann commented Oct 2, 2026

Copy link
Copy Markdown
Member

Problem

struphy compile -j N failed at random in CI, e.g. in this job, while another shard of the same run with the same packages passed:

pyccel: |fatal [syntactic]: .../struphy/pic/accumulation/particle_to_mat_kernels.py| Imported files must be pyccelised before they can be used. (struphy.bsplines.evaluation_kernels_3d)

dependencies.py only counted from a.b import c as a dependency when c is a module. particle_to_mat_kernels.py does from struphy.bsplines.evaluation_kernels_3d import get_spans, a function, so make had no prerequisite on evaluation_kernels_3d.so. Whether it was built first depended on how make scheduled the parallel jobs.

Kernels affected: particle_to_mat_kernels, accum_kernels, pusher_utilities_kernels.

Fix

  • dependencies.py: if the imported name c in from a.b import c is not a module, then a.b itself is a dependency.
  • test_compile.py:
    • test_dependencies_static_rules now expects from struphy.pkg.h_kernels import some_function to give a dependency.
    • The import-based reference in test_dependencies_match_import_based_result now also collects the __module__ of imported functions and classes, compiled kernels included.

Testing

  • All 11 tests in src/struphy/console/tests/test_compile.py pass, including the cycle check.
  • After struphy compile -d, struphy compile -j 4 built all 56 kernels locally.
    • particle_to_mat_kernels now lists evaluation_kernels_3d among its dependencies.
    • evaluation_kernels_3d was built before all three affected kernels.

🤖 Generated with Claude Code

get_dependencies only counted "from a.b import c" as a dependency when c
is a module. Kernels importing a function from another kernel, e.g.
"from struphy.bsplines.evaluation_kernels_3d import get_spans", therefore
had no make prerequisite on it, and "struphy compile -j N" could fail
with "Imported files must be pyccelised before they can be used",
depending on the build order.

Affected: particle_to_mat_kernels, accum_kernels, pusher_utilities_kernels.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@spossann
spossann requested a review from max-models October 2, 2026 11:11

@max-models max-models left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

This makes sense.

@max-models
max-models merged commit d6e64d8 into devel Oct 2, 2026
30 checks passed
@max-models
max-models deleted the fix-undetected-dependencies branch October 2, 2026 12:23
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.

2 participants