Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Conversation

@yunzheng
Copy link
Member

All record reader adapters now utilize an AppContext to track metrics such as the number of records read, matched, and excluded.

This context is accessible via flow.record.context.get_app_context().

The progress bar in rdump has been updated to display these metrics.

@codecov
Copy link

codecov bot commented Aug 18, 2025

Codecov Report

❌ Patch coverage is 90.55118% with 12 lines in your changes missing coverage. Please review.
✅ Project coverage is 83.35%. Comparing base (c3447bd) to head (55c91fb).
⚠️ Report is 1 commits behind head on main.

Files with missing lines Patch % Lines
flow/record/adapter/mongo.py 0.00% 4 Missing ⚠️
flow/record/adapter/elastic.py 25.00% 3 Missing ⚠️
flow/record/adapter/xlsx.py 25.00% 3 Missing ⚠️
flow/record/tools/rdump.py 96.36% 2 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main     #184      +/-   ##
==========================================
+ Coverage   83.07%   83.35%   +0.28%     
==========================================
  Files          34       35       +1     
  Lines        3609     3718     +109     
==========================================
+ Hits         2998     3099     +101     
- Misses        611      619       +8     
Flag Coverage Δ
unittests 83.35% <90.55%> (+0.28%) ⬆️

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

☔ View full report in Codecov by Sentry.
📢 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.

@yunzheng
Copy link
Member Author

This PR improves the progress bar to show other metrics that were normally not available due to the limitation of record_stream. Every RecordReader adapter has been updated to track these metrics via the AppContext, which is a ContextVar.

The updating of the progress bar now also happens via a thread that periodically reads the AppContext. Progress bar now looks like this:

Processed: 119619 records [00:03, 30231.59 records/s, source=1/1, read=119619, matched=119619, excluded=0] 

It shows how many records have been processed/read and how many have matched the selector, and how many have been excluded by the selector. I'm not so sure about the naming of matched and excluded, suggestions are welcome.

@yunzheng yunzheng requested a review from Copilot August 18, 2025 21:44
Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull Request Overview

This PR adds an AppContext for tracking record reader metrics throughout the flow record processing pipeline. The context tracks records read, matched, and excluded counts, enabling better progress reporting and statistics.

Key Changes

  • Introduces AppContext class for tracking record processing metrics
  • Updates all record adapters to utilize the context for metric tracking
  • Enhances rdump tool's progress bar to display detailed metrics

Reviewed Changes

Copilot reviewed 14 out of 14 changed files in this pull request and generated 2 comments.

Show a summary per file
File Description
flow/record/context.py New context module with AppContext class and helper functions
flow/record/stream.py Updates RecordReader to track metrics in app context
flow/record/tools/rdump.py Enhanced progress bar with detailed metrics display
flow/record/adapter/*.py Updates all adapters to track metrics via app context
tests/conftest.py Test fixture to reset app context between tests
tests/record/test_context.py Comprehensive tests for app context functionality
tests/tools/test_rdump.py Updated tests for new progress bar format
tests/test_regressions.py Test updates to accommodate new context behavior

Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.

@yunzheng yunzheng changed the title Add AppContext for tracking record reader metrics Improve progress bar by tracking record metrics Aug 19, 2025
@yunzheng
Copy link
Member Author

Also still contemplating if I should change ctx.excluded to ctx.unmatched. As during development I kept forgetting what the exact attribute name was.

@yunzheng yunzheng force-pushed the feature/improved-progress-bar branch from 8c06419 to 7edcb8d Compare August 21, 2025 08:28
All record reader adapters now utilize an `AppContext` to track metrics
such as the number of records read, matched, and excluded.

This context is accessible via `flow.record.context.get_app_context()`.

The progress bar in `rdump` has been updated to display these metrics.
This helper function matches the record against given selector, and updates metrics in the context.
- The `ctx.read += 1` now happens in the helper function
- Renamed ctx.excluded to ctx.unmatched
@yunzheng yunzheng force-pushed the feature/improved-progress-bar branch from 1956df3 to 2f96e95 Compare August 21, 2025 15:35
@yunzheng yunzheng merged commit 9daa5c9 into main Sep 1, 2025
25 checks passed
@yunzheng yunzheng deleted the feature/improved-progress-bar branch September 1, 2025 14:48
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.

3 participants