-
Notifications
You must be signed in to change notification settings - Fork 1
Allow for regenerating test data for patched examples + tidy-ups #1081
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
These are hidden from the help as ordinary users shouldn't need them.
This makes it consistent with the `just` command.
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #1081 +/- ##
=======================================
Coverage 82.26% 82.27%
=======================================
Files 53 55 +2
Lines 7416 7487 +71
Branches 7416 7487 +71
=======================================
+ Hits 6101 6160 +59
- Misses 1025 1029 +4
- Partials 290 298 +8 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
There was a problem hiding this 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 enables regenerating test data for patched examples and includes refactoring improvements. The main motivation is to allow regeneration of test data for patched example models (like simple_divisible) that are used in tests.
Changes:
- Added a
--patchflag to theexamplesubcommands (list, extract, run) to support patched examples - Refactored example-related code into a new
examplemodule with apatchessubmodule - Updated the test data regeneration script to support specifying individual models and patched examples
- Simplified the
run_regression_test_with_patchesfunction signature by retrieving patches from the centralized location
Reviewed changes
Copilot reviewed 10 out of 10 changed files in this pull request and generated 4 comments.
Show a summary per file
| File | Description |
|---|---|
src/lib.rs |
Added new example module export |
src/example.rs |
New module containing refactored code for working with example models |
src/example/patches.rs |
New module centralizing patch definitions for test cases |
src/cli/example.rs |
Updated to use refactored example module and added --patch flag support |
tests/regression.rs |
Updated to use centralized patch retrieval from example::patches |
tests/regression_simple_divisible.rs |
Simplified test function and renamed to match test case name |
tests/regenerate_test_data.sh |
New script replacing old one, with support for selective model regeneration and patched examples |
tests/regenerate_all_data.sh |
Removed (replaced by new script) |
justfile |
Updated to pass arguments to regenerate script |
docs/developer_guide/architecture_quickstart.md |
Added documentation about regenerating data for specific models and patched examples |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
|
|
||
| if [ "$1" = --patch ]; then | ||
| shift 1 | ||
| patch_examples=$@ |
Copilot
AI
Jan 15, 2026
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The variable assignment should use quotes around $@ to properly handle arguments with spaces. Change to patch_examples=\"$@\".
| patch_examples=$@ | |
| patch_examples="$@" |
| patch_examples=$@ | ||
| elif [ $# -gt 0 ]; then | ||
| examples=$@ |
Copilot
AI
Jan 15, 2026
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The variable assignment should use quotes around $@ to properly handle arguments with spaces. Change to examples=\"$@\".
| patch_examples=$@ | |
| elif [ $# -gt 0 ]; then | |
| examples=$@ | |
| patch_examples="$@" | |
| elif [ $# -gt 0 ]; then | |
| examples="$@" |
| new_path.display() | ||
| ); | ||
| // NB: All patched models are based on `simple`, for now | ||
| let example = Example::from_name("simple").unwrap(); |
Copilot
AI
Jan 15, 2026
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Using unwrap() here assumes that the 'simple' example always exists. Since this is a hardcoded value and the comment on line 106 indicates this is intentional, consider using expect() with a descriptive message to make the assumption explicit, e.g., expect(\"'simple' example must exist as base for all patched models\").
| let example = Example::from_name("simple").unwrap(); | |
| let example = Example::from_name("simple") | |
| .expect("'simple' example must exist as base for all patched models"); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No, this should be fine as the simple example should always be present.
That said, there should probs be a test for this function instead.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull request overview
Copilot reviewed 10 out of 10 changed files in this pull request and generated 3 comments.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| @@ -0,0 +1,49 @@ | |||
| #!/bin/sh | |||
| set -ef | |||
Copilot
AI
Jan 15, 2026
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The shell option -e will cause the script to exit on error, but -f is not a valid POSIX shell option. You likely meant -eu (exit on error and treat unset variables as errors). The -f option disables filename globbing which is rarely the intended behavior for scripts like this.
| set -ef | |
| set -eu |
| new_path.display() | ||
| ); | ||
| // NB: All patched models are based on `simple`, for now | ||
| let example = Example::from_name("simple").unwrap(); |
Copilot
AI
Jan 15, 2026
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hard-coding 'simple' as the base example creates a hidden coupling between patch definitions and this code. If a patch is added that's based on a different example, this will silently use the wrong base. Consider storing the base example name alongside each patch in the PATCHES map, or adding validation that ensures all patches are actually based on 'simple'.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It'll take more changes than that, see #1080
35c0d19 to
d4a8f51
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull request overview
Copilot reviewed 10 out of 10 changed files in this pull request and generated 1 comment.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
tsmbland
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM!
| /// Get all patches | ||
| fn get_all_patches() -> PatchMap { | ||
| [( | ||
| "simple_divisible", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think we'd want a short comment for what each patch represents/what functionality it's testing. Just an inline comment is probably fine for now, but if we have loads of patches it might be neater to define each with a function rather than just listing them all out in a vec. I could also imagine something more complex whereby the description can be printed with muse2 example info and saved to the README with muse2 example extract, but that's probably not necessary.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That's a good idea. I'll add a comment.
We might want to house the patches in a struct when we do #1080 at which point we could stick an info field in there too.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull request overview
Copilot reviewed 10 out of 10 changed files in this pull request and generated no new comments.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Description
You currently can't regenerate test data for the patched examples used by tests. For now, there's just
simple_divisible, but there will be more in future, so it seemed worth fixing.I've fixed it by changing things so that you can pass a
--patchflag to a few of theexamplesubcommands, so that we can list and run them in the script. This option is hidden from the program help, as it's aimed at developers. In the long run, I'd like to unify the code paths used by the regression test code and the CLI code to do the patching etc., but I think we should do the refactoring for #1080 first.Other changes:
examplemoduleFixes #1077.
Type of change
Key checklist
$ cargo test$ cargo docpresent in the previous release
Further checks