fmu-settings 0.0.1__tar.gz → 0.1.0__tar.gz

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.

Files changed (40) hide show
  1. {fmu_settings-0.0.1 → fmu_settings-0.1.0}/PKG-INFO +2 -2
  2. {fmu_settings-0.0.1 → fmu_settings-0.1.0}/pyproject.toml +1 -1
  3. {fmu_settings-0.0.1 → fmu_settings-0.1.0}/src/fmu/settings/_version.py +16 -3
  4. {fmu_settings-0.0.1 → fmu_settings-0.1.0}/src/fmu/settings/models/_mappings.py +1 -1
  5. {fmu_settings-0.0.1 → fmu_settings-0.1.0}/src/fmu/settings/models/project_config.py +8 -16
  6. {fmu_settings-0.0.1 → fmu_settings-0.1.0}/src/fmu/settings/resources/config_managers.py +1 -1
  7. {fmu_settings-0.0.1 → fmu_settings-0.1.0}/src/fmu_settings.egg-info/PKG-INFO +2 -2
  8. {fmu_settings-0.0.1 → fmu_settings-0.1.0}/src/fmu_settings.egg-info/SOURCES.txt +0 -1
  9. {fmu_settings-0.0.1 → fmu_settings-0.1.0}/src/fmu_settings.egg-info/requires.txt +1 -1
  10. {fmu_settings-0.0.1 → fmu_settings-0.1.0}/tests/conftest.py +26 -4
  11. {fmu_settings-0.0.1 → fmu_settings-0.1.0}/tests/test_resources/test_project_config.py +77 -2
  12. fmu_settings-0.0.1/src/fmu/settings/models/smda.py +0 -90
  13. {fmu_settings-0.0.1 → fmu_settings-0.1.0}/.coveragerc +0 -0
  14. {fmu_settings-0.0.1 → fmu_settings-0.1.0}/.github/pull_request_template.md +0 -0
  15. {fmu_settings-0.0.1 → fmu_settings-0.1.0}/.github/workflows/ci.yml +0 -0
  16. {fmu_settings-0.0.1 → fmu_settings-0.1.0}/.github/workflows/codeql.yml +0 -0
  17. {fmu_settings-0.0.1 → fmu_settings-0.1.0}/.github/workflows/publish.yml +0 -0
  18. {fmu_settings-0.0.1 → fmu_settings-0.1.0}/.gitignore +0 -0
  19. {fmu_settings-0.0.1 → fmu_settings-0.1.0}/CONTRIBUTING.md +0 -0
  20. {fmu_settings-0.0.1 → fmu_settings-0.1.0}/LICENSE +0 -0
  21. {fmu_settings-0.0.1 → fmu_settings-0.1.0}/README.md +0 -0
  22. {fmu_settings-0.0.1 → fmu_settings-0.1.0}/SECURITY.md +0 -0
  23. {fmu_settings-0.0.1 → fmu_settings-0.1.0}/setup.cfg +0 -0
  24. {fmu_settings-0.0.1 → fmu_settings-0.1.0}/src/fmu/__init__.py +0 -0
  25. {fmu_settings-0.0.1 → fmu_settings-0.1.0}/src/fmu/settings/__init__.py +0 -0
  26. {fmu_settings-0.0.1 → fmu_settings-0.1.0}/src/fmu/settings/_fmu_dir.py +0 -0
  27. {fmu_settings-0.0.1 → fmu_settings-0.1.0}/src/fmu/settings/_init.py +0 -0
  28. {fmu_settings-0.0.1 → fmu_settings-0.1.0}/src/fmu/settings/_logging.py +0 -0
  29. {fmu_settings-0.0.1 → fmu_settings-0.1.0}/src/fmu/settings/models/__init__.py +0 -0
  30. {fmu_settings-0.0.1 → fmu_settings-0.1.0}/src/fmu/settings/models/_enums.py +0 -0
  31. {fmu_settings-0.0.1 → fmu_settings-0.1.0}/src/fmu/settings/models/user_config.py +0 -0
  32. {fmu_settings-0.0.1 → fmu_settings-0.1.0}/src/fmu/settings/py.typed +0 -0
  33. {fmu_settings-0.0.1 → fmu_settings-0.1.0}/src/fmu/settings/resources/managers.py +0 -0
  34. {fmu_settings-0.0.1 → fmu_settings-0.1.0}/src/fmu/settings/types.py +0 -0
  35. {fmu_settings-0.0.1 → fmu_settings-0.1.0}/src/fmu_settings.egg-info/dependency_links.txt +0 -0
  36. {fmu_settings-0.0.1 → fmu_settings-0.1.0}/src/fmu_settings.egg-info/top_level.txt +0 -0
  37. {fmu_settings-0.0.1 → fmu_settings-0.1.0}/tests/test_fmu_dir.py +0 -0
  38. {fmu_settings-0.0.1 → fmu_settings-0.1.0}/tests/test_init.py +0 -0
  39. {fmu_settings-0.0.1 → fmu_settings-0.1.0}/tests/test_resources/test_resource_managers.py +0 -0
  40. {fmu_settings-0.0.1 → fmu_settings-0.1.0}/tests/test_resources/test_user_config.py +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: fmu-settings
3
- Version: 0.0.1
3
+ Version: 0.1.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"
@@ -29,7 +29,7 @@ classifiers = [
29
29
  dynamic = ["version"]
30
30
  dependencies = [
31
31
  "annotated_types", # Dependency in Pydantic also
32
- "fmu-dataio",
32
+ "fmu-datamodels",
33
33
  "pydantic",
34
34
  ]
35
35
 
@@ -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.1.0'
32
+ __version_tuple__ = version_tuple = (0, 1, 0)
33
+
34
+ __commit_id__ = commit_id = 'gc714eb4cf'
@@ -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
  )
@@ -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()
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: fmu-settings
3
- Version: 0.0.1
3
+ Version: 0.1.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"
@@ -21,7 +21,6 @@ src/fmu/settings/models/__init__.py
21
21
  src/fmu/settings/models/_enums.py
22
22
  src/fmu/settings/models/_mappings.py
23
23
  src/fmu/settings/models/project_config.py
24
- src/fmu/settings/models/smda.py
25
24
  src/fmu/settings/models/user_config.py
26
25
  src/fmu/settings/resources/config_managers.py
27
26
  src/fmu/settings/resources/managers.py
@@ -1,5 +1,5 @@
1
1
  annotated_types
2
- fmu-dataio
2
+ fmu-datamodels
3
3
  pydantic
4
4
 
5
5
  [dev]
@@ -27,9 +27,9 @@ def config_dict(unix_epoch_utc: datetime) -> dict[str, Any]:
27
27
  "version": __version__,
28
28
  "created_at": unix_epoch_utc,
29
29
  "created_by": "user",
30
- "masterdata": {
31
- "smda": None,
32
- },
30
+ "masterdata": None,
31
+ "model": None,
32
+ "access": None,
33
33
  }
34
34
 
35
35
 
@@ -68,9 +68,30 @@ def masterdata_dict() -> dict[str, Any]:
68
68
  }
69
69
 
70
70
 
71
+ @pytest.fixture
72
+ def model_dict() -> dict[str, Any]:
73
+ """Example model information."""
74
+ return {
75
+ "name": "Drogon",
76
+ "revision": "21.0.0",
77
+ "description": None,
78
+ }
79
+
80
+
81
+ @pytest.fixture
82
+ def access_dict() -> dict[str, Any]:
83
+ """Example access information."""
84
+ return {
85
+ "asset": {"name": "Drogon"},
86
+ "classification": "internal",
87
+ }
88
+
89
+
71
90
  @pytest.fixture
72
91
  def config_dict_with_masterdata(
73
- unix_epoch_utc: datetime, masterdata_dict: dict[str, Any]
92
+ unix_epoch_utc: datetime,
93
+ masterdata_dict: dict[str, Any],
94
+ model_dict: dict[str, Any],
74
95
  ) -> dict[str, Any]:
75
96
  """A dictionary representing a .fmu config."""
76
97
  return {
@@ -78,6 +99,7 @@ def config_dict_with_masterdata(
78
99
  "created_at": unix_epoch_utc,
79
100
  "created_by": "user",
80
101
  "masterdata": masterdata_dict,
102
+ "model": model_dict,
81
103
  }
82
104
 
83
105
 
@@ -7,9 +7,9 @@ from typing import Any
7
7
 
8
8
  import pytest
9
9
 
10
+ from fmu.datamodels.fmu_results.fields import Access, Model, Smda
10
11
  from fmu.settings._fmu_dir import ProjectFMUDirectory, UserFMUDirectory
11
12
  from fmu.settings.models.project_config import ProjectConfig
12
- from fmu.settings.models.smda import Smda
13
13
  from fmu.settings.models.user_config import UserConfig
14
14
  from fmu.settings.resources.config_managers import (
15
15
  ProjectConfigManager,
@@ -238,7 +238,7 @@ def test_set_smda(
238
238
  assert fmu_dir.config.get("masterdata.smda") is None
239
239
  with open(fmu_dir.path / fmu_dir.config.relative_path, encoding="utf-8") as f:
240
240
  config_on_disk = json.loads(f.read())
241
- assert config_on_disk["masterdata"]["smda"] is None
241
+ assert config_on_disk["masterdata"] is None
242
242
 
243
243
  fmu_dir.set_config_value("masterdata", masterdata_dict)
244
244
 
@@ -250,10 +250,85 @@ def test_set_smda(
250
250
 
251
251
  config_on_disk_model = ProjectConfig.model_validate(config_on_disk)
252
252
  assert fmu_dir.config._cache is not None
253
+ assert fmu_dir.config._cache.masterdata is not None
253
254
  assert fmu_dir.config._cache.masterdata.smda == smda_model
254
255
  assert config_on_disk_model == fmu_dir.config._cache
255
256
 
256
257
 
258
+ def test_set_model_invalid_fails(
259
+ fmu_dir: ProjectFMUDirectory, model_dict: dict[str, Any]
260
+ ) -> None:
261
+ """Tests setting the model value in the config using an invalid dictionary."""
262
+ assert fmu_dir.config.get("model") is None
263
+
264
+ # drop model.name to test validation
265
+ model_dict.pop("name")
266
+
267
+ with pytest.raises(ValueError, match="model.name"):
268
+ fmu_dir.set_config_value("model", model_dict)
269
+
270
+
271
+ def test_set_model(fmu_dir: ProjectFMUDirectory, model_dict: dict[str, Any]) -> None:
272
+ """Tests setting the model value in the config."""
273
+ assert fmu_dir.config.get("model") is None
274
+ with open(fmu_dir.path / fmu_dir.config.relative_path, encoding="utf-8") as f:
275
+ config_on_disk = json.loads(f.read())
276
+ assert config_on_disk["model"] is None
277
+
278
+ fmu_dir.set_config_value("model", model_dict)
279
+
280
+ model = Model.model_validate(model_dict)
281
+
282
+ assert fmu_dir.get_config_value("model") == model
283
+ assert fmu_dir.get_config_value("model.revision") == "21.0.0"
284
+ assert fmu_dir.get_config_value("model.name") == "Drogon"
285
+
286
+ with open(fmu_dir.path / fmu_dir.config.relative_path, encoding="utf-8") as f:
287
+ config_on_disk = json.loads(f.read())
288
+
289
+ config_on_disk_model = ProjectConfig.model_validate(config_on_disk)
290
+ assert fmu_dir.config._cache is not None
291
+ assert fmu_dir.config._cache.model == model
292
+ assert config_on_disk_model == fmu_dir.config._cache
293
+
294
+
295
+ def test_set_access_invalid_fails(
296
+ fmu_dir: ProjectFMUDirectory, access_dict: dict[str, Any]
297
+ ) -> None:
298
+ """Tests setting the access value in the config using an invalid dictionary."""
299
+ assert fmu_dir.config.get("access") is None
300
+
301
+ # drop access.asset to test validation
302
+ access_dict.pop("asset")
303
+
304
+ with pytest.raises(ValueError, match="access.asset"):
305
+ fmu_dir.set_config_value("access", access_dict)
306
+
307
+
308
+ def test_set_access(fmu_dir: ProjectFMUDirectory, access_dict: dict[str, Any]) -> None:
309
+ """Tests setting the access value in the config."""
310
+ assert fmu_dir.config.get("access") is None
311
+ with open(fmu_dir.path / fmu_dir.config.relative_path, encoding="utf-8") as f:
312
+ config_on_disk = json.loads(f.read())
313
+ assert config_on_disk["access"] is None
314
+
315
+ fmu_dir.set_config_value("access", access_dict)
316
+
317
+ access = Access.model_validate(access_dict)
318
+
319
+ assert fmu_dir.get_config_value("access") == access
320
+ assert fmu_dir.get_config_value("access.classification") == "internal"
321
+ assert fmu_dir.get_config_value("access.asset.name") == "Drogon"
322
+
323
+ with open(fmu_dir.path / fmu_dir.config.relative_path, encoding="utf-8") as f:
324
+ config_on_disk = json.loads(f.read())
325
+
326
+ config_on_disk_model = ProjectConfig.model_validate(config_on_disk)
327
+ assert fmu_dir.config._cache is not None
328
+ assert fmu_dir.config._cache.access == access
329
+ assert config_on_disk_model == fmu_dir.config._cache
330
+
331
+
257
332
  def test_update_config_when_it_does_not_exist(tmp_path: Path) -> None:
258
333
  """Tests getting a key when the config is missing."""
259
334
  empty_fmu_dir = tmp_path / ".fmu"
@@ -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`."""
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes