Skip to content

fix: defer params functions touching named input of incomplete expansion - #4331

Open
barlowa124 wants to merge 1 commit into
snakemake:mainfrom
barlowa124:fix/unpack-checkpoint-params
Open

barlowa124 wants to merge 1 commit into
snakemake:mainfrom
barlowa124:fix/unpack-checkpoint-params

Conversation

@barlowa124

@barlowa124 barlowa124 commented Oct 3, 2026 •

Copy link
Copy Markdown

Closes #4312.

When a checkpoint-resolving input function returns named inputs via
unpack(), a params function that reads one of those names fails.
Parameter evaluation happens during DAG construction (in this case via
collect_envs -> software_env_spec), while the job input still
carries only the checkpoint placeholder. The injected InputFiles
does not yet have the names, so AttributeError propagates.

This mirrors the FileNotFoundError deferral already used for
input-dependent functions: while the job's input expansion is
incomplete, a missing-name AttributeError on the injected lists
resolves to <TBD>. After the checkpoint runs and the job is
replaced, the parameter resolves normally on re-evaluation.

Coverage: tests/test_github_issue4312 reproduces the reported
AttributeError on unpatched code.

QC

  • The PR contains a test case for the changes or the changes are already covered by an existing test case.
  • The documentation (docs/) is updated to reflect the changes or this is not necessary (e.g. if the change does neither modify the language nor the behavior or functionalities of Snakemake).
  • I, as a human being, have checked each line of code in this pull request

AI-assistance disclosure

I used AI assistance for the categories checked below.

  • Code generation (e.g., when writing an implementation or fixing a bug)
  • Test/benchmark generation
  • Documentation (including examples)
  • Research and understanding

An input function that resolves a checkpoint and returns a dict of
named inputs crashes the workflow when a params function accesses
such a name. Params are evaluated while the job input still holds
only the checkpoint placeholder, so the names do not exist yet.

Treat a missing-name AttributeError on the injected named lists the
same as a FileNotFoundError on injected input files when the job's
input expansion is incomplete. The parameter becomes <TBD> and is
re-evaluated once the checkpoint has run and the job is updated.
@coderabbitai

coderabbitai Bot commented Oct 3, 2026 •

Copy link
Copy Markdown
Contributor

Review in Change Stack →

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration
  • Configuration used: Organization UI
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: a438284e-e6f8-44c5-97d8-6ec3ebff2f40

📥 Commits

Reviewing files that changed from the base of the PR and between 5bf5e21 and 79d805e.


📒 Files selected for processing (4)
  • src/snakemake/rules.py
  • tests/test_github_issue4312/Snakefile
  • tests/test_github_issue4312/expected-results/d
  • tests/tests.py

Included review availability: This review used your included allowance. Your plan provides up to 8 included reviews per hour; 7 remain after this review.



📝 Walkthrough

Walkthrough

Parameter input functions now receive the job’s incomplete input expansion state. Qualifying AttributeErrors involving a Namedlist return a TBDString. A regression test covers accessing a named input from an unpacked checkpoint in a parameter function.

Changes

Checkpoint parameter expansion

Layer / File(s) Summary
Handle incomplete input expansion
src/snakemake/rules.py
Rule.expand_params passes the job’s incomplete input expansion state to parameter input functions. Rule.apply_input_function returns a TBDString for qualifying AttributeErrors.
Test unpacked checkpoint inputs
tests/test_github_issue4312/Snakefile, tests/test_github_issue4312/expected-results/d, tests/tests.py
The regression fixture creates checkpoint files, uses them as named inputs, and accesses one in a parameter function. The test checks the expected output.

Priority: ⬇️ Low

Estimated code review effort: 2 (Simple) | ~10 minutes

Change: Bug fix · Severity of issue fixed: Low


Merge Risk: ⚪ Minimal · up to 79d80

Checkpoint-dependent params are reevaluated after the checkpoint provides the named inputs. No actionable merge risk remains beyond normal checks.

Pre-merge checks | Passed 4 | Failed 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 6 functions across 2 files. (2 skipped: 2 … Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Linked Issues check Passed Issue #4312 requires named inputs returned from a checkpoint input function and exposed with unpack() to be accessible in a params function. Rule.apply_input_function now defers a missing-name `At…
Out of Scope Changes check Passed The reported changes are limited to deferring parameter evaluation for incomplete checkpoint input expansion and adding its regression test and expected output. These changes directly support issue #4…
Title check Passed The title clearly and concisely describes the main change: deferring parameter functions that access named inputs during incomplete expansion.
Description check Passed The description explains the bug, implementation approach, expected behavior, test coverage, documentation decision, human review, and AI assistance. It follows the repository template.

Full details: Docstring Coverage

Explanation

Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 6 functions across 2 files. (2 skipped: 2 unsupported.)


  • Fix all pre-merge checks with AI
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create a new PR

  • Autopilot · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

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

@barlowa124
barlowa124 marked this pull request as ready for review October 6, 2026 19:04
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.

unpacking a checkpoint gives AttributeError: 'InputFiles' object has no attribute ... in params function

1 participant