Skip to content

[RunInference] Honor model updates in also in the first batch. - #40667

Open
tvalentyn wants to merge 4 commits into
apache:masterfrom
tvalentyn:model_updates
Open

tvalentyn wants to merge 4 commits into
apache:masterfrom
tvalentyn:model_updates

Conversation

@tvalentyn

@tvalentyn tvalentyn commented Oct 19, 2026 •

Copy link
Copy Markdown
Contributor
  1. Honor model updates in first batch.

  2. Don't initiate load model calls when there are no updates. In another branch, do an update if the model was invalidated.

  3. Drive-by entries to changes.md from earlier PRs.

Fixes: #40665

@github-actions github-actions Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

📋 Review Summary

This PR resolves a bug (#40665) where RunInference with per-key models (KeyedModelHandler) failed to apply KeyModelPathMapping side-input updates on the first batch when load_model_at_runtime=True. It also avoids redundant update_model calls on every batch when the side input is empty or the per-key model path mapping has not changed.

🔍 General Feedback

  • The fix in _RunInferenceDoFn._load_model and process is clean, well-tested, and properly addresses both the first-batch stale model bug and redundant update_model invocations.
  • One minor edge case was noted in process when using ModelMetadata side inputs together with timeout-based model invalidation, along with a minor CHANGES.md template placeholder removal.

💡 Tip: Comment /gemini review on this pull request to trigger a new Gemini code review.

Comment thread sdks/python/apache_beam/ml/inference/base.py Outdated
Comment thread CHANGES.md
@tvalentyn

Copy link
Copy Markdown
Contributor Author

/gemini review

@github-actions github-actions Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

📋 Review Summary

This PR fixes a bug (#40665) where RunInference with per-key models (KeyedModelHandler) failed to apply KeyModelPathMapping side-input updates on the first batch when load_model_at_runtime=True. It also prevents redundant update_model calls on every batch when side inputs are empty or unchanged, while properly handling model reloading across all branches when a model is marked invalid.

🔍 General Feedback

  • The updates in _RunInferenceDoFn._load_model and _RunInferenceDoFn.process are clean, consistent across all side-input branches, and well-covered by the new unit tests.

💡 Tip: Comment /gemini review on this pull request to trigger a new Gemini code review.

@codecov

codecov Bot commented Oct 19, 2026 •

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 80.02%. Comparing base (76f6e6d) to head (3cc35f6).
⚠️ Report is 240 commits behind head on master.

Additional details and impacted files
@@              Coverage Diff              @@
##             master   #40667       +/-   ##
=============================================
+ Coverage     56.16%   80.02%   +23.85%     
=============================================
  Files          1124      490      -634     
  Lines        178336    82810    -95526     
  Branches       1489        0     -1489     
=============================================
- Hits         100170    66267    -33903     
+ Misses        75645    16543    -59102     
+ Partials       2521        0     -2521     
Flag Coverage Δ
go ?
java ?
python 80.02% <100.00%> (+0.46%) ⬆️

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.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@github-actions

Copy link
Copy Markdown
Contributor

Assigning reviewers:

R: @jrmccluskey for label python.
Backup reviewer: damccorm (if the main reviewer is unresponsive, you can escalate to them by tagging their username)

Note: If you would like to opt out of this review, comment assign to next reviewer.

Available commands:

  • stop reviewer notifications - opt out of the automated review tooling
  • remind me after tests pass - tag the comment author after tests pass
  • waiting on author - shift the attention set back to the author (any comment or push by the author will return the attention set to the reviewers)

The PR bot will only process comments in the main thread (not review comments).

@github-actions
github-actions Bot requested a review from jrmccluskey October 19, 2026 21:14
@tvalentyn tvalentyn changed the title Model updates [RunInference] Honor model updates in also in the first batch. Oct 19, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Bug]: [RunInference] When load_model_at_runtime=True, the first batch always ignores model side-input updates.

1 participant