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

@@ -32,6 +32,10 @@ class LockError(Exception):
32
32
  """Raised when the lock cannot be acquired."""
33
33
 
34
34
 
35
+ class LockNotFoundError(FileNotFoundError):
36
+ """Raised when the lock cannot be found."""
37
+
38
+
35
39
  class LockManager(PydanticResourceManager[LockInfo]):
36
40
  """Manages the .lock file."""
37
41
 
@@ -194,7 +198,9 @@ class LockManager(PydanticResourceManager[LockInfo]):
194
198
  LockError: If we don't hold the lock or it's invalid
195
199
  """
196
200
  if not self.exists:
197
- raise LockError("Cannot refresh: lock file does not exist")
201
+ if self.is_acquired():
202
+ self.release()
203
+ raise LockNotFoundError("Cannot refresh: lock file does not exist")
198
204
 
199
205
  lock_info = self._safe_load()
200
206
  if not lock_info or not self._is_mine(lock_info):
@@ -112,21 +112,21 @@ class PydanticResourceManager(Generic[PydanticResource]):
112
112
 
113
113
 
114
114
  class MutablePydanticResourceManager(PydanticResourceManager[MutablePydanticResource]):
115
- """Manages the .fmu configuration file."""
115
+ """Manages the .fmu resource file."""
116
116
 
117
117
  def __init__(
118
- self: Self, fmu_dir: FMUDirectoryBase, config: type[MutablePydanticResource]
118
+ self: Self, fmu_dir: FMUDirectoryBase, resource: type[MutablePydanticResource]
119
119
  ) -> None:
120
- """Initializes the Config resource manager."""
121
- super().__init__(fmu_dir, config)
120
+ """Initializes the resource manager."""
121
+ super().__init__(fmu_dir, resource)
122
122
 
123
123
  def _get_dot_notation_key(
124
- self: Self, config_dict: dict[str, Any], key: str, default: Any = None
124
+ self: Self, resource_dict: dict[str, Any], key: str, default: Any = None
125
125
  ) -> Any:
126
126
  """Sets the value to a dot-notation key.
127
127
 
128
128
  Args:
129
- config_dict: The configuration dictionary we are modifying (by reference)
129
+ resource_dict: The resource dictionary we are modifying (by reference)
130
130
  key: The key to set
131
131
  default: Value to return if key is not found. Default None
132
132
 
@@ -134,7 +134,7 @@ class MutablePydanticResourceManager(PydanticResourceManager[MutablePydanticReso
134
134
  The value or default
135
135
  """
136
136
  parts = key.split(".")
137
- value = config_dict
137
+ value = resource_dict
138
138
  for part in parts:
139
139
  if isinstance(value, dict) and part in value:
140
140
  value = value[part]
@@ -144,28 +144,28 @@ class MutablePydanticResourceManager(PydanticResourceManager[MutablePydanticReso
144
144
  return value
145
145
 
146
146
  def get(self: Self, key: str, default: Any = None) -> Any:
147
- """Gets a configuration value by key.
147
+ """Gets a resource value by key.
148
148
 
149
149
  Supports dot notation for nested values (e.g., "foo.bar")
150
150
 
151
151
  Args:
152
- key: The configuration key
152
+ key: The resource key
153
153
  default: Value to return if key is not found. Default None
154
154
 
155
155
  Returns:
156
- The configuration value or default
156
+ The resource value or default
157
157
  """
158
158
  try:
159
- config = self.load()
159
+ resource = self.load()
160
160
 
161
161
  if "." in key:
162
- return self._get_dot_notation_key(config.model_dump(), key, default)
162
+ return self._get_dot_notation_key(resource.model_dump(), key, default)
163
163
 
164
- if hasattr(config, key):
165
- return getattr(config, key)
164
+ if hasattr(resource, key):
165
+ return getattr(resource, key)
166
166
 
167
- config_dict = config.model_dump()
168
- return config_dict.get(key, default)
167
+ resource_dict = resource.model_dump()
168
+ return resource_dict.get(key, default)
169
169
  except FileNotFoundError as e:
170
170
  raise FileNotFoundError(
171
171
  f"Resource file for '{self.__class__.__name__}' not found "
@@ -173,17 +173,17 @@ class MutablePydanticResourceManager(PydanticResourceManager[MutablePydanticReso
173
173
  ) from e
174
174
 
175
175
  def _set_dot_notation_key(
176
- self: Self, config_dict: dict[str, Any], key: str, value: Any
176
+ self: Self, resource_dict: dict[str, Any], key: str, value: Any
177
177
  ) -> None:
178
178
  """Sets the value to a dot-notation key.
179
179
 
180
180
  Args:
181
- config_dict: The configuration dictionary we are modifying (by reference)
181
+ resource_dict: The resource dictionary we are modifying (by reference)
182
182
  key: The key to set
183
183
  value: The value to set
184
184
  """
185
185
  parts = key.split(".")
186
- target = config_dict
186
+ target = resource_dict
187
187
 
188
188
  for part in parts[:-1]:
189
189
  if part not in target or not isinstance(target[part], dict):
@@ -193,27 +193,27 @@ class MutablePydanticResourceManager(PydanticResourceManager[MutablePydanticReso
193
193
  target[parts[-1]] = value
194
194
 
195
195
  def set(self: Self, key: str, value: Any) -> None:
196
- """Sets a configuration value by key.
196
+ """Sets a resource value by key.
197
197
 
198
198
  Args:
199
- key: The configuration key
199
+ key: The resource key
200
200
  value: The value to set
201
201
 
202
202
  Raises:
203
- FileNotFoundError: If config file doesn't exist
204
- ValueError: If the updated config is invalid
203
+ FileNotFoundError: If resource file doesn't exist
204
+ ValueError: If the updated resource is invalid
205
205
  """
206
206
  try:
207
- config = self.load()
208
- config_dict = config.model_dump()
207
+ resource = self.load()
208
+ resource_dict = resource.model_dump()
209
209
 
210
210
  if "." in key:
211
- self._set_dot_notation_key(config_dict, key, value)
211
+ self._set_dot_notation_key(resource_dict, key, value)
212
212
  else:
213
- config_dict[key] = value
213
+ resource_dict[key] = value
214
214
 
215
- updated_config = config.model_validate(config_dict)
216
- self.save(updated_config)
215
+ updated_resource = resource.model_validate(resource_dict)
216
+ self.save(updated_resource)
217
217
  except ValidationError as e:
218
218
  raise ValueError(
219
219
  f"Invalid value set for '{self.__class__.__name__}' with "
@@ -226,31 +226,31 @@ class MutablePydanticResourceManager(PydanticResourceManager[MutablePydanticReso
226
226
  ) from e
227
227
 
228
228
  def update(self: Self, updates: dict[str, Any]) -> MutablePydanticResource:
229
- """Updates multiple configuration values at once.
229
+ """Updates multiple resource values at once.
230
230
 
231
231
  Args:
232
232
  updates: Dictionary of key-value pairs to update
233
233
 
234
234
  Returns:
235
- The updated Config object
235
+ The updated Resource object
236
236
 
237
237
  Raises:
238
- FileNotFoundError: If config file doesn't exist
239
- ValueError: If the updates config is invalid
238
+ FileNotFoundError: If resource file doesn't exist
239
+ ValueError: If the updates resource is invalid
240
240
  """
241
241
  try:
242
- config = self.load()
243
- config_dict = config.model_dump()
242
+ resource = self.load()
243
+ resource_dict = resource.model_dump()
244
244
 
245
245
  flat_updates = {k: v for k, v in updates.items() if "." not in k}
246
- config_dict.update(flat_updates)
246
+ resource_dict.update(flat_updates)
247
247
 
248
248
  for key, value in updates.items():
249
249
  if "." in key:
250
- self._set_dot_notation_key(config_dict, key, value)
250
+ self._set_dot_notation_key(resource_dict, key, value)
251
251
 
252
- updated_config = config.model_validate(config_dict)
253
- self.save(updated_config)
252
+ updated_resource = resource.model_validate(resource_dict)
253
+ self.save(updated_resource)
254
254
  except ValidationError as e:
255
255
  raise ValueError(
256
256
  f"Invalid value set for '{self.__class__.__name__}' with "
@@ -262,14 +262,14 @@ class MutablePydanticResourceManager(PydanticResourceManager[MutablePydanticReso
262
262
  f"at: '{self.path}' when setting updates {updates}"
263
263
  ) from e
264
264
 
265
- return updated_config
265
+ return updated_resource
266
266
 
267
267
  def reset(self: Self) -> MutablePydanticResource:
268
- """Resets the configuration to defaults.
268
+ """Resets the resources to defaults.
269
269
 
270
270
  Returns:
271
- The new default config object
271
+ The new default resource object
272
272
  """
273
- config = self.model_class.reset()
274
- self.save(config)
275
- return config
273
+ resource = self.model_class.reset()
274
+ self.save(resource)
275
+ return resource
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.5.1'
32
- __version_tuple__ = version_tuple = (0, 5, 1)
31
+ __version__ = version = '0.5.3'
32
+ __version_tuple__ = version_tuple = (0, 5, 3)
33
33
 
34
34
  __commit_id__ = commit_id = None
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: fmu-settings
3
- Version: 0.5.1
3
+ Version: 0.5.3
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
@@ -4,21 +4,21 @@ fmu/settings/_fmu_dir.py,sha256=XeZjec78q0IUOpBq-VMkKoWtzXwBeQi2qWRIh_SIFwU,1085
4
4
  fmu/settings/_global_config.py,sha256=C0_o99OhOc49ynz4h6ygbbHHH8OOI5lcVFr-9FCwD0c,9331
5
5
  fmu/settings/_init.py,sha256=ucueS0BlEsM3MkX7IaRISloH4vF7-_ZKSphrORbHgJ4,4381
6
6
  fmu/settings/_logging.py,sha256=nEdmZlNCBsB1GfDmFMKCjZmeuRp3CRlbz1EYUemc95Y,1104
7
- fmu/settings/_version.py,sha256=cYMOhuaBHd0MIZmumuccsEQ-AxM8LIJy9dsBAWgOpqE,704
7
+ fmu/settings/_version.py,sha256=EWl7XaGZUG57Di8WiRltpKAkwy1CShJuJ-i6_rAPr-w,704
8
8
  fmu/settings/py.typed,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
9
9
  fmu/settings/types.py,sha256=aeXEsznBTT1YRRY_LSRqK1j2gmMmyLYYTGYl3a9fweU,513
10
10
  fmu/settings/_resources/__init__.py,sha256=LHYR_F7lNGdv8N6R3cEwds5CJQpkOthXFqsEs24vgF8,118
11
11
  fmu/settings/_resources/config_managers.py,sha256=QcCLlSw8KdJKrkhGax5teFJzjgQG3ym7Ljs1DykjFbc,1570
12
- fmu/settings/_resources/lock_manager.py,sha256=zdv1BZJlgB1BO9NepAdjY-YZ1-57HEJcTApE4UVS-8M,9995
13
- fmu/settings/_resources/pydantic_resource_manager.py,sha256=AVvBUPnYOzmFYo9k5cA9QUme6ZOu0Q3IoLx_le7Mq20,9264
12
+ fmu/settings/_resources/lock_manager.py,sha256=1LL4FUBwvIIzBz5YXC0eoqdGUizVN5ZKwx_8CbwTudU,10163
13
+ fmu/settings/_resources/pydantic_resource_manager.py,sha256=BUWO6IHSoT0Ma6QgseweEf7uiGeMwHBEoCyGYPYYFdA,9290
14
14
  fmu/settings/models/__init__.py,sha256=lRlXgl55ba2upmDzdvzx8N30JMq2Osnm8aa_xxTZn8A,112
15
15
  fmu/settings/models/_enums.py,sha256=SQUZ-2mQcTx4F0oefPFfuQzMKsKTSFSB-wq_CH7TBRE,734
16
16
  fmu/settings/models/_mappings.py,sha256=Z4Ex7MtmajBr6FjaNzmwDRwtJlaZZ8YKh9NDmZHRKPI,2832
17
17
  fmu/settings/models/lock_info.py,sha256=-oHDF9v9bDLCoFvEg4S6XXYLeo19zRAZ8HynCv75VWg,711
18
18
  fmu/settings/models/project_config.py,sha256=pxb54JmpXNMVAFUu_yJ89dNrYEk6hrPuFfFUpf84Jh0,1099
19
19
  fmu/settings/models/user_config.py,sha256=dWFTcZY6UnEgNTuGqB-izraJ657PecsW0e0Nt9GBDhI,2666
20
- fmu_settings-0.5.1.dist-info/licenses/LICENSE,sha256=OXLcl0T2SZ8Pmy2_dmlvKuetivmyPd5m1q-Gyd-zaYY,35149
21
- fmu_settings-0.5.1.dist-info/METADATA,sha256=kVJutk6xJAJ2bHHn-VgKuhoIMtu761lgvC6G5LAr4kM,2116
22
- fmu_settings-0.5.1.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
23
- fmu_settings-0.5.1.dist-info/top_level.txt,sha256=Z-FIY3pxn0UK2Wxi9IJ7fKoLSraaxuNGi1eokiE0ShM,4
24
- fmu_settings-0.5.1.dist-info/RECORD,,
20
+ fmu_settings-0.5.3.dist-info/licenses/LICENSE,sha256=OXLcl0T2SZ8Pmy2_dmlvKuetivmyPd5m1q-Gyd-zaYY,35149
21
+ fmu_settings-0.5.3.dist-info/METADATA,sha256=MA3zZ6GPHQ0bJtHnAcCINEuDnaJtDRHT0E0SrmGu-cg,2116
22
+ fmu_settings-0.5.3.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
23
+ fmu_settings-0.5.3.dist-info/top_level.txt,sha256=Z-FIY3pxn0UK2Wxi9IJ7fKoLSraaxuNGi1eokiE0ShM,4
24
+ fmu_settings-0.5.3.dist-info/RECORD,,