-
Notifications
You must be signed in to change notification settings - Fork 1
Object-oriented programming Refactor for CodeEntropy #88
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
- Replaced legacy procedural modules with a modular, object-oriented structure - Introduced core classes: `RunManager`, `LevelManager`, `EntropyManager` with subclasses of `VibrationalEntropy`, `ConformationalEntropy`, `OrientationalEntropy` - Implemented dependency injection for improved testability and modularity - Encapsulated configuration, logging, and data management into dedicated components - Added `@property` accessors and private attributes for better encapsulation - Removed legacy function-based modules under `CodeEntropy/calculations/` - Added new entry point via `main.py` using `RunManager` orchestration
- Imports now reflect the new file, class and function locations - Renamed test file names to follow the same structure as the project directory file names - Moved all of the current entropy tests into a single file seperated in classes by the type of entropy
- Broke down `EntropyManager.execute()` into smaller private methods for readability and maintainability - Added docstrings to new helper methods and existing class methods - No changes to core logic; behavior remains the same
- Added a test to verify that the logging level is set to DEBUG when the verbose flag is provided - Added a test to ensure that invalid argument types raise appropriate errors in the argument parsing logic
- Added a test to verify that the `init` function is correctly set up - Added a test to ensure that results are added correctly - Added a test to ensure the dataframes are saved to `JSON` files correctly - Added a test to ensure the `log_tables` are formatted as expected
…in consistency with naming conventions across the codebase
- Test case to simulate a successful and unsuccessful runs - Removal of existing test cases as they are not fit for purpose with the new OOP structure
- Testing the log directory creation - Testing the logger instantiation and return value - Testing that the expected log files are created - Testing that the logger is able to dynacmically change - Testing the MDAnalysis and command logger configuration
- Additional tests to cover the creation of the folders - Test to ensure a job folder is created when the directory is empty - Test to ensure the correct job folder is created if there are existing folders - Test to ensure job folder is created correctly when non job folders are present - Test to ensure job folder is created with mixed job folders and other folders - Test to ensure job folders with the wrong suffix are ignored
jimboid
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.
A solid refactor with tests for the vast majority of the new code and its flow. There remains some areas such as levels, entropy and run modules with low test coverage, but these will be dealt with later as they require more specialist testing.
The code looks to be have all of the right parts in the correct places, happy to approve this.
I did raise in the review the possibility of structuring the levels like the entropy class as a series of subclasses with a base for common code to avoid the checking for which level is being dealt with, but this is should not block this PR, mainly for us to discuss later as there may be reasons why this is not simple to do.
Well done on getting this out of the door Harry!
|
One detail - in the doc strings in entropy.py. For results_df it should be """Returns the dataframe containing entropy results at all levels.""" and for residue_results it should be """Returns the dataframe containing united-atom level results for each residue.""" |
…` to ensure correctness
Summary
This PR introduces a major refactor of the CodeEntropy project, transitioning the codebase to a modular, object-oriented architecture. Alongside the structural updates, I've expanded and reorganized the test suite, pull in a key bug fix in trajectory slicing, and pulled in upstream changes to stay aligned with recent work in
main.Changes
Migrated CodeEntropy to an Object-Oriented Design
RunManagerfor handling the entire run lifecycle.LevelManagerfor managing energy levels and states.EntropyManagerwith specialized subclasses:VibrationalEntropy,ConformationalEntropy, andOrientationalEntropy.@propertydecorators.CodeEntropy/calculations/.Refactored
EntropyManager.execute()for Readabilityexecute()method into smaller, focused helper functions.Restructured and Expanded Tests
test_EntropyFunctionstotest_CodeEntropyto better match project structure.Added Tests for
main.pyExecution LogicEnhanced Coverage for
data_logger.pylog_tablesare formatted correctly.Strengthened Tests for
arg_config_manager.pyDEBUGwhen--verboseis passed.Fixed Off-by-One Error in Trajectory Slicing
986c314.Synced with PR #87 for Config Manager Updates
arg_config_manager.pyfrom PR Fixing an off by one indexing error when slicing trajectories. #87 (commitbdb09c7) to ensure consistency with upstream development.Impact