fmu-settings 0.0.1__py3-none-any.whl → 0.2.0__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.

Potentially problematic release.


This version of fmu-settings might be problematic. Click here for more details.

fmu/settings/_fmu_dir.py CHANGED
@@ -4,12 +4,12 @@ from pathlib import Path
4
4
  from typing import Any, Final, Self, TypeAlias, cast
5
5
 
6
6
  from ._logging import null_logger
7
- from .models.project_config import ProjectConfig
8
- from .models.user_config import UserConfig
9
- from .resources.config_managers import (
7
+ from ._resources.config_managers import (
10
8
  ProjectConfigManager,
11
9
  UserConfigManager,
12
10
  )
11
+ from .models.project_config import ProjectConfig
12
+ from .models.user_config import UserConfig
13
13
 
14
14
  logger: Final = null_logger(__name__)
15
15
 
@@ -0,0 +1,5 @@
1
+ """Contains resources used in this package.
2
+
3
+ Some resources contained here may also be used
4
+ outside this package.
5
+ """
@@ -13,7 +13,7 @@ from fmu.settings.models.project_config import ProjectConfig
13
13
  from fmu.settings.models.user_config import UserConfig
14
14
  from fmu.settings.types import ResettableBaseModel, VersionStr # noqa TC001
15
15
 
16
- from .managers import PydanticResourceManager
16
+ from .pydantic_resource_manager import PydanticResourceManager
17
17
 
18
18
  if TYPE_CHECKING:
19
19
  # Avoid circular dependency for type hint in __init__ only
@@ -73,7 +73,7 @@ class ConfigManager(PydanticResourceManager[T]):
73
73
  default: Value to return if key is not found. Default None
74
74
 
75
75
  Returns:
76
- The configuration value or deafult
76
+ The configuration value or default
77
77
  """
78
78
  try:
79
79
  config = self.load()
fmu/settings/_version.py CHANGED
@@ -1,7 +1,14 @@
1
1
  # file generated by setuptools-scm
2
2
  # don't change, don't track in version control
3
3
 
4
- __all__ = ["__version__", "__version_tuple__", "version", "version_tuple"]
4
+ __all__ = [
5
+ "__version__",
6
+ "__version_tuple__",
7
+ "version",
8
+ "version_tuple",
9
+ "__commit_id__",
10
+ "commit_id",
11
+ ]
5
12
 
6
13
  TYPE_CHECKING = False
7
14
  if TYPE_CHECKING:
@@ -9,13 +16,19 @@ if TYPE_CHECKING:
9
16
  from typing import Union
10
17
 
11
18
  VERSION_TUPLE = Tuple[Union[int, str], ...]
19
+ COMMIT_ID = Union[str, None]
12
20
  else:
13
21
  VERSION_TUPLE = object
22
+ COMMIT_ID = object
14
23
 
15
24
  version: str
16
25
  __version__: str
17
26
  __version_tuple__: VERSION_TUPLE
18
27
  version_tuple: VERSION_TUPLE
28
+ commit_id: COMMIT_ID
29
+ __commit_id__: COMMIT_ID
19
30
 
20
- __version__ = version = '0.0.1'
21
- __version_tuple__ = version_tuple = (0, 0, 1)
31
+ __version__ = version = '0.2.0'
32
+ __version_tuple__ = version_tuple = (0, 2, 0)
33
+
34
+ __commit_id__ = commit_id = None
@@ -6,7 +6,7 @@ from uuid import UUID
6
6
 
7
7
  from pydantic import BaseModel, RootModel
8
8
 
9
- from fmu.dataio._models.enums import Content # type: ignore
9
+ from fmu.datamodels.enums import Content # type: ignore
10
10
 
11
11
  from ._enums import (
12
12
  DataEntrySource,
@@ -3,25 +3,13 @@
3
3
  import getpass
4
4
  from datetime import UTC, datetime
5
5
  from typing import Self
6
- from uuid import UUID # noqa TC003
7
6
 
8
- from pydantic import AwareDatetime, BaseModel, Field
7
+ from pydantic import AwareDatetime, Field
9
8
 
9
+ from fmu.datamodels.fmu_results.fields import Access, Masterdata, Model
10
10
  from fmu.settings import __version__
11
11
  from fmu.settings.types import ResettableBaseModel, VersionStr # noqa TC001
12
12
 
13
- from .smda import Smda
14
-
15
-
16
- class Masterdata(BaseModel):
17
- """The ``masterdata`` block contains information related to masterdata.
18
-
19
- Currently, SMDA holds the masterdata.
20
- """
21
-
22
- smda: Smda | None = Field(default=None)
23
- """Block containing SMDA-related attributes. See :class:`Smda`."""
24
-
25
13
 
26
14
  class ProjectConfig(ResettableBaseModel):
27
15
  """The configuration file in a .fmu directory.
@@ -32,7 +20,9 @@ class ProjectConfig(ResettableBaseModel):
32
20
  version: VersionStr
33
21
  created_at: AwareDatetime
34
22
  created_by: str
35
- masterdata: Masterdata
23
+ masterdata: Masterdata | None = Field(default=None)
24
+ model: Model | None = Field(default=None)
25
+ access: Access | None = Field(default=None)
36
26
 
37
27
  @classmethod
38
28
  def reset(cls: type[Self]) -> Self:
@@ -45,5 +35,7 @@ class ProjectConfig(ResettableBaseModel):
45
35
  version=__version__,
46
36
  created_at=datetime.now(UTC),
47
37
  created_by=getpass.getuser(),
48
- masterdata=Masterdata(),
38
+ masterdata=None,
39
+ model=None,
40
+ access=None,
49
41
  )
@@ -8,12 +8,18 @@ from typing import Annotated, Self
8
8
  from uuid import UUID # noqa TC003
9
9
 
10
10
  import annotated_types
11
- from pydantic import AwareDatetime, BaseModel, SecretStr, field_serializer
11
+ from pydantic import (
12
+ AwareDatetime,
13
+ BaseModel,
14
+ SecretStr,
15
+ field_serializer,
16
+ field_validator,
17
+ )
12
18
 
13
19
  from fmu.settings import __version__
14
20
  from fmu.settings.types import ResettableBaseModel, VersionStr # noqa TC001
15
21
 
16
- RecentDirectories = Annotated[set[Path], annotated_types.Len(0, 5)]
22
+ RecentProjectDirectories = Annotated[list[Path], annotated_types.Len(0, 5)]
17
23
 
18
24
 
19
25
  class UserAPIKeys(BaseModel):
@@ -38,7 +44,7 @@ class UserConfig(ResettableBaseModel):
38
44
  version: VersionStr
39
45
  created_at: AwareDatetime
40
46
  user_api_keys: UserAPIKeys
41
- recent_directories: RecentDirectories
47
+ recent_project_directories: RecentProjectDirectories
42
48
 
43
49
  @classmethod
44
50
  def reset(cls: type[Self]) -> Self:
@@ -47,9 +53,17 @@ class UserConfig(ResettableBaseModel):
47
53
  version=__version__,
48
54
  created_at=datetime.now(UTC),
49
55
  user_api_keys=UserAPIKeys(),
50
- recent_directories=set(),
56
+ recent_project_directories=[],
51
57
  )
52
58
 
59
+ @field_validator("recent_project_directories", mode="before")
60
+ @classmethod
61
+ def ensure_unique(cls, recent_projects: list[Path]) -> list[Path]:
62
+ """Ensures that recent_project_directories contains unique entries."""
63
+ if len(recent_projects) != len(set(recent_projects)):
64
+ raise ValueError("recent_project_directories must contain unique entries")
65
+ return recent_projects
66
+
53
67
  def obfuscate_secrets(self: Self) -> Self:
54
68
  """Returns a copy of the model with obfuscated secrets.
55
69
 
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: fmu-settings
3
- Version: 0.0.1
3
+ Version: 0.2.0
4
4
  Summary: A library for managing FMU settings
5
5
  Author-email: Equinor <fg-fmu_atlas@equinor.com>
6
6
  License: GPL-3.0
@@ -18,7 +18,7 @@ Requires-Python: >=3.11
18
18
  Description-Content-Type: text/markdown
19
19
  License-File: LICENSE
20
20
  Requires-Dist: annotated_types
21
- Requires-Dist: fmu-dataio
21
+ Requires-Dist: fmu-datamodels
22
22
  Requires-Dist: pydantic
23
23
  Provides-Extra: dev
24
24
  Requires-Dist: mypy; extra == "dev"
@@ -0,0 +1,21 @@
1
+ fmu/__init__.py,sha256=htx6HlMme77I6pZ8U256-2B2cMJuELsu3JN3YM2Efh4,144
2
+ fmu/settings/__init__.py,sha256=x96dVVR-2n2lYD84LGbL7W8l3-r7W_0reUTKZlE7S34,331
3
+ fmu/settings/_fmu_dir.py,sha256=E8ULohZKwMixkuw9cXK20IxaHaRXmWQ1vbE02QAX_YU,10573
4
+ fmu/settings/_init.py,sha256=5CT7tV2XHz5wuLh97XozyLiKpwogrsfjpxm2dpn7KWE,4097
5
+ fmu/settings/_logging.py,sha256=nEdmZlNCBsB1GfDmFMKCjZmeuRp3CRlbz1EYUemc95Y,1104
6
+ fmu/settings/_version.py,sha256=Dg8AmJomLVpjKL6prJylOONZAPRtB86LOce7dorQS_A,704
7
+ fmu/settings/py.typed,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
8
+ fmu/settings/types.py,sha256=aeXEsznBTT1YRRY_LSRqK1j2gmMmyLYYTGYl3a9fweU,513
9
+ fmu/settings/_resources/__init__.py,sha256=LHYR_F7lNGdv8N6R3cEwds5CJQpkOthXFqsEs24vgF8,118
10
+ fmu/settings/_resources/config_managers.py,sha256=b8DUtRHti1n2pSuw5eCQko7e7NKOzP2BH6dNPJFd2ck,6869
11
+ fmu/settings/_resources/pydantic_resource_manager.py,sha256=t4Rp6MOSIq85iKfDHZLJxeGRj8S3SKanWHWri0p9wV8,3161
12
+ fmu/settings/models/__init__.py,sha256=lRlXgl55ba2upmDzdvzx8N30JMq2Osnm8aa_xxTZn8A,112
13
+ fmu/settings/models/_enums.py,sha256=SQUZ-2mQcTx4F0oefPFfuQzMKsKTSFSB-wq_CH7TBRE,734
14
+ fmu/settings/models/_mappings.py,sha256=Z4Ex7MtmajBr6FjaNzmwDRwtJlaZZ8YKh9NDmZHRKPI,2832
15
+ fmu/settings/models/project_config.py,sha256=K7y4PZMuq5wD-0Br60xfffBN6QQUV8viKGjjOcCB-7M,1098
16
+ fmu/settings/models/user_config.py,sha256=UrRcbxJAGn1e7IeE0_v1oPWVOk-DGekRG49pXzDr83o,2701
17
+ fmu_settings-0.2.0.dist-info/licenses/LICENSE,sha256=OXLcl0T2SZ8Pmy2_dmlvKuetivmyPd5m1q-Gyd-zaYY,35149
18
+ fmu_settings-0.2.0.dist-info/METADATA,sha256=Kjzn1O0vvAAYoYAoC-Jo8IzN0H-V7HWwwV3Io47N41w,2024
19
+ fmu_settings-0.2.0.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
20
+ fmu_settings-0.2.0.dist-info/top_level.txt,sha256=Z-FIY3pxn0UK2Wxi9IJ7fKoLSraaxuNGi1eokiE0ShM,4
21
+ fmu_settings-0.2.0.dist-info/RECORD,,
@@ -1,90 +0,0 @@
1
- """Models for SMDA masterdata."""
2
-
3
- from uuid import UUID
4
-
5
- from pydantic import BaseModel, Field
6
-
7
- from fmu.settings.types import VersionStr # noqa TC001
8
-
9
-
10
- class SmdaIdentifier(BaseModel):
11
- """The identifier for something known to SMDA."""
12
-
13
- identifier: str
14
- """Identifier known to SMDA."""
15
-
16
- uuid: UUID
17
- """Identifier known to SMDA."""
18
-
19
-
20
- class CountryItem(SmdaIdentifier):
21
- """A single country in the list of countries known to SMDA."""
22
-
23
- identifier: str = Field(examples=["Norway"])
24
- """Identifier known to SMDA."""
25
-
26
- uuid: UUID = Field(examples=["15ce3b84-766f-4c93-9050-b154861f9100"])
27
- """Identifier known to SMDA."""
28
-
29
-
30
- class FieldItem(SmdaIdentifier):
31
- """A single field in the list of fields known to SMDA."""
32
-
33
- identifier: str = Field(examples=["OseFax"])
34
- """Identifier known to SMDA."""
35
-
36
- uuid: UUID = Field(examples=["15ce3b84-766f-4c93-9050-b154861f9100"])
37
- """Identifier known to SMDA."""
38
-
39
-
40
- class CoordinateSystem(SmdaIdentifier):
41
- """Contains the coordinate system known to SMDA."""
42
-
43
- identifier: str = Field(examples=["ST_WGS84_UTM37N_P32637"])
44
- """Identifier known to SMDA."""
45
-
46
- uuid: UUID = Field(examples=["15ce3b84-766f-4c93-9050-b154861f9100"])
47
- """Identifier known to SMDA."""
48
-
49
-
50
- class StratigraphicColumn(SmdaIdentifier):
51
- """Contains the stratigraphic column known to SMDA."""
52
-
53
- identifier: str = Field(examples=["DROGON_2020"])
54
- """Identifier known to SMDA."""
55
-
56
- uuid: UUID = Field(examples=["15ce3b84-766f-4c93-9050-b154861f9100"])
57
- """Identifier known to SMDA."""
58
-
59
-
60
- class DiscoveryItem(BaseModel):
61
- """A single discovery in the list of discoveries known to SMDA."""
62
-
63
- short_identifier: str = Field(examples=["SomeDiscovery"])
64
- """Identifier known to SMDA."""
65
-
66
- uuid: UUID = Field(examples=["15ce3b84-766f-4c93-9050-b154861f9100"])
67
- """Identifier known to SMDA."""
68
-
69
-
70
- class Smda(BaseModel):
71
- """Contains SMDA-related attributes."""
72
-
73
- coordinate_system: CoordinateSystem
74
- """Reference to coordinate system known to SMDA. See :class:`CoordinateSystem`."""
75
-
76
- country: list[CountryItem]
77
- """A list referring to countries known to SMDA. First item is primary.
78
- See :class:`CountryItem`."""
79
-
80
- discovery: list[DiscoveryItem]
81
- """A list referring to discoveries known to SMDA. First item is primary.
82
- See :class:`DiscoveryItem`."""
83
-
84
- field: list[FieldItem]
85
- """A list referring to fields known to SMDA. First item is primary.
86
- See :class:`FieldItem`."""
87
-
88
- stratigraphic_column: StratigraphicColumn
89
- """Reference to stratigraphic column known to SMDA.
90
- See :class:`StratigraphicColumn`."""
@@ -1,21 +0,0 @@
1
- fmu/__init__.py,sha256=htx6HlMme77I6pZ8U256-2B2cMJuELsu3JN3YM2Efh4,144
2
- fmu/settings/__init__.py,sha256=x96dVVR-2n2lYD84LGbL7W8l3-r7W_0reUTKZlE7S34,331
3
- fmu/settings/_fmu_dir.py,sha256=-w3cB0_2WCKYkXTmoOQtZHI_fHfCDbnzEtTF_lcYod8,10572
4
- fmu/settings/_init.py,sha256=5CT7tV2XHz5wuLh97XozyLiKpwogrsfjpxm2dpn7KWE,4097
5
- fmu/settings/_logging.py,sha256=nEdmZlNCBsB1GfDmFMKCjZmeuRp3CRlbz1EYUemc95Y,1104
6
- fmu/settings/_version.py,sha256=vgltXBYF55vNcC2regxjGN0_cbebmm8VgcDdQaDapWQ,511
7
- fmu/settings/py.typed,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
8
- fmu/settings/types.py,sha256=aeXEsznBTT1YRRY_LSRqK1j2gmMmyLYYTGYl3a9fweU,513
9
- fmu/settings/models/__init__.py,sha256=lRlXgl55ba2upmDzdvzx8N30JMq2Osnm8aa_xxTZn8A,112
10
- fmu/settings/models/_enums.py,sha256=SQUZ-2mQcTx4F0oefPFfuQzMKsKTSFSB-wq_CH7TBRE,734
11
- fmu/settings/models/_mappings.py,sha256=uaSAE_0y88Gvv-vM3VR5xx7yuXn9mio_8V3YC1t9wLI,2836
12
- fmu/settings/models/project_config.py,sha256=vImpk_rPrMEn3G9NZj83Recq9YzqAABQS7ZVUlBa0vM,1207
13
- fmu/settings/models/smda.py,sha256=nQ3-EI2VDRappwHgipLLXnWbEVQCsLrtJn14lES2Q6g,2639
14
- fmu/settings/models/user_config.py,sha256=JhMeSmWcE4GrBRkM_D5QVnUbRKfVy_XakHeKqJrYxvE,2217
15
- fmu/settings/resources/config_managers.py,sha256=4rA2xXS8BoNkM-RCfhJ6FNiwRGW_jTckZzpT_llkqlY,6852
16
- fmu/settings/resources/managers.py,sha256=t4Rp6MOSIq85iKfDHZLJxeGRj8S3SKanWHWri0p9wV8,3161
17
- fmu_settings-0.0.1.dist-info/licenses/LICENSE,sha256=OXLcl0T2SZ8Pmy2_dmlvKuetivmyPd5m1q-Gyd-zaYY,35149
18
- fmu_settings-0.0.1.dist-info/METADATA,sha256=_Jt3s4v_3G-lhNAd4S8ocOYZ0_KoRQEdCRCIvaQqO68,2020
19
- fmu_settings-0.0.1.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
20
- fmu_settings-0.0.1.dist-info/top_level.txt,sha256=Z-FIY3pxn0UK2Wxi9IJ7fKoLSraaxuNGi1eokiE0ShM,4
21
- fmu_settings-0.0.1.dist-info/RECORD,,