- Removed the existing `validation.py` file and replaced it with a modular structure, introducing separate files for validation results, field validators, and the base validator class. - Implemented comprehensive validation functions for common data types, enhancing reusability and maintainability. - Added a new `__init__.py` to expose the validation utilities, ensuring a clean public interface. - Created detailed documentation for the validation module, including usage examples and architectural details. - Introduced extensive unit tests to cover the new validation framework, ensuring reliability and preventing regressions. These changes enhance the overall architecture of the data validation module, making it more scalable and easier to manage.
3.6 KiB
3.6 KiB
Relevant Files
data/common/aggregation.py- To be broken into a sub-package.data/common/indicators.py- To be broken into a sub-package and have a bug fixed.data/common/validation.py- To be refactored for better modularity.data/common/transformation.py- To be refactored for better modularity.data/common/data_types.py- To be updated with new types from other modules.data/common/__init__.py- To be updated to reflect the new package structure.tests/- Existing tests will need to be run after each step to ensure no regressions.
Notes
- This refactoring focuses on improving modularity by splitting large files into smaller, more focused modules, as outlined in the
refactoring.mdcguide. - Each major step will be followed by a verification phase to ensure the application remains stable.
Tasks
-
1.0 Refactor
aggregation.pyinto a dedicated sub-package.- 1.1 Create safety net tests to ensure the aggregation logic still works as expected.
- 1.2 Create a new directory
data/common/aggregation. - 1.3 Create
data/common/aggregation/__init__.pyto mark it as a package. - 1.4 Move the
TimeframeBucketclass todata/common/aggregation/bucket.py. - 1.5 Move the
RealTimeCandleProcessorclass todata/common/aggregation/realtime.py. - 1.6 Move the
BatchCandleProcessorclass todata/common/aggregation/batch.py. - 1.7 Move the utility functions to
data/common/aggregation/utils.py. - 1.8 Update
data/common/aggregation/__init__.pyto expose all public classes and functions. - 1.9 Delete the original
data/common/aggregation.pyfile. - 1.10 Run tests to verify the aggregation logic still works as expected.
-
2.0 Refactor
indicators.pyinto a dedicated sub-package.- 2.1 Create safety net tests for indicators module.
- 2.2 Create a new directory
data/common/indicators. - 2.3 Create
data/common/indicators/__init__.pyto mark it as a package. - 2.4 Move the
TechnicalIndicatorsclass todata/common/indicators/technical.py. - 2.5 Move the
IndicatorResultclass todata/common/indicators/result.py. - 2.6 Move the utility functions to
data/common/indicators/utils.py. - 2.7 Update
data/common/indicators/__init__.pyto expose all public classes and functions. - 2.8 Delete the original
data/common/indicators.pyfile. - 2.9 Run tests to verify the indicators logic still works as expected.
-
3.0 Refactor
validation.pyfor better modularity.- 3.1 Create safety net tests for validation module.
- 3.2 Extract common validation logic into separate functions.
- 3.3 Improve error handling and validation messages.
- 3.4 Run tests to verify validation still works as expected.
-
4.0 Refactor
transformation.pyfor better modularity.- 4.1 Create safety net tests for transformation module.
- 4.2 Extract common transformation logic into separate functions.
- 4.3 Improve error handling and transformation messages.
- 4.4 Run tests to verify transformation still works as expected.
-
5.0 Update
data_types.pywith new types.- 5.1 Review and document all data types.
- 5.2 Add any missing type hints.
- 5.3 Add validation for data types.
- 5.4 Run tests to verify data types still work as expected.
-
6.0 Final verification and cleanup.
- 6.1 Run all tests to ensure no regressions.
- 6.2 Update documentation to reflect new structure.
- 6.3 Review and clean up any remaining TODOs.
- 6.4 Create PR with changes.