Skip to content

Conversation

@lpi-tn
Copy link
Collaborator

@lpi-tn lpi-tn commented Nov 24, 2025

This pull request adds support for a strict mode to the compute_duration and compute_readability functions, allowing callers to force recomputation of metadata even if values already exist. It also introduces comprehensive tests for these behaviors to ensure correctness.

Enhancements to metadata computation:

  • Added a strict boolean parameter to both compute_duration and compute_readability in welearn_datastack/modules/computed_metadata.py, enabling forced recomputation of duration and readability scores when set to True.
  • Updated the logic in these functions so that, if strict is False and a value is already present in document.details, the original value is retained.

Testing improvements:

  • Added new unit tests in tests/test_computed_metadata.py to cover both strict and non-strict behaviors for duration and readability computation, verifying that values are correctly overwritten or preserved based on the strict flag.
  • Added tests to confirm that estimated reading time and readability scores are correctly set when no prior value exists.

Copy link
Contributor

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 introduces a strict mode parameter to the compute_duration and compute_readability functions, allowing callers to control whether existing metadata values should be recomputed or preserved.

Key Changes:

  • Added optional strict boolean parameter (default False) to both metadata computation functions
  • Implemented early return logic to preserve existing values when strict=False
  • Added comprehensive test coverage for strict and non-strict behaviors

Reviewed changes

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

File Description
welearn_datastack/modules/computed_metadata.py Added strict parameter and conditional logic to compute_duration and compute_readability functions with documentation
tests/test_computed_metadata.py Added six new test cases covering strict mode, non-strict mode, and initial value setting for both functions

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@lpi-tn lpi-tn merged commit 41522bc into main Nov 24, 2025
7 checks passed
@lpi-tn lpi-tn deleted the Fix/computed_metadata branch November 24, 2025 15:46
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