fmu-dataio 0.30.2__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- fmu/__init__.py +2 -0
- fmu/dataio/__init__.py +27 -0
- fmu/dataio/_definitions.py +110 -0
- fmu/dataio/_export/__init__.py +23 -0
- fmu/dataio/_export/_export_config.py +503 -0
- fmu/dataio/_export/_export_config_resolver.py +636 -0
- fmu/dataio/_export/_export_models.py +68 -0
- fmu/dataio/_export/core.py +88 -0
- fmu/dataio/_export/deprecations.py +396 -0
- fmu/dataio/_export/serialize.py +130 -0
- fmu/dataio/_global_config.py +273 -0
- fmu/dataio/_interfaces/__init__.py +13 -0
- fmu/dataio/_interfaces/sumo_uploader_interface.py +105 -0
- fmu/dataio/_logging.py +32 -0
- fmu/dataio/_metadata/__init__.py +19 -0
- fmu/dataio/_metadata/_file.py +169 -0
- fmu/dataio/_metadata/_fmu.py +262 -0
- fmu/dataio/_metadata/_object/__init__.py +7 -0
- fmu/dataio/_metadata/_object/_base.py +231 -0
- fmu/dataio/_metadata/_object/_faultroom.py +93 -0
- fmu/dataio/_metadata/_object/_tables.py +266 -0
- fmu/dataio/_metadata/_object/_utils.py +64 -0
- fmu/dataio/_metadata/_object/_xtgeo.py +657 -0
- fmu/dataio/_metadata/_object/core.py +112 -0
- fmu/dataio/_metadata/core.py +113 -0
- fmu/dataio/_readers/__init__.py +0 -0
- fmu/dataio/_readers/faultroom.py +118 -0
- fmu/dataio/_runcontext.py +301 -0
- fmu/dataio/_utils.py +127 -0
- fmu/dataio/_workflows/__init__.py +0 -0
- fmu/dataio/_workflows/case/__init__.py +0 -0
- fmu/dataio/_workflows/case/_config.py +123 -0
- fmu/dataio/_workflows/case/_mappings.py +28 -0
- fmu/dataio/_workflows/case/_observations.py +68 -0
- fmu/dataio/_workflows/case/_parameters.py +108 -0
- fmu/dataio/_workflows/case/export_case_metadata.py +146 -0
- fmu/dataio/_workflows/case/main.py +385 -0
- fmu/dataio/_workflows/copy_preprocessed.py +156 -0
- fmu/dataio/_workflows/jobs.py +8 -0
- fmu/dataio/dataio.py +759 -0
- fmu/dataio/exceptions.py +18 -0
- fmu/dataio/export/__init__.py +0 -0
- fmu/dataio/export/_base.py +37 -0
- fmu/dataio/export/_export_result.py +19 -0
- fmu/dataio/export/rms/__init__.py +28 -0
- fmu/dataio/export/rms/_conditional_rms_imports.py +46 -0
- fmu/dataio/export/rms/_utils.py +382 -0
- fmu/dataio/export/rms/field_outline.py +101 -0
- fmu/dataio/export/rms/fluid_contact_outlines.py +162 -0
- fmu/dataio/export/rms/fluid_contact_surfaces.py +165 -0
- fmu/dataio/export/rms/grid_extracted_depth_surfaces.py +103 -0
- fmu/dataio/export/rms/grid_model_static.py +314 -0
- fmu/dataio/export/rms/inplace_volumes.py +417 -0
- fmu/dataio/export/rms/simulator_fipregions_mapping.py +152 -0
- fmu/dataio/export/rms/structure_depth_fault_lines.py +129 -0
- fmu/dataio/export/rms/structure_depth_fault_surfaces.py +155 -0
- fmu/dataio/export/rms/structure_depth_isochores.py +106 -0
- fmu/dataio/export/rms/structure_depth_surfaces.py +123 -0
- fmu/dataio/export/rms/structure_time_surfaces.py +98 -0
- fmu/dataio/manifest/__init__.py +3 -0
- fmu/dataio/manifest/_manifest.py +62 -0
- fmu/dataio/manifest/_models.py +55 -0
- fmu/dataio/preprocessed.py +271 -0
- fmu/dataio/py.typed +0 -0
- fmu/dataio/types.py +40 -0
- fmu/dataio/version.py +24 -0
- fmu_dataio-0.30.2.dist-info/METADATA +128 -0
- fmu_dataio-0.30.2.dist-info/RECORD +72 -0
- fmu_dataio-0.30.2.dist-info/WHEEL +5 -0
- fmu_dataio-0.30.2.dist-info/entry_points.txt +3 -0
- fmu_dataio-0.30.2.dist-info/licenses/LICENSE +190 -0
- fmu_dataio-0.30.2.dist-info/top_level.txt +1 -0
fmu/__init__.py
ADDED
fmu/dataio/__init__.py
ADDED
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
"""Top-level package for fmu-dataio"""
|
|
2
|
+
|
|
3
|
+
from fmu.dataio.dataio import ExportData, read_metadata
|
|
4
|
+
from fmu.dataio.exceptions import (
|
|
5
|
+
ConfigurationError,
|
|
6
|
+
DeprecationError,
|
|
7
|
+
InvalidMetadataError,
|
|
8
|
+
ValidationError,
|
|
9
|
+
)
|
|
10
|
+
from fmu.dataio.preprocessed import ExportPreprocessedData
|
|
11
|
+
|
|
12
|
+
try:
|
|
13
|
+
from .version import version
|
|
14
|
+
|
|
15
|
+
__version__ = version
|
|
16
|
+
except ImportError:
|
|
17
|
+
__version__ = "0.0.0"
|
|
18
|
+
|
|
19
|
+
__all__ = [
|
|
20
|
+
"ConfigurationError",
|
|
21
|
+
"DeprecationError",
|
|
22
|
+
"ExportData",
|
|
23
|
+
"ExportPreprocessedData",
|
|
24
|
+
"InvalidMetadataError",
|
|
25
|
+
"ValidationError",
|
|
26
|
+
"read_metadata",
|
|
27
|
+
]
|
|
@@ -0,0 +1,110 @@
|
|
|
1
|
+
"""Various definitions and hard settings used in fmu-dataio."""
|
|
2
|
+
|
|
3
|
+
from __future__ import annotations
|
|
4
|
+
|
|
5
|
+
from enum import StrEnum
|
|
6
|
+
from typing import Final
|
|
7
|
+
|
|
8
|
+
from pydantic import BaseModel, model_validator
|
|
9
|
+
|
|
10
|
+
from fmu.datamodels.fmu_results.enums import Content
|
|
11
|
+
from fmu.datamodels.standard_results.enums import InplaceVolumes, SimulatorTables
|
|
12
|
+
|
|
13
|
+
ERT_RELATIVE_CASE_METADATA_FILE: Final = "share/metadata/fmu_case.yml"
|
|
14
|
+
|
|
15
|
+
|
|
16
|
+
class ShareFolder(StrEnum):
|
|
17
|
+
preprocessed = "share/preprocessed/"
|
|
18
|
+
observations = "share/observations/"
|
|
19
|
+
results = "share/results/"
|
|
20
|
+
|
|
21
|
+
|
|
22
|
+
class FileExtension(StrEnum):
|
|
23
|
+
gri = ".gri"
|
|
24
|
+
roff = ".roff"
|
|
25
|
+
segy = ".segy"
|
|
26
|
+
csv = ".csv"
|
|
27
|
+
parquet = ".parquet"
|
|
28
|
+
pol = ".pol"
|
|
29
|
+
poi = ".poi"
|
|
30
|
+
json = ".json"
|
|
31
|
+
tsurf = ".ts"
|
|
32
|
+
|
|
33
|
+
|
|
34
|
+
class ExportFolder(StrEnum):
|
|
35
|
+
cubes = "cubes"
|
|
36
|
+
dictionaries = "dictionaries"
|
|
37
|
+
grids = "grids"
|
|
38
|
+
maps = "maps"
|
|
39
|
+
points = "points"
|
|
40
|
+
polygons = "polygons"
|
|
41
|
+
tables = "tables"
|
|
42
|
+
|
|
43
|
+
|
|
44
|
+
class StandardTableIndex(BaseModel):
|
|
45
|
+
columns: list[str]
|
|
46
|
+
"""List of all index columns"""
|
|
47
|
+
required: list[str]
|
|
48
|
+
"""List of required index columns"""
|
|
49
|
+
|
|
50
|
+
@model_validator(mode="after")
|
|
51
|
+
def _required_in_columns(self) -> StandardTableIndex:
|
|
52
|
+
if not all(c in self.columns for c in self.required):
|
|
53
|
+
raise ValueError("Not all required columns are listed in columns")
|
|
54
|
+
return self
|
|
55
|
+
|
|
56
|
+
|
|
57
|
+
STANDARD_TABLE_INDEX_COLUMNS: Final[dict[Content, StandardTableIndex]] = {
|
|
58
|
+
Content.volumes: StandardTableIndex(
|
|
59
|
+
columns=InplaceVolumes.index_columns(),
|
|
60
|
+
required=InplaceVolumes.required_index_columns(),
|
|
61
|
+
),
|
|
62
|
+
Content.production_network: StandardTableIndex(
|
|
63
|
+
columns=SimulatorTables.ProductionNetworkColumns.index_columns(),
|
|
64
|
+
required=SimulatorTables.ProductionNetworkColumns.index_columns(),
|
|
65
|
+
),
|
|
66
|
+
Content.pvt: StandardTableIndex(
|
|
67
|
+
columns=SimulatorTables.PvtColumns.index_columns(),
|
|
68
|
+
required=SimulatorTables.PvtColumns.index_columns(),
|
|
69
|
+
),
|
|
70
|
+
Content.rft: StandardTableIndex(
|
|
71
|
+
columns=SimulatorTables.RftColumns.index_columns(),
|
|
72
|
+
required=SimulatorTables.RftColumns.index_columns(),
|
|
73
|
+
),
|
|
74
|
+
Content.timeseries: StandardTableIndex(
|
|
75
|
+
columns=SimulatorTables.SimulationTimeseriesColumns.index_columns(),
|
|
76
|
+
required=SimulatorTables.SimulationTimeseriesColumns.index_columns(),
|
|
77
|
+
),
|
|
78
|
+
Content.simulationtimeseries: StandardTableIndex(
|
|
79
|
+
columns=SimulatorTables.SimulationTimeseriesColumns.index_columns(),
|
|
80
|
+
required=SimulatorTables.SimulationTimeseriesColumns.index_columns(),
|
|
81
|
+
),
|
|
82
|
+
Content.wellpicks: StandardTableIndex(
|
|
83
|
+
columns=["WELL", "HORIZON"],
|
|
84
|
+
required=["WELL", "HORIZON"],
|
|
85
|
+
),
|
|
86
|
+
Content.relperm: StandardTableIndex(
|
|
87
|
+
columns=SimulatorTables.RelpermColumns.index_columns(),
|
|
88
|
+
required=SimulatorTables.RelpermColumns.index_columns(),
|
|
89
|
+
),
|
|
90
|
+
Content.well_completions: StandardTableIndex(
|
|
91
|
+
columns=SimulatorTables.WellCompletionsColumns.index_columns(),
|
|
92
|
+
required=SimulatorTables.WellCompletionsColumns.index_columns(),
|
|
93
|
+
),
|
|
94
|
+
Content.transmissibilities: StandardTableIndex(
|
|
95
|
+
columns=SimulatorTables.TransmissibilitiesColumns.index_columns(),
|
|
96
|
+
required=SimulatorTables.TransmissibilitiesColumns.index_columns(),
|
|
97
|
+
),
|
|
98
|
+
Content.lift_curves: StandardTableIndex(
|
|
99
|
+
columns=SimulatorTables.LiftCurvesColumns.index_columns(),
|
|
100
|
+
required=SimulatorTables.LiftCurvesColumns.index_columns(),
|
|
101
|
+
),
|
|
102
|
+
}
|
|
103
|
+
|
|
104
|
+
|
|
105
|
+
class RMSExecutionMode(StrEnum):
|
|
106
|
+
"""The modes RMS can execute in. These definitions come from
|
|
107
|
+
`runrms.executor._rms_executor`."""
|
|
108
|
+
|
|
109
|
+
interactive = "interactive"
|
|
110
|
+
batch = "batch"
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
from ._export_config import ExportConfig, ExportConfigBuilder
|
|
2
|
+
from ._export_config_resolver import build_from_export_data
|
|
3
|
+
from ._export_models import AllowedContentSeismic, ObjectMetadataExport, UnsetData
|
|
4
|
+
from .core import (
|
|
5
|
+
export_metadata_file,
|
|
6
|
+
export_with_metadata,
|
|
7
|
+
export_without_metadata,
|
|
8
|
+
)
|
|
9
|
+
from .serialize import compute_md5_and_size, export_object
|
|
10
|
+
|
|
11
|
+
__all__ = [
|
|
12
|
+
"compute_md5_and_size",
|
|
13
|
+
"export_metadata_file",
|
|
14
|
+
"export_object",
|
|
15
|
+
"export_with_metadata",
|
|
16
|
+
"export_without_metadata",
|
|
17
|
+
"ExportConfig",
|
|
18
|
+
"ExportConfigBuilder",
|
|
19
|
+
"build_from_export_data",
|
|
20
|
+
"ObjectMetadataExport",
|
|
21
|
+
"UnsetData",
|
|
22
|
+
"AllowedContentSeismic",
|
|
23
|
+
]
|
|
@@ -0,0 +1,503 @@
|
|
|
1
|
+
"""
|
|
2
|
+
Module for ExportConfig which contains the fully resolved export configuration.
|
|
3
|
+
|
|
4
|
+
This is the interface used internally which has already processed user input and
|
|
5
|
+
undergone input validation and transformations.
|
|
6
|
+
"""
|
|
7
|
+
|
|
8
|
+
from __future__ import annotations
|
|
9
|
+
|
|
10
|
+
import dataclasses
|
|
11
|
+
from dataclasses import dataclass
|
|
12
|
+
from pathlib import Path
|
|
13
|
+
from typing import TYPE_CHECKING, Final, Literal, Self, TypeAlias
|
|
14
|
+
|
|
15
|
+
from pydantic import TypeAdapter
|
|
16
|
+
|
|
17
|
+
from fmu.dataio._logging import null_logger
|
|
18
|
+
from fmu.dataio._runcontext import RunContext
|
|
19
|
+
from fmu.datamodels import TracklogSource
|
|
20
|
+
from fmu.datamodels.common.enums import Classification
|
|
21
|
+
from fmu.datamodels.fmu_results.data import (
|
|
22
|
+
FieldOutline,
|
|
23
|
+
FieldRegion,
|
|
24
|
+
FluidContact,
|
|
25
|
+
Property,
|
|
26
|
+
)
|
|
27
|
+
from fmu.datamodels.fmu_results.enums import (
|
|
28
|
+
Content,
|
|
29
|
+
DomainReference,
|
|
30
|
+
FMUContext,
|
|
31
|
+
VerticalDomain,
|
|
32
|
+
)
|
|
33
|
+
from fmu.datamodels.fmu_results.fields import Display, Workflow
|
|
34
|
+
from fmu.datamodels.fmu_results.global_configuration import GlobalConfiguration
|
|
35
|
+
from fmu.datamodels.fmu_results.standard_result import AnyStandardResult
|
|
36
|
+
from fmu.datamodels.standard_results.enums import StandardResultName
|
|
37
|
+
from fmu.settings import ProjectFMUDirectory
|
|
38
|
+
|
|
39
|
+
from ._export_config_resolver import (
|
|
40
|
+
_resolve_fmu_context,
|
|
41
|
+
_resolve_fmu_dir,
|
|
42
|
+
build_from_export_data,
|
|
43
|
+
)
|
|
44
|
+
from ._export_models import AllowedContentSeismic
|
|
45
|
+
|
|
46
|
+
logger: Final = null_logger(__name__)
|
|
47
|
+
|
|
48
|
+
|
|
49
|
+
if TYPE_CHECKING:
|
|
50
|
+
from fmu.dataio import ExportData
|
|
51
|
+
|
|
52
|
+
AnyContentMetadata: TypeAlias = (
|
|
53
|
+
AllowedContentSeismic | FieldOutline | FieldRegion | FluidContact | Property
|
|
54
|
+
)
|
|
55
|
+
|
|
56
|
+
StandardResultAdapter = TypeAdapter(AnyStandardResult)
|
|
57
|
+
|
|
58
|
+
|
|
59
|
+
@dataclass(frozen=True)
|
|
60
|
+
class ExportConfig:
|
|
61
|
+
"""Immutable configuration for export operations.
|
|
62
|
+
|
|
63
|
+
All values are resolved and validated at creation time.
|
|
64
|
+
"""
|
|
65
|
+
|
|
66
|
+
# Content
|
|
67
|
+
content: Content | Literal["unset"]
|
|
68
|
+
content_metadata: AnyContentMetadata | None
|
|
69
|
+
|
|
70
|
+
# File/path configuration
|
|
71
|
+
name: str
|
|
72
|
+
tagname: str
|
|
73
|
+
forcefolder: str
|
|
74
|
+
subfolder: str
|
|
75
|
+
parent: str
|
|
76
|
+
filename_timedata_reverse: bool
|
|
77
|
+
geometry: str | None
|
|
78
|
+
|
|
79
|
+
# Domain configuration
|
|
80
|
+
vertical_domain: VerticalDomain
|
|
81
|
+
domain_reference: DomainReference
|
|
82
|
+
|
|
83
|
+
# User input strings
|
|
84
|
+
display: Display
|
|
85
|
+
workflow: Workflow | None
|
|
86
|
+
description: list[str] | None
|
|
87
|
+
|
|
88
|
+
# Classification/access
|
|
89
|
+
classification: Classification
|
|
90
|
+
rep_include: bool
|
|
91
|
+
|
|
92
|
+
# Table configuration
|
|
93
|
+
table_index: list[str] | None
|
|
94
|
+
table_fformat: str
|
|
95
|
+
polygons_fformat: str
|
|
96
|
+
points_fformat: str
|
|
97
|
+
|
|
98
|
+
# Time configuration
|
|
99
|
+
timedata: list[str] | list[list[str]] | None
|
|
100
|
+
|
|
101
|
+
# Flags
|
|
102
|
+
preprocessed: bool
|
|
103
|
+
is_prediction: bool
|
|
104
|
+
is_observation: bool
|
|
105
|
+
undef_is_zero: bool
|
|
106
|
+
|
|
107
|
+
# Other
|
|
108
|
+
unit: str
|
|
109
|
+
|
|
110
|
+
# Global configuration
|
|
111
|
+
config: GlobalConfiguration | None
|
|
112
|
+
fmu_dir: ProjectFMUDirectory | None
|
|
113
|
+
|
|
114
|
+
# Run context
|
|
115
|
+
runcontext: RunContext
|
|
116
|
+
|
|
117
|
+
# Standard result
|
|
118
|
+
standard_result: AnyStandardResult | None
|
|
119
|
+
|
|
120
|
+
# Data provenance
|
|
121
|
+
tracklog_source: TracklogSource | None = None
|
|
122
|
+
|
|
123
|
+
@property
|
|
124
|
+
def content_enum(self) -> Content | None:
|
|
125
|
+
"""Filter possible 'unset' content."""
|
|
126
|
+
if isinstance(self.content, Content):
|
|
127
|
+
return self.content
|
|
128
|
+
return None
|
|
129
|
+
|
|
130
|
+
@property
|
|
131
|
+
def fmu_context(self) -> FMUContext | None:
|
|
132
|
+
"""The FMU context from the run context."""
|
|
133
|
+
return self.runcontext.fmu_context
|
|
134
|
+
|
|
135
|
+
@property
|
|
136
|
+
def casepath(self) -> Path | None:
|
|
137
|
+
"""The casepath from the run context."""
|
|
138
|
+
return self.runcontext.casepath
|
|
139
|
+
|
|
140
|
+
def with_ensemble_name(self, ensemble_name: str) -> Self:
|
|
141
|
+
"""Return a new ExportConfig with the ensemble name set explicitly.
|
|
142
|
+
|
|
143
|
+
This is an adapter for existing tests."""
|
|
144
|
+
runcontext = RunContext(
|
|
145
|
+
casepath_proposed=self.runcontext.casepath,
|
|
146
|
+
fmu_context=self.runcontext.fmu_context,
|
|
147
|
+
ensemble_name=ensemble_name,
|
|
148
|
+
)
|
|
149
|
+
return dataclasses.replace(self, runcontext=runcontext)
|
|
150
|
+
|
|
151
|
+
def with_standard_result(self, standard_result: AnyStandardResult) -> Self:
|
|
152
|
+
"""Returns a new ExportConfig with a standard result set explicitly.
|
|
153
|
+
|
|
154
|
+
This is an adapter for existing tests."""
|
|
155
|
+
return dataclasses.replace(self, standard_result=standard_result)
|
|
156
|
+
|
|
157
|
+
def with_tracklog_source(self, source_name: str, source_version: str) -> Self:
|
|
158
|
+
"""Returns a new ExportConfig with a source to use in the tracklog."""
|
|
159
|
+
return dataclasses.replace(
|
|
160
|
+
self,
|
|
161
|
+
tracklog_source=TracklogSource(name=source_name, version=source_version),
|
|
162
|
+
)
|
|
163
|
+
|
|
164
|
+
@classmethod
|
|
165
|
+
def builder(cls) -> ExportConfigBuilder:
|
|
166
|
+
"""Create a new builder instance."""
|
|
167
|
+
return ExportConfigBuilder()
|
|
168
|
+
|
|
169
|
+
@classmethod
|
|
170
|
+
def from_export_data(cls, dataio: ExportData) -> ExportConfig:
|
|
171
|
+
"""Create an ExportConfig from an ExportData instance.
|
|
172
|
+
|
|
173
|
+
Args:
|
|
174
|
+
dataio: The ExportData instance to create config from.
|
|
175
|
+
|
|
176
|
+
Returns:
|
|
177
|
+
An immutable ExportConfig with all resolved values.
|
|
178
|
+
"""
|
|
179
|
+
|
|
180
|
+
return build_from_export_data(dataio)
|
|
181
|
+
|
|
182
|
+
|
|
183
|
+
class ExportConfigBuilder:
|
|
184
|
+
"""Builder for ExportConfig.
|
|
185
|
+
|
|
186
|
+
Accepts already-validated types. For resolution from raw user input, use
|
|
187
|
+
ExportConfig.from_export_data().
|
|
188
|
+
|
|
189
|
+
Example:
|
|
190
|
+
config = (
|
|
191
|
+
ExportConfig.builder()
|
|
192
|
+
.content(Content.depth)
|
|
193
|
+
.domain(VerticalDomain.depth, DomainReference.msl)
|
|
194
|
+
.file_config(name="TopVolantis")
|
|
195
|
+
.access(Classification.internal, rep_include=False)
|
|
196
|
+
.global_config(validated_config)
|
|
197
|
+
.build()
|
|
198
|
+
)
|
|
199
|
+
|
|
200
|
+
# With explicit run context:
|
|
201
|
+
config = (
|
|
202
|
+
ExportConfig.builder()
|
|
203
|
+
.content(Content.depth, None)
|
|
204
|
+
.global_config(validated_config)
|
|
205
|
+
.run_context(fmu_context=FMUContext.case, casepath=some_path)
|
|
206
|
+
.build()
|
|
207
|
+
)
|
|
208
|
+
"""
|
|
209
|
+
|
|
210
|
+
def __init__(self) -> None:
|
|
211
|
+
# Content
|
|
212
|
+
self._content: Content | None = None
|
|
213
|
+
self._content_metadata: AnyContentMetadata | None = None
|
|
214
|
+
|
|
215
|
+
# File/path
|
|
216
|
+
self._name: str = ""
|
|
217
|
+
self._tagname: str = ""
|
|
218
|
+
self._forcefolder: str = ""
|
|
219
|
+
self._subfolder: str = ""
|
|
220
|
+
self._parent: str = ""
|
|
221
|
+
self._filename_timedata_reverse: bool = False
|
|
222
|
+
self._geometry: str | None = None
|
|
223
|
+
|
|
224
|
+
# Domain
|
|
225
|
+
self._vertical_domain: VerticalDomain = VerticalDomain.depth
|
|
226
|
+
self._domain_reference: DomainReference = DomainReference.msl
|
|
227
|
+
|
|
228
|
+
# Display/workflow
|
|
229
|
+
self._display: Display = Display(name=None)
|
|
230
|
+
self._workflow: Workflow | None = None
|
|
231
|
+
self._description: list[str] | None = None
|
|
232
|
+
|
|
233
|
+
# Classification
|
|
234
|
+
self._classification: Classification = Classification.internal
|
|
235
|
+
self._rep_include: bool = False
|
|
236
|
+
|
|
237
|
+
# Table config
|
|
238
|
+
self._table_index: list[str] | None = None
|
|
239
|
+
self._table_fformat: str = "parquet"
|
|
240
|
+
self._polygons_fformat: str = "parquet"
|
|
241
|
+
self._points_fformat: str = "parquet"
|
|
242
|
+
|
|
243
|
+
# Time
|
|
244
|
+
self._timedata: list[str] | list[list[str]] | None = None
|
|
245
|
+
|
|
246
|
+
# Flags
|
|
247
|
+
self._preprocessed: bool = False
|
|
248
|
+
self._is_prediction: bool = True
|
|
249
|
+
self._is_observation: bool = False
|
|
250
|
+
self._unit: str = ""
|
|
251
|
+
self._undef_is_zero: bool = False
|
|
252
|
+
|
|
253
|
+
# Config
|
|
254
|
+
self._config: GlobalConfiguration | None = None
|
|
255
|
+
self._fmu_dir: ProjectFMUDirectory | None = None
|
|
256
|
+
|
|
257
|
+
# Run context
|
|
258
|
+
self._runcontext: RunContext | None = None
|
|
259
|
+
self._casepath: Path | None = None
|
|
260
|
+
self._fmu_context: FMUContext | None = None
|
|
261
|
+
self._ensemble_name: str | None = None
|
|
262
|
+
self._run_context_called: bool = False
|
|
263
|
+
|
|
264
|
+
# Standard result
|
|
265
|
+
self._standard_result: AnyStandardResult | None = None
|
|
266
|
+
|
|
267
|
+
# Data provenance
|
|
268
|
+
self._tracklog_source: TracklogSource | None = None
|
|
269
|
+
|
|
270
|
+
def content(
|
|
271
|
+
self,
|
|
272
|
+
content: Content,
|
|
273
|
+
metadata: AnyContentMetadata | None = None,
|
|
274
|
+
) -> ExportConfigBuilder:
|
|
275
|
+
"""Set content type and metadata."""
|
|
276
|
+
self._content = content
|
|
277
|
+
self._content_metadata = metadata
|
|
278
|
+
return self
|
|
279
|
+
|
|
280
|
+
def file_config(
|
|
281
|
+
self,
|
|
282
|
+
name: str = "",
|
|
283
|
+
tagname: str = "",
|
|
284
|
+
forcefolder: str = "",
|
|
285
|
+
subfolder: str = "",
|
|
286
|
+
parent: str = "",
|
|
287
|
+
geometry: str | None = None,
|
|
288
|
+
filename_timedata_reverse: bool = False,
|
|
289
|
+
) -> ExportConfigBuilder:
|
|
290
|
+
"""Set file/path configuration."""
|
|
291
|
+
self._name = name
|
|
292
|
+
self._tagname = tagname
|
|
293
|
+
self._forcefolder = forcefolder
|
|
294
|
+
self._subfolder = subfolder
|
|
295
|
+
self._parent = parent
|
|
296
|
+
self._geometry = geometry
|
|
297
|
+
self._filename_timedata_reverse = filename_timedata_reverse
|
|
298
|
+
return self
|
|
299
|
+
|
|
300
|
+
def domain(
|
|
301
|
+
self,
|
|
302
|
+
vertical_domain: VerticalDomain,
|
|
303
|
+
domain_reference: DomainReference,
|
|
304
|
+
) -> ExportConfigBuilder:
|
|
305
|
+
"""Set vertical domain and reference."""
|
|
306
|
+
self._vertical_domain = vertical_domain
|
|
307
|
+
self._domain_reference = domain_reference
|
|
308
|
+
return self
|
|
309
|
+
|
|
310
|
+
def display(self, display: Display) -> ExportConfigBuilder:
|
|
311
|
+
"""Set display configuration."""
|
|
312
|
+
self._display = display
|
|
313
|
+
return self
|
|
314
|
+
|
|
315
|
+
def workflow(self, workflow: Workflow | None) -> ExportConfigBuilder:
|
|
316
|
+
"""Set workflow."""
|
|
317
|
+
self._workflow = workflow
|
|
318
|
+
return self
|
|
319
|
+
|
|
320
|
+
def description(self, description: list[str] | None) -> ExportConfigBuilder:
|
|
321
|
+
"""Set description."""
|
|
322
|
+
self._description = description
|
|
323
|
+
return self
|
|
324
|
+
|
|
325
|
+
def access(
|
|
326
|
+
self,
|
|
327
|
+
classification: Classification,
|
|
328
|
+
rep_include: bool,
|
|
329
|
+
) -> ExportConfigBuilder:
|
|
330
|
+
"""Set classification and access."""
|
|
331
|
+
self._classification = classification
|
|
332
|
+
self._rep_include = rep_include
|
|
333
|
+
return self
|
|
334
|
+
|
|
335
|
+
def table_config(
|
|
336
|
+
self,
|
|
337
|
+
table_index: list[str] | None = None,
|
|
338
|
+
table_fformat: str = "parquet",
|
|
339
|
+
polygons_fformat: str = "parquet",
|
|
340
|
+
points_fformat: str = "parquet",
|
|
341
|
+
) -> ExportConfigBuilder:
|
|
342
|
+
"""Set table-related configuration."""
|
|
343
|
+
self._table_index = table_index
|
|
344
|
+
self._table_fformat = table_fformat
|
|
345
|
+
self._polygons_fformat = polygons_fformat
|
|
346
|
+
self._points_fformat = points_fformat
|
|
347
|
+
return self
|
|
348
|
+
|
|
349
|
+
def timedata(
|
|
350
|
+
self, timedata: list[str] | list[list[str]] | None
|
|
351
|
+
) -> ExportConfigBuilder:
|
|
352
|
+
"""Set time data."""
|
|
353
|
+
self._timedata = timedata
|
|
354
|
+
return self
|
|
355
|
+
|
|
356
|
+
def flags(
|
|
357
|
+
self,
|
|
358
|
+
preprocessed: bool = False,
|
|
359
|
+
is_prediction: bool = True,
|
|
360
|
+
is_observation: bool = False,
|
|
361
|
+
undef_is_zero: bool = False,
|
|
362
|
+
) -> ExportConfigBuilder:
|
|
363
|
+
"""Set boolean flags."""
|
|
364
|
+
self._preprocessed = preprocessed
|
|
365
|
+
self._is_prediction = is_prediction
|
|
366
|
+
self._is_observation = is_observation
|
|
367
|
+
self._undef_is_zero = undef_is_zero
|
|
368
|
+
return self
|
|
369
|
+
|
|
370
|
+
def unit(self, unit: str) -> ExportConfigBuilder:
|
|
371
|
+
"""Set unit."""
|
|
372
|
+
self._unit = unit
|
|
373
|
+
return self
|
|
374
|
+
|
|
375
|
+
def global_config(
|
|
376
|
+
self,
|
|
377
|
+
config: GlobalConfiguration | None,
|
|
378
|
+
) -> ExportConfigBuilder:
|
|
379
|
+
"""Set global configuration.
|
|
380
|
+
|
|
381
|
+
Args:
|
|
382
|
+
config: The global configuration from the config file.
|
|
383
|
+
"""
|
|
384
|
+
self._config = config
|
|
385
|
+
return self
|
|
386
|
+
|
|
387
|
+
def fmu_dir(self, fmu_dir: ProjectFMUDirectory | None) -> ExportConfigBuilder:
|
|
388
|
+
"""Set project FMU directory.
|
|
389
|
+
|
|
390
|
+
Args:
|
|
391
|
+
fmu_dir: The project FMU directory or None.
|
|
392
|
+
"""
|
|
393
|
+
self._fmu_dir = fmu_dir
|
|
394
|
+
return self
|
|
395
|
+
|
|
396
|
+
def run_context(
|
|
397
|
+
self,
|
|
398
|
+
*,
|
|
399
|
+
fmu_context: FMUContext | None = None,
|
|
400
|
+
casepath: Path | None = None,
|
|
401
|
+
ensemble_name: str | None = None,
|
|
402
|
+
) -> ExportConfigBuilder:
|
|
403
|
+
"""Set run context parameters explicitly.
|
|
404
|
+
|
|
405
|
+
If this method is not called, the run context will be automatically detected
|
|
406
|
+
from the environment when build() is called.
|
|
407
|
+
|
|
408
|
+
Args:
|
|
409
|
+
fmu_context: The FMU context (case, realization, etc.).
|
|
410
|
+
casepath: The path to the case directory.
|
|
411
|
+
"""
|
|
412
|
+
self._fmu_context = fmu_context
|
|
413
|
+
self._casepath = casepath
|
|
414
|
+
self._ensemble_name = ensemble_name
|
|
415
|
+
self._run_context_called = True
|
|
416
|
+
return self
|
|
417
|
+
|
|
418
|
+
def _build_run_context(self) -> RunContext:
|
|
419
|
+
"""Build RunContext.
|
|
420
|
+
|
|
421
|
+
Auto-detects from environment if needed."""
|
|
422
|
+
if self._run_context_called:
|
|
423
|
+
return RunContext(
|
|
424
|
+
casepath_proposed=self._casepath,
|
|
425
|
+
fmu_context=self._fmu_context,
|
|
426
|
+
ensemble_name=self._ensemble_name,
|
|
427
|
+
)
|
|
428
|
+
|
|
429
|
+
fmu_context, preprocessed = _resolve_fmu_context(
|
|
430
|
+
fmu_context_input=None,
|
|
431
|
+
preprocessed_input=self._preprocessed,
|
|
432
|
+
)
|
|
433
|
+
|
|
434
|
+
if preprocessed:
|
|
435
|
+
self._preprocessed = preprocessed
|
|
436
|
+
|
|
437
|
+
return RunContext(
|
|
438
|
+
casepath_proposed=None,
|
|
439
|
+
fmu_context=fmu_context,
|
|
440
|
+
)
|
|
441
|
+
|
|
442
|
+
def standard_result(self, name: StandardResultName) -> ExportConfigBuilder:
|
|
443
|
+
"""Set standard result."""
|
|
444
|
+
self._standard_result = StandardResultAdapter.validate_python({"name": name})
|
|
445
|
+
return self
|
|
446
|
+
|
|
447
|
+
def tracklog_source(self, name: str, version: str) -> ExportConfigBuilder:
|
|
448
|
+
self._tracklog_source = TracklogSource(name=name, version=version)
|
|
449
|
+
return self
|
|
450
|
+
|
|
451
|
+
def build(self) -> ExportConfig:
|
|
452
|
+
"""Build the immutable ExportConfig.
|
|
453
|
+
|
|
454
|
+
If run_context() was not called, the run context will be automatically detected
|
|
455
|
+
from the FMU environment.
|
|
456
|
+
|
|
457
|
+
Returns:
|
|
458
|
+
Configured ExportConfig instance.
|
|
459
|
+
|
|
460
|
+
Raises:
|
|
461
|
+
ValueError: If content is not set.
|
|
462
|
+
"""
|
|
463
|
+
if self._content is None:
|
|
464
|
+
raise ValueError("content must be set before building")
|
|
465
|
+
|
|
466
|
+
runcontext = self._build_run_context()
|
|
467
|
+
|
|
468
|
+
if self._fmu_dir is None:
|
|
469
|
+
self._fmu_dir = _resolve_fmu_dir()
|
|
470
|
+
|
|
471
|
+
return ExportConfig(
|
|
472
|
+
content=self._content,
|
|
473
|
+
content_metadata=self._content_metadata,
|
|
474
|
+
name=self._name,
|
|
475
|
+
tagname=self._tagname,
|
|
476
|
+
forcefolder=self._forcefolder,
|
|
477
|
+
subfolder=self._subfolder,
|
|
478
|
+
parent=self._parent,
|
|
479
|
+
filename_timedata_reverse=self._filename_timedata_reverse,
|
|
480
|
+
geometry=self._geometry,
|
|
481
|
+
vertical_domain=self._vertical_domain,
|
|
482
|
+
domain_reference=self._domain_reference,
|
|
483
|
+
display=self._display,
|
|
484
|
+
workflow=self._workflow,
|
|
485
|
+
description=self._description,
|
|
486
|
+
classification=self._classification,
|
|
487
|
+
rep_include=self._rep_include,
|
|
488
|
+
table_index=self._table_index,
|
|
489
|
+
table_fformat=self._table_fformat,
|
|
490
|
+
polygons_fformat=self._polygons_fformat,
|
|
491
|
+
points_fformat=self._points_fformat,
|
|
492
|
+
timedata=self._timedata,
|
|
493
|
+
preprocessed=self._preprocessed,
|
|
494
|
+
is_prediction=self._is_prediction,
|
|
495
|
+
is_observation=self._is_observation,
|
|
496
|
+
unit=self._unit,
|
|
497
|
+
undef_is_zero=self._undef_is_zero,
|
|
498
|
+
config=self._config,
|
|
499
|
+
fmu_dir=self._fmu_dir,
|
|
500
|
+
runcontext=runcontext,
|
|
501
|
+
standard_result=self._standard_result,
|
|
502
|
+
tracklog_source=self._tracklog_source,
|
|
503
|
+
)
|