Skip to content

Commit

Permalink
CLN: Adjust ObjectDataProvider typing
Browse files Browse the repository at this point in the history
  • Loading branch information
mferrera committed Apr 4, 2024
1 parent c86c2ff commit 8503a09
Show file tree
Hide file tree
Showing 5 changed files with 17 additions and 51 deletions.
Empty file.
65 changes: 14 additions & 51 deletions src/fmu/dataio/providers/objectdata/_base.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,9 @@
from dataclasses import dataclass, field
from datetime import datetime
from pathlib import Path
from typing import TYPE_CHECKING, Any, Dict, Final, Literal, Optional, TypeVar
from typing import TYPE_CHECKING, Any, Final, TypeVar
from warnings import warn

from fmu.dataio import dataio, types
from fmu.dataio._definitions import ConfigurationError
from fmu.dataio._logging import null_logger
from fmu.dataio._utils import generate_description, parse_timedata
Expand All @@ -16,7 +15,7 @@

if TYPE_CHECKING:
from fmu.dataio.dataio import ExportData
from fmu.dataio.types import Inferrable
from fmu.dataio.types import Classname, Efolder, Inferrable, Layout, Subtype

logger: Final = null_logger(__name__)

Expand All @@ -25,51 +24,15 @@

@dataclass
class DerivedObjectDescriptor:
subtype: Literal[
"RegularSurface",
"Polygons",
"Points",
"RegularCube",
"CPGrid",
"CPGridProperty",
"DataFrame",
"JSON",
"ArrowTable",
]
classname: Literal[
"surface",
"polygons",
"points",
"cube",
"cpgrid",
"cpgrid_property",
"table",
"dictionary",
]
layout: Literal[
"regular",
"unset",
"cornerpoint",
"table",
"dictionary",
]
efolder: (
Literal[
"maps",
"polygons",
"points",
"cubes",
"grids",
"tables",
"dictionaries",
]
| str
)
subtype: Subtype
classname: Classname
layout: Layout
efolder: Efolder | str
fmt: str
extension: str
spec: Dict[str, Any] | None
bbox: Dict[str, Any] | None
table_index: Optional[list[str]]
spec: dict[str, Any]
bbox: dict[str, Any]
table_index: list[str] | None


@dataclass
Expand All @@ -86,8 +49,8 @@ class DerivedNamedStratigraphy:


def derive_name(
export: dataio.ExportData,
obj: types.Inferrable,
export: ExportData,
obj: Inferrable,
) -> str:
"""
Derives and returns a name for an export operation based on the
Expand Down Expand Up @@ -128,8 +91,8 @@ class ObjectDataProvider(ABC):
"""

# input fields
obj: types.Inferrable
dataio: dataio.ExportData
obj: Inferrable
dataio: ExportData

# result properties; the most important is metadata which IS the 'data' part in
# the resulting metadata. But other variables needed later are also given
Expand Down Expand Up @@ -216,7 +179,7 @@ def _process_content(self) -> tuple[str | dict, dict | None]:

return content, content_spesific

def _derive_timedata(self) -> Optional[dict[str, str]]:
def _derive_timedata(self) -> dict[str, str] | None:
"""Format input timedata to metadata
New format:
Expand Down
1 change: 1 addition & 0 deletions src/fmu/dataio/providers/objectdata/_provider.py
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,7 @@

import pandas as pd
import xtgeo

from fmu.dataio._definitions import ValidFormats
from fmu.dataio._logging import null_logger

Expand Down
1 change: 1 addition & 0 deletions src/fmu/dataio/providers/objectdata/_tables.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
from typing import TYPE_CHECKING, Final

import pandas as pd

from fmu.dataio._definitions import STANDARD_TABLE_INDEX_COLUMNS, ValidFormats
from fmu.dataio._logging import null_logger
from fmu.dataio.datastructure.meta import specification
Expand Down
1 change: 1 addition & 0 deletions src/fmu/dataio/providers/objectdata/_xtgeo.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
import numpy as np
import pandas as pd
import xtgeo

from fmu.dataio._definitions import ValidFormats
from fmu.dataio._logging import null_logger
from fmu.dataio._utils import npfloat_to_float
Expand Down

0 comments on commit 8503a09

Please sign in to comment.