Skip to content

Conversation

@Leguark
Copy link
Member

@Leguark Leguark commented May 22, 2025

Description

Refactored grid modules to improve serialization and added validation capabilities to the model computation process. Key changes include:

  • Split grid_types.py into separate files for each grid type (RegularGrid, CustomGrid, Sections)
  • Converted CustomGrid and Sections to dataclasses with proper field definitions
  • Added serialization validation during model computation via environment variable
  • Fixed parameter names in grid API functions to match updated class structures
  • Added dotenv support to compute_API for configuration
  • Updated geophysics_input to be properly serializable
  • Added verification tests for model serialization in multiple test cases
  • Added approved verification files for serialization tests

Relates to #serialization-improvements

Checklist

  • My code uses type hinting for function and method arguments and return values.
  • I have created tests which cover my code.
  • The test code either 1. demonstrates at least one valuable use case (e.g. integration tests)
    or 2. verifies that outputs are as expected for given inputs (e.g. unit tests).
  • New tests pass locally with my changes.

@Leguark Leguark changed the title [ENH] Adding logic to test serialization on compute model [ENH] Add model serialization validation and refactor grid modules May 22, 2025
@Leguark Leguark marked this pull request as ready for review May 23, 2025 15:33
@graphite-app graphite-app bot added the gempy 3 Will come with the next major update label May 23, 2025
@graphite-app
Copy link

graphite-app bot commented May 23, 2025

Graphite Automations

"Add gempy label" took an action on this PR • (05/23/25)

1 label was added to this PR based on Miguel de la Varga's automation.

Copy link
Member Author

Leguark commented May 25, 2025

Merge activity

@Leguark Leguark changed the base branch from gempy_save to graphite-base/1032 May 25, 2025 07:27
Leguark added 15 commits May 25, 2025 08:28
Refactored `StructuralElement` attributes to use Pydantic's `Field` for improved data validation and added `exclude=True` where necessary. Enhanced serialization test to include model save after computation with validation.
Add warnings to indicate that save/load functions are in development and may not work as expected. Updated test cases by commenting unused computations, modifying object serialization, and adding placeholders for future functionality.
Add detailed validation for serialized GeoModel instances, including debugging for string differences and hash checks. Introduce `verify_model_serialization` with pre/post-deserialization checks, and update gravity tests for structured verification and data type consistency.
Expose `geophysics_input` and integrate gravity gradient calculation during deserialization. This ensures proper resetting of geophysics-specific fields when grid data is available.
Replaced hardcoded file paths with `tempfile.NamedTemporaryFile` to ensure safe and temporary file handling during serialization tests. This improves test reliability and avoids residual files on disk.
Simplified imports and removed unused `SectionDefinition` class. Adjusted and clarified type annotations while ensuring internal fields are properly excluded from serialization.
Refactored `regular_grid` to `_regular_grid` to indicate it as a private attribute. This change ensures better encapsulation and aligns with naming conventions.
Leguark added 2 commits May 25, 2025 08:28
Introduces a new approved test file to validate grid sections in `test_grids_sections`. This ensures consistency and accuracy in grid-related functionality during testing.
@Leguark Leguark changed the base branch from graphite-base/1032 to main May 25, 2025 07:28
@Leguark Leguark merged commit 95a580a into main May 25, 2025
2 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

gempy 3 Will come with the next major update

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants