Skip to content
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

Refine examples/ for versioned schemas #1010

Open
mferrera opened this issue Feb 18, 2025 · 3 comments · May be fixed by #1056
Open

Refine examples/ for versioned schemas #1010

mferrera opened this issue Feb 18, 2025 · 3 comments · May be fixed by #1056
Assignees

Comments

@mferrera
Copy link
Collaborator

mferrera commented Feb 18, 2025

There are a few ways we need to improve examples/ as we move into versioned schemas. Files in this directory are used both in tests and in documentation.

  • examples/0.8.0 contains metadata examples that are manually updated
    • These should be automatically generated
    • We may only care about the latest version of metadata (?)
    • These are important to tests. This fixture is used in quite a bit of tests:
    • @pytest.fixture(scope="session")
      def metadata_examples():
      """Parse all metadata examples.
      Returns:
      Dict: Dictionary with filename as key, file contents as value.
      """
      return _metadata_examples()
    • def _metadata_examples():
      return {
      path.name: _isoformat_all_datetimes(_parse_yaml(path))
      for path in Path(".").absolute().glob("examples/0.8.0/*.yml")
      }
  • examples/s/d/nn contains a mocked Ert ensemble that runs scripts and generates metadata
    • The file structure could be improved
    • We should generate more file types (ideally, one per content type)
    • Has at least one reference in tests
    • shutil.copy(
      source_root
      / "examples/s/d/nn/xcase/realization-0/iter-0/rms"
      / "output/maps/props/poro_average.gri",
      tmp_path / "ert/output/maps/props/poro_average.gri",
      )
    • Is featured quite a bit in docs
    • .. literalinclude:: ../../examples/s/d/nn/xcase/realization-0/iter-0/rms/bin/export_faultpolygons.py
      :language: python
      Press + to see generated YAML file.
      .. toggle::
      .. literalinclude:: ../../examples/s/d/nn/xcase/realization-0/iter-0/share/results/polygons/.volantis_gp_top--faultlines.pol.yml
      :language: yaml
    • - bash examples/run_examples.sh
    • run: sh examples/run_examples.sh

We should combine these two things into a simpler, cohesive, but comprehensive way of managing documentation, examples, and testing altogether.

It's possible that this should be part of the update-schemas script.

@mferrera mferrera mentioned this issue Feb 18, 2025
8 tasks
@mferrera
Copy link
Collaborator Author

It is possible to generate a new example directory for every schema version, and store those examples forever. Is this something we want to do?

@slangeveld slangeveld self-assigned this Feb 18, 2025
@slangeveld
Copy link
Contributor

slangeveld commented Feb 20, 2025

What I was thinking so far was to create a folder structure like this

/examples
   schemas/
      templates/
      0.8.0/
      0.8.1/
      .
      .
      .
      1.0.0/    

where the folder templates would coutain templates for the examples:

/templates
   case_template.yml
   aggregated_surface_depth_template.yml
   surface_depth.yml
   (etc..)

Then update-schema could use the templates, create a new folder and generate yml-files for each new schema.

We should maybe delete some of the schema example folders after some time, but I guess that is not something we need to decide on yet.

Not sure where to place the files from examples/s/d/nn into the picture yet..

@mferrera
Copy link
Collaborator Author

One way I had thought of doing this is to have a script (or set of scripts) that generates metadata per content type. So basically do a full

export_data = ExportData(..)
...export()...

And do this for several (in the long run, all) content types.

class Content(str, Enum):
"""The content type of a given data object."""
depth = "depth"
facies_thickness = "facies_thickness"
fault_lines = "fault_lines"
fault_properties = "fault_properties"
field_outline = "field_outline"
field_region = "field_region"
fluid_contact = "fluid_contact"
khproduct = "khproduct"
lift_curves = "lift_curves"
named_area = "named_area"
parameters = "parameters"
pinchout = "pinchout"
property = "property"
pvt = "pvt"
regions = "regions"
relperm = "relperm"
rft = "rft"
seismic = "seismic"
simulationtimeseries = "simulationtimeseries"
subcrop = "subcrop"
thickness = "thickness"
time = "time"
timeseries = "timeseries"
transmissibilities = "transmissibilities"
velocity = "velocity"
volumes = "volumes"
wellpicks = "wellpicks"

examples/s/d/nn contains a few of these scripts now, that generate data based upon the latest models.

Then, when update-schemas is run, and we see a version change (maybe it is just for major/minor versions), it invokes these exports scripts, exports the metadata to examples/x.y.z/, and renames the metadata files to human readable ones. (It can probably reach deeper into code and just call the metadata export function).

Then we can always keeps our testing and examples up-to-date with the latest version of the schema/models. For the documentation build we may have to see if we can do something clever like have a symlink "latest" in examples/ that points to the most recent version, and see if docs can read into the symlink and build examples in from there.

Maybe we should have a sync? There's a fair bit going on here, but it's important for the longevity of the current testing regime we have which will start breaking down when we bump versions

@mferrera mferrera added simple-exports-milestone Relevant to the current milestone and removed simple-exports-milestone Relevant to the current milestone labels Mar 5, 2025
@slangeveld slangeveld linked a pull request Mar 6, 2025 that will close this issue
11 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants