Skip to content

Commit

Permalink
CLN: Refactor ObjectDataProvider
Browse files Browse the repository at this point in the history
This splits the large elif cases into a factory pattern and establishes
a providers subpackage. Some extra refactoring is still warranted for
the case of existing metadata and some other things can be cleaned up
with this split.
  • Loading branch information
mferrera committed Mar 22, 2024
1 parent 7cce416 commit 2bc579b
Show file tree
Hide file tree
Showing 8 changed files with 1,103 additions and 945 deletions.
11 changes: 8 additions & 3 deletions src/fmu/dataio/_metadata.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,15 +14,14 @@
from datetime import timezone
from pathlib import Path
from tempfile import NamedTemporaryFile
from typing import Final
from typing import TYPE_CHECKING, Final

from pydantic import AnyHttpUrl, TypeAdapter

from fmu import dataio
from fmu.dataio._definitions import SCHEMA, SOURCE, VERSION
from fmu.dataio._filedata_provider import FileDataProvider
from fmu.dataio._fmu_provider import FmuProvider
from fmu.dataio._objectdata_provider import ObjectDataProvider
from fmu.dataio._utils import (
drop_nones,
export_file_compute_checksum_md5,
Expand All @@ -32,11 +31,15 @@
from fmu.dataio.datastructure._internal import internal
from fmu.dataio.datastructure.configuration import global_configuration
from fmu.dataio.datastructure.meta import meta
from fmu.dataio.providers._objectdata import objectdata_provider_factory

from . import types
from ._definitions import FmuContext
from ._logging import null_logger

if TYPE_CHECKING:
from fmu.dataio.providers._objectdata_base import ObjectDataProvider

logger: Final = null_logger(__name__)


Expand Down Expand Up @@ -156,7 +159,9 @@ def _populate_meta_objectdata(self) -> None:
Hence this must be ran early or first.
"""
self.objdata = ObjectDataProvider(self.obj, self.dataio, self.meta_existing)
self.objdata = objectdata_provider_factory(
self.obj, self.dataio, self.meta_existing
)
self.objdata.derive_metadata()
self.meta_objectdata = self.objdata.metadata

Expand Down
Loading

0 comments on commit 2bc579b

Please sign in to comment.