fmu-settings 0.3.1__py3-none-any.whl → 0.3.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.
Potentially problematic release.
This version of fmu-settings might be problematic. Click here for more details.
- fmu/settings/_resources/pydantic_resource_manager.py +11 -4
- fmu/settings/_version.py +2 -2
- {fmu_settings-0.3.1.dist-info → fmu_settings-0.3.2.dist-info}/METADATA +1 -1
- {fmu_settings-0.3.1.dist-info → fmu_settings-0.3.2.dist-info}/RECORD +7 -7
- {fmu_settings-0.3.1.dist-info → fmu_settings-0.3.2.dist-info}/WHEEL +0 -0
- {fmu_settings-0.3.1.dist-info → fmu_settings-0.3.2.dist-info}/licenses/LICENSE +0 -0
- {fmu_settings-0.3.1.dist-info → fmu_settings-0.3.2.dist-info}/top_level.txt +0 -0
|
@@ -48,11 +48,14 @@ class PydanticResourceManager(Generic[T]):
|
|
|
48
48
|
"""Returns whether or not the resource exists."""
|
|
49
49
|
return self.path.exists()
|
|
50
50
|
|
|
51
|
-
def load(self: Self, force: bool = False) -> T:
|
|
52
|
-
"""Loads the
|
|
51
|
+
def load(self: Self, force: bool = False, store_cache: bool = True) -> T:
|
|
52
|
+
"""Loads the resource from disk and validates it as a Pydantic model.
|
|
53
53
|
|
|
54
54
|
Args:
|
|
55
|
-
force: Force a re-read even if the file is already cached
|
|
55
|
+
force: Force a re-read even if the file is already cached.
|
|
56
|
+
store_cache: Whether or not to cache the loaded model internally. This is
|
|
57
|
+
best used with 'force=True' because if a model is already stored in
|
|
58
|
+
_cache it will be returned without re-loading. Default True.
|
|
56
59
|
|
|
57
60
|
Returns:
|
|
58
61
|
Validated Pydantic model
|
|
@@ -71,7 +74,11 @@ class PydanticResourceManager(Generic[T]):
|
|
|
71
74
|
try:
|
|
72
75
|
content = self.fmu_dir.read_text_file(self.relative_path)
|
|
73
76
|
data = json.loads(content)
|
|
74
|
-
|
|
77
|
+
validated_model = self.model_class.model_validate(data)
|
|
78
|
+
if store_cache:
|
|
79
|
+
self._cache = validated_model
|
|
80
|
+
else:
|
|
81
|
+
return validated_model
|
|
75
82
|
except ValidationError as e:
|
|
76
83
|
raise ValueError(
|
|
77
84
|
f"Invalid content in resource file for '{self.__class__.__name__}: "
|
fmu/settings/_version.py
CHANGED
|
@@ -28,7 +28,7 @@ version_tuple: VERSION_TUPLE
|
|
|
28
28
|
commit_id: COMMIT_ID
|
|
29
29
|
__commit_id__: COMMIT_ID
|
|
30
30
|
|
|
31
|
-
__version__ = version = '0.3.
|
|
32
|
-
__version_tuple__ = version_tuple = (0, 3,
|
|
31
|
+
__version__ = version = '0.3.2'
|
|
32
|
+
__version_tuple__ = version_tuple = (0, 3, 2)
|
|
33
33
|
|
|
34
34
|
__commit_id__ = commit_id = None
|
|
@@ -3,21 +3,21 @@ fmu/settings/__init__.py,sha256=CkEE7al_uBCQO1lxBKN5LzyCwzzH5Aq6kkEIR7f-zTw,336
|
|
|
3
3
|
fmu/settings/_fmu_dir.py,sha256=Br_hcfAXshiuDyWqG_qx5VXFpsCBJO1XDMPzdxxesoE,10684
|
|
4
4
|
fmu/settings/_init.py,sha256=5CT7tV2XHz5wuLh97XozyLiKpwogrsfjpxm2dpn7KWE,4097
|
|
5
5
|
fmu/settings/_logging.py,sha256=nEdmZlNCBsB1GfDmFMKCjZmeuRp3CRlbz1EYUemc95Y,1104
|
|
6
|
-
fmu/settings/_version.py,sha256=
|
|
6
|
+
fmu/settings/_version.py,sha256=e8NqPtZ8fggRgk3GPrqZ_U_BDV8aSULw1u_Gn9NNbnk,704
|
|
7
7
|
fmu/settings/py.typed,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
8
8
|
fmu/settings/types.py,sha256=aeXEsznBTT1YRRY_LSRqK1j2gmMmyLYYTGYl3a9fweU,513
|
|
9
9
|
fmu/settings/_resources/__init__.py,sha256=LHYR_F7lNGdv8N6R3cEwds5CJQpkOthXFqsEs24vgF8,118
|
|
10
10
|
fmu/settings/_resources/config_managers.py,sha256=IjOtS2lSU55GE_TWqHjbBPAzE8xQyVBvpHcfm0hTSnI,6822
|
|
11
11
|
fmu/settings/_resources/lock_manager.py,sha256=_xzSJNF_qcpKpo8AxMfEgOhPxKXl3fZ2lRi0_y2eUEg,9206
|
|
12
|
-
fmu/settings/_resources/pydantic_resource_manager.py,sha256=
|
|
12
|
+
fmu/settings/_resources/pydantic_resource_manager.py,sha256=NV9qGnKaZ2RYt6o2NMaHvKyiZDIsxwD5y3y2a6QQtHw,3555
|
|
13
13
|
fmu/settings/models/__init__.py,sha256=lRlXgl55ba2upmDzdvzx8N30JMq2Osnm8aa_xxTZn8A,112
|
|
14
14
|
fmu/settings/models/_enums.py,sha256=SQUZ-2mQcTx4F0oefPFfuQzMKsKTSFSB-wq_CH7TBRE,734
|
|
15
15
|
fmu/settings/models/_mappings.py,sha256=Z4Ex7MtmajBr6FjaNzmwDRwtJlaZZ8YKh9NDmZHRKPI,2832
|
|
16
16
|
fmu/settings/models/lock_info.py,sha256=-oHDF9v9bDLCoFvEg4S6XXYLeo19zRAZ8HynCv75VWg,711
|
|
17
17
|
fmu/settings/models/project_config.py,sha256=pxb54JmpXNMVAFUu_yJ89dNrYEk6hrPuFfFUpf84Jh0,1099
|
|
18
18
|
fmu/settings/models/user_config.py,sha256=dWFTcZY6UnEgNTuGqB-izraJ657PecsW0e0Nt9GBDhI,2666
|
|
19
|
-
fmu_settings-0.3.
|
|
20
|
-
fmu_settings-0.3.
|
|
21
|
-
fmu_settings-0.3.
|
|
22
|
-
fmu_settings-0.3.
|
|
23
|
-
fmu_settings-0.3.
|
|
19
|
+
fmu_settings-0.3.2.dist-info/licenses/LICENSE,sha256=OXLcl0T2SZ8Pmy2_dmlvKuetivmyPd5m1q-Gyd-zaYY,35149
|
|
20
|
+
fmu_settings-0.3.2.dist-info/METADATA,sha256=CC-jegtLPAS2vpUajvXTd3D_Fyow5q62Dwy4WDH4ypA,2024
|
|
21
|
+
fmu_settings-0.3.2.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
|
|
22
|
+
fmu_settings-0.3.2.dist-info/top_level.txt,sha256=Z-FIY3pxn0UK2Wxi9IJ7fKoLSraaxuNGi1eokiE0ShM,4
|
|
23
|
+
fmu_settings-0.3.2.dist-info/RECORD,,
|
|
File without changes
|
|
File without changes
|
|
File without changes
|