Implement lazy directives for Ramble - #1756
Conversation
There was a problem hiding this comment.
Code Review
This pull request refactors Ramble's directive system to support lazy evaluation of directives upon first access using a new DirectiveDictDescriptor descriptor. It removes the need for explicit class-to-instance attribute conversion and updates various base classes to use DirectiveMeta directly as their metaclass. Additionally, comprehensive tests are added to verify lazy evaluation, inheritance, and attribute isolation. The review feedback highlights a critical issue where instance-level modifications to these lazily evaluated directive dictionaries would be lost during cloning or copying. It is recommended to dynamically copy all evaluated directive dictionaries from self.__dict__ to the cloned or copied instances in both ApplicationBase.clone() and ObjectMixin.copy().
Ramble Performance Test MetricsResults produced with commit: 2b398d1
|
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## develop #1756 +/- ##
===========================================
+ Coverage 94.07% 94.08% +0.01%
===========================================
Files 370 370
Lines 37399 37554 +155
===========================================
+ Hits 35182 35333 +151
- Misses 2217 2221 +4 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
|
/gemini review |
There was a problem hiding this comment.
Code Review
This pull request refactors Ramble's directive system to support lazy evaluation on first access, introducing the DirectiveDictDescriptor class and removing the eager conversion of class attributes to instance attributes across all base classes. A comprehensive test suite has been added to verify lazy evaluation, inheritance, and isolation. The review feedback highlights critical inheritance issues where using getattr on classes or objects can mistakenly retrieve parent class attributes (such as evaluated directive dictionaries or preferred versions) instead of checking the subclass's own __dict__ directly, which would bypass subclass directive execution or raise incorrect errors.
1fadb66 to
87a882c
Compare
|
/gemini review |
This is inspired by Spack's lazy directive (spack/spack#51881). * Add in the dict descriptor (as a non-data descriptor) to support the lazy initiailization * Remove the `convert_class_attributes` since now the lazy execution allows us to perform copy on first access * Update the various directives to support the new semantics. Specifically, it now requires listing out all mutated dicts of a directive * Also unify the various language meta directives, so now they are all essentially DirectiveMeta * Update the mirror test since before it implicitly relied on the mutation happening both at the class and the instance level Signed-off-by: Lin Guo <linsword13@gmail.com>
Signed-off-by: Lin Guo <linsword13@gmail.com>
87a882c to
7efbad1
Compare
Signed-off-by: Lin Guo <linsword13@gmail.com>
7efbad1 to
2b398d1
Compare
|
/gemini review |
This is inspired by Spack's lazy directive (spack/spack#51881).
convert_class_attributessince now the lazy execution allows us to perform copy on first access