refactor: extract ModelFeatureFactory from GeologicalModel - #308
Merged
lachlangrose merged 1 commit intoAug 14, 2026
Conversation
This was referenced Aug 14, 2026
stack merge was automatically disabled
August 14, 2026 11:29
Pull Request is not mergeable
Move the seven _build_* feature-construction methods (foliation, fold frame, folded foliation, folded fold frame, intrusion, domain fault, fault) -- collectively ~1000 lines, the largest remaining chunk of GeologicalModel -- into a standalone ModelFeatureFactory. The FeatureBuilderRegistry wiring at the bottom of geological_model.py now dispatches to ModelFeatureFactory.build_* instead of the removed private methods. Public create_and_add_* wrappers are unchanged; their docstring cross-references are updated to point at the new factory location. geological_model.py drops from 2579 to 1505 lines. (cherry picked from commit 068d93b)
lachlangrose
force-pushed
the
split/09-extract-model-feature-factory
branch
from
August 14, 2026 11:29
b3aad97 to
6530cd7
Compare
lachlangrose
added a commit
that referenced
this pull request
Aug 17, 2026
* fix: Updating intrusions code - Added a new method `_validate_intrusion_inputs` in `GeologicalModel` to validate inputs for intrusions, ensuring necessary data is present before processing. - Updated `_build_intrusion` to call the new validation method, improving error handling for missing data. - Refactored `IntrusionBuilder.create_geometry_using_geometric_scaling` to clarify that geometric scaling is not currently implemented, raising a `NotImplementedError` immediately. - Simplified threshold handling in `IntrusionFeature` by removing redundant checks for marginal faults. - Removed the unused `intrusion_support_functions.py` file to clean up the codebase. - Updated tests in `test_intrusions.py` to cover new validation logic, ensuring clear error messages for missing data and parameters. - Added regression tests for previously silent errors related to weight handling and geometric scaling. (cherry picked from commit 8cb80c1) * fix: correct fault-proximity gradient retry loop and stop set_stratigraphic_column from wiping state (#304) * fix: Updating intrusions code - Added a new method `_validate_intrusion_inputs` in `GeologicalModel` to validate inputs for intrusions, ensuring necessary data is present before processing. - Updated `_build_intrusion` to call the new validation method, improving error handling for missing data. - Refactored `IntrusionBuilder.create_geometry_using_geometric_scaling` to clarify that geometric scaling is not currently implemented, raising a `NotImplementedError` immediately. - Simplified threshold handling in `IntrusionFeature` by removing redundant checks for marginal faults. - Removed the unused `intrusion_support_functions.py` file to clean up the codebase. - Updated tests in `test_intrusions.py` to cover new validation logic, ensuring clear error messages for missing data and parameters. - Added regression tests for previously silent errors related to weight handling and geometric scaling. (cherry picked from commit 8cb80c1) * fix: correct fault-proximity gradient retry loop and stop set_stratigraphic_column from wiping state evaluate_gradient's tetrahedron-refinement loop set resolved=True unconditionally after one pass, so it never actually retried after shrinking the tetrahedron near a fault. set_stratigraphic_column cleared the model's stratigraphic column before unconditionally raising DeprecationWarning, destroying existing state on every call. (cherry picked from commit 647fe5d) * refactor: extract ModelSerializer from GeologicalModel (#305) GeologicalModel mixed recipe/pickle I/O in with feature-construction orchestration, evaluation, and export logic (2580 lines total). Move the recipe/JSON and dill/pickle serialization logic into a standalone ModelSerializer, keeping every GeologicalModel public method as a thin unchanged-signature wrapper so the CI-enforced stable API surface (API.md, tests/unit/test_public_api_contract.py) is unaffected. (cherry picked from commit 404ce4b) * refactor: extract ModelExporter from GeologicalModel (#306) Move surface/block-model export logic (get_fault_surfaces, get_stratigraphic_surfaces, get_block_model, save) into a standalone ModelExporter, continuing the GeologicalModel decomposition. Public methods remain unchanged thin wrappers. (cherry picked from commit c2435ac) * refactor: extract FeatureRelationshipManager from GeologicalModel (#307) Move fault/unconformity relationship bookkeeping (_add_faults, _add_domain_fault_above/below, _add_unconformity_above, add_unconformity, add_onlap_unconformity) into a standalone FeatureRelationshipManager, continuing the GeologicalModel decomposition. Public methods remain unchanged thin wrappers; _add_feature stays on GeologicalModel since it owns features/feature_name_index mutation directly. (cherry picked from commit b7f2197) * refactor: extract ModelFeatureFactory from GeologicalModel (#308) Move the seven _build_* feature-construction methods (foliation, fold frame, folded foliation, folded fold frame, intrusion, domain fault, fault) -- collectively ~1000 lines, the largest remaining chunk of GeologicalModel -- into a standalone ModelFeatureFactory. The FeatureBuilderRegistry wiring at the bottom of geological_model.py now dispatches to ModelFeatureFactory.build_* instead of the removed private methods. Public create_and_add_* wrappers are unchanged; their docstring cross-references are updated to point at the new factory location. geological_model.py drops from 2579 to 1505 lines. (cherry picked from commit 068d93b) * fix: add future annotations for 3.9 compatability
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Split out of #298 / #299. PR 9 of 9 in the stack — depends on #307.
Last of four sequential extractions, and the largest: moves feature-building logic (including intrusion building, which is why this needs #300's intrusions fix in its ancestry) out of
geological_model.pyinto a new_model_feature_factory.py.This is the tip of the stack. Merged together with #303 (tip of the other line), the full stack reproduces the original combined branch tree exactly (verified: zero diff).