Skip to content

Refactor grain_data_processing_test and improve time#3918

Open
aireenmei wants to merge 1 commit into
mainfrom
aireen/shorten_data_tests
Open

Refactor grain_data_processing_test and improve time#3918
aireenmei wants to merge 1 commit into
mainfrom
aireen/shorten_data_tests

Conversation

@aireenmei
Copy link
Copy Markdown
Collaborator

@aireenmei aireenmei commented May 15, 2026

Description

As data pipeline unit tests in grain_data_processing_test.py grow, it take a lot of time from the CI runner. The base test includes three tests: test_train_ds, test_batch_determinism, test_for_loop_repeatable. And all the variants inherit these three test. Since it's unlikely for the config variants to change the determinism and for_loop_repeatable behavior, this PR refactor introduces _Grain{format}Setup, GrainBaseProcessingTest, GrainDeterminismMixin class, and have the config variant test only inherit _Grain{format}Setup and GrainBaseProcessingTest to reduce the time for running determinism tests.

Tests

When running locally (CI runner time will be different but expect similar percentage)
Before this PR, all tests in grain_data_processing_test.py takes 7:08 min, log
After this PR, all tests in grain_data_processing_test.py takes 4:15 min, log

Checklist

Before submitting this PR, please make sure (put X in square brackets):

  • I have performed a self-review of my code. For an optional AI review, add the gemini-review label.
  • I have necessary comments in my code, particularly in hard-to-understand areas.
  • I have run end-to-end tests tests and provided workload links above if applicable.
  • I have made or will make corresponding changes to the doc if needed, including adding new documentation pages to the relevant Table of Contents (toctree directive) as explained in our documentation.

@github-actions
Copy link
Copy Markdown

🤖 Hi @aireenmei, I've received your request, and I'm working on it now! You can track my progress in the logs for more details.

Copy link
Copy Markdown

@github-actions github-actions Bot left a comment

Choose a reason for hiding this comment

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

## 📋 Review Summary

This PR successfully refactors grain_data_processing_test.py to improve test execution time. By introducing specialized mixins for setup and determinism, it avoids redundant and expensive checks in variant subclasses while actually increasing the validation depth for the primary format tests.

🔍 General Feedback

  • Refactoring Quality: The use of GrainDeterminismMixin and private setup mixins like _GrainArrayRecordSetup is a clean architectural improvement that makes the test suite more modular and maintainable.
  • Coverage: The addition of auxiliary tensor checks in the determinism tests is a proactive improvement to the overall test quality.
  • Performance: This change should significantly reduce the time spent in grain_data_processing_test.py during CI runs by eliminating redundant test_batch_determinism and test_for_loop_repeatable calls in specialized variant tests.

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

🟢 This is a solid refactoring. Moving the determinism tests into a separate mixin (GrainDeterminismMixin) and setup logic into format-specific mixins (_GrainArrayRecordSetup, _GrainTFRecordSetup) effectively reduces redundant test execution in variant subclasses, which will significantly improve CI performance.

@codecov
Copy link
Copy Markdown

codecov Bot commented May 15, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.

📢 Thoughts on this report? Let us know!

@aireenmei aireenmei force-pushed the aireen/shorten_data_tests branch 2 times, most recently from b3ec285 to 6c2949e Compare May 15, 2026 21:26
@aireenmei aireenmei changed the title Improve time for grain_data_processing_test Refactor grain_data_processing_test and improve time May 15, 2026
@aireenmei aireenmei marked this pull request as ready for review May 15, 2026 21:33
super().setUpClass()

def setUp(self):
"""common setup for ArrayReord format"""
Copy link
Copy Markdown
Collaborator

@SurbhiJainUSC SurbhiJainUSC May 15, 2026

Choose a reason for hiding this comment

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

nit: Common and ArrayRecord

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

Fixed. Thanks for catching

@aireenmei aireenmei force-pushed the aireen/shorten_data_tests branch from 6c2949e to 1ab5b5b Compare May 15, 2026 21:48
@aireenmei aireenmei force-pushed the aireen/shorten_data_tests branch from 1ab5b5b to feaf467 Compare May 15, 2026 21:49
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.

2 participants