fmu-settings 0.5.0__tar.gz → 0.5.1__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 (45) hide show
  1. {fmu_settings-0.5.0 → fmu_settings-0.5.1}/PKG-INFO +1 -1
  2. {fmu_settings-0.5.0 → fmu_settings-0.5.1}/src/fmu/settings/_global_config.py +17 -4
  3. {fmu_settings-0.5.0 → fmu_settings-0.5.1}/src/fmu/settings/_version.py +3 -3
  4. {fmu_settings-0.5.0 → fmu_settings-0.5.1}/src/fmu_settings.egg-info/PKG-INFO +1 -1
  5. {fmu_settings-0.5.0 → fmu_settings-0.5.1}/tests/test_global_config.py +82 -23
  6. {fmu_settings-0.5.0 → fmu_settings-0.5.1}/.coveragerc +0 -0
  7. {fmu_settings-0.5.0 → fmu_settings-0.5.1}/.github/pull_request_template.md +0 -0
  8. {fmu_settings-0.5.0 → fmu_settings-0.5.1}/.github/workflows/ci.yml +0 -0
  9. {fmu_settings-0.5.0 → fmu_settings-0.5.1}/.github/workflows/codeql.yml +0 -0
  10. {fmu_settings-0.5.0 → fmu_settings-0.5.1}/.github/workflows/publish.yml +0 -0
  11. {fmu_settings-0.5.0 → fmu_settings-0.5.1}/.gitignore +0 -0
  12. {fmu_settings-0.5.0 → fmu_settings-0.5.1}/CONTRIBUTING.md +0 -0
  13. {fmu_settings-0.5.0 → fmu_settings-0.5.1}/LICENSE +0 -0
  14. {fmu_settings-0.5.0 → fmu_settings-0.5.1}/README.md +0 -0
  15. {fmu_settings-0.5.0 → fmu_settings-0.5.1}/SECURITY.md +0 -0
  16. {fmu_settings-0.5.0 → fmu_settings-0.5.1}/pyproject.toml +0 -0
  17. {fmu_settings-0.5.0 → fmu_settings-0.5.1}/setup.cfg +0 -0
  18. {fmu_settings-0.5.0 → fmu_settings-0.5.1}/src/fmu/__init__.py +0 -0
  19. {fmu_settings-0.5.0 → fmu_settings-0.5.1}/src/fmu/settings/__init__.py +0 -0
  20. {fmu_settings-0.5.0 → fmu_settings-0.5.1}/src/fmu/settings/_fmu_dir.py +0 -0
  21. {fmu_settings-0.5.0 → fmu_settings-0.5.1}/src/fmu/settings/_init.py +0 -0
  22. {fmu_settings-0.5.0 → fmu_settings-0.5.1}/src/fmu/settings/_logging.py +0 -0
  23. {fmu_settings-0.5.0 → fmu_settings-0.5.1}/src/fmu/settings/_resources/__init__.py +0 -0
  24. {fmu_settings-0.5.0 → fmu_settings-0.5.1}/src/fmu/settings/_resources/config_managers.py +0 -0
  25. {fmu_settings-0.5.0 → fmu_settings-0.5.1}/src/fmu/settings/_resources/lock_manager.py +0 -0
  26. {fmu_settings-0.5.0 → fmu_settings-0.5.1}/src/fmu/settings/_resources/pydantic_resource_manager.py +0 -0
  27. {fmu_settings-0.5.0 → fmu_settings-0.5.1}/src/fmu/settings/models/__init__.py +0 -0
  28. {fmu_settings-0.5.0 → fmu_settings-0.5.1}/src/fmu/settings/models/_enums.py +0 -0
  29. {fmu_settings-0.5.0 → fmu_settings-0.5.1}/src/fmu/settings/models/_mappings.py +0 -0
  30. {fmu_settings-0.5.0 → fmu_settings-0.5.1}/src/fmu/settings/models/lock_info.py +0 -0
  31. {fmu_settings-0.5.0 → fmu_settings-0.5.1}/src/fmu/settings/models/project_config.py +0 -0
  32. {fmu_settings-0.5.0 → fmu_settings-0.5.1}/src/fmu/settings/models/user_config.py +0 -0
  33. {fmu_settings-0.5.0 → fmu_settings-0.5.1}/src/fmu/settings/py.typed +0 -0
  34. {fmu_settings-0.5.0 → fmu_settings-0.5.1}/src/fmu/settings/types.py +0 -0
  35. {fmu_settings-0.5.0 → fmu_settings-0.5.1}/src/fmu_settings.egg-info/SOURCES.txt +0 -0
  36. {fmu_settings-0.5.0 → fmu_settings-0.5.1}/src/fmu_settings.egg-info/dependency_links.txt +0 -0
  37. {fmu_settings-0.5.0 → fmu_settings-0.5.1}/src/fmu_settings.egg-info/requires.txt +0 -0
  38. {fmu_settings-0.5.0 → fmu_settings-0.5.1}/src/fmu_settings.egg-info/top_level.txt +0 -0
  39. {fmu_settings-0.5.0 → fmu_settings-0.5.1}/tests/conftest.py +0 -0
  40. {fmu_settings-0.5.0 → fmu_settings-0.5.1}/tests/test_fmu_dir.py +0 -0
  41. {fmu_settings-0.5.0 → fmu_settings-0.5.1}/tests/test_init.py +0 -0
  42. {fmu_settings-0.5.0 → fmu_settings-0.5.1}/tests/test_resources/test_lock_manager.py +0 -0
  43. {fmu_settings-0.5.0 → fmu_settings-0.5.1}/tests/test_resources/test_project_config.py +0 -0
  44. {fmu_settings-0.5.0 → fmu_settings-0.5.1}/tests/test_resources/test_resource_managers.py +0 -0
  45. {fmu_settings-0.5.0 → fmu_settings-0.5.1}/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.5.0
3
+ Version: 0.5.1
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
@@ -145,16 +145,18 @@ def load_global_configuration_if_present(
145
145
  fmu_load: Whether or not to load in the custom 'fmu' format. Default False.
146
146
 
147
147
  Returns:
148
- GlobalConfiguration instance or None.
148
+ GlobalConfiguration instance or None if file cannot be loaded.
149
+
150
+ Raises:
151
+ ValidationError: If the file is loaded but has invalid schema.
149
152
  """
150
153
  loader = "fmu" if fmu_load else "standard"
151
154
  try:
152
155
  global_variables_dict = yaml_load(path, loader=loader)
153
156
  global_config = GlobalConfiguration.model_validate(global_variables_dict)
154
157
  logger.debug(f"Global variables at {path} has valid settings data")
155
- except ValidationError as e:
156
- logger.debug(f"Global variables at {path} failed validation: {e}")
157
- return None
158
+ except ValidationError:
159
+ raise
158
160
  except Exception as e:
159
161
  logger.debug(
160
162
  f"Failed to load global variables at {path}: {type(e).__name__}: {e}"
@@ -173,6 +175,9 @@ def _find_global_variables_file(paths: list[Path]) -> GlobalConfiguration | None
173
175
 
174
176
  Returns:
175
177
  A validated GlobalConfiguration or None.
178
+
179
+ Raises:
180
+ ValidationError: If a file is found but has invalid schema.
176
181
  """
177
182
  for path in paths:
178
183
  if not path.exists():
@@ -204,6 +209,9 @@ def _find_global_config_file(paths: list[Path]) -> GlobalConfiguration | None:
204
209
 
205
210
  Returns:
206
211
  A validated GlobalConfiguration or None.
212
+
213
+ Raises:
214
+ ValidationError: If a file is found but has invalid schema.
207
215
  """
208
216
  for path in paths:
209
217
  if not path.exists():
@@ -241,6 +249,11 @@ def find_global_config(
241
249
 
242
250
  Returns:
243
251
  A valid GlobalConfiguration instance, or None.
252
+
253
+ Raises:
254
+ ValidationError: If a configuration file is found but has invalid schema.
255
+ InvalidGlobalConfigurationError: If strict=True and configuration contains
256
+ disallowed content (e.g., Drogon data).
244
257
  """
245
258
  base_path = Path(base_path)
246
259
 
@@ -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.0'
32
- __version_tuple__ = version_tuple = (0, 5, 0)
31
+ __version__ = version = '0.5.1'
32
+ __version_tuple__ = version_tuple = (0, 5, 1)
33
33
 
34
- __commit_id__ = commit_id = 'g53ff72079'
34
+ __commit_id__ = commit_id = 'g6786842d9'
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: fmu-settings
3
- Version: 0.5.0
3
+ Version: 0.5.1
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
@@ -13,6 +13,7 @@ from fmu.datamodels.fmu_results.global_configuration import (
13
13
  GlobalConfiguration,
14
14
  StratigraphyElement,
15
15
  )
16
+ from pydantic import ValidationError
16
17
 
17
18
  from fmu.settings._global_config import (
18
19
  InvalidGlobalConfigurationError,
@@ -291,29 +292,51 @@ def test_validate_global_config_strict_stratigraphy_names(
291
292
 
292
293
 
293
294
  @pytest.mark.parametrize("fmu_load", [True, False])
294
- def test_load_global_configuration_returns_none_if_invalid_yaml(
295
+ def test_load_global_configuration_raises_on_invalid_yaml_structure(
295
296
  fmu_load: bool, tmp_path: Path
296
297
  ) -> None:
297
- """Tests maybe_load returns None if an Exception is raised."""
298
+ """Tests that ValidationError is raised for invalid YAML structure."""
298
299
  config_path = tmp_path / "global_config.yml"
299
300
  with open(config_path, "w") as f:
300
301
  f.write("foo=bar")
301
302
 
302
- assert load_global_configuration_if_present(config_path, fmu_load=fmu_load) is None
303
+ with pytest.raises(ValidationError):
304
+ load_global_configuration_if_present(config_path, fmu_load=fmu_load)
303
305
 
304
306
 
305
307
  @pytest.mark.parametrize("fmu_load", [True, False])
306
- def test_load_global_configuration_returns_none_if_invalid_config(
308
+ def test_load_global_configuration_raises_on_missing_required_fields(
307
309
  fmu_load: bool,
308
310
  tmp_path: Path,
309
311
  global_variables_with_masterdata: dict[str, Any],
310
312
  ) -> None:
311
- """Tests maybe_load returns None if an Exception is raised."""
313
+ """Tests that ValidationError is raised for missing required fields."""
312
314
  config_path = tmp_path / "global_config.yml"
313
315
  del global_variables_with_masterdata["masterdata"]
314
316
  with open(config_path, "w") as f:
315
317
  yaml.safe_dump(global_variables_with_masterdata, f)
316
318
 
319
+ with pytest.raises(ValidationError):
320
+ load_global_configuration_if_present(config_path, fmu_load=fmu_load)
321
+
322
+
323
+ @pytest.mark.parametrize("fmu_load", [True, False])
324
+ def test_load_global_configuration_returns_none_on_file_not_found(
325
+ fmu_load: bool, tmp_path: Path
326
+ ) -> None:
327
+ """Tests that None is returned when file doesn't exist."""
328
+ config_path = tmp_path / "non_existent_file.yml"
329
+ assert load_global_configuration_if_present(config_path, fmu_load=fmu_load) is None
330
+
331
+
332
+ @pytest.mark.parametrize("fmu_load", [True, False])
333
+ def test_load_global_configuration_returns_none_on_yaml_parse_error(
334
+ fmu_load: bool, tmp_path: Path
335
+ ) -> None:
336
+ """Tests that None is returned on YAML parsing errors."""
337
+ config_path = tmp_path / "invalid.yml"
338
+ with open(config_path, "w") as f:
339
+ f.write("key: [unclosed list")
317
340
  assert load_global_configuration_if_present(config_path, fmu_load=fmu_load) is None
318
341
 
319
342
 
@@ -327,10 +350,23 @@ def test_find_global_config_file_not_there(tmp_path: Path) -> None:
327
350
  assert _find_global_config_file([tmp_path / "dne"]) is None
328
351
 
329
352
 
330
- def test_find_global_configs_file_malformed(tmp_path: Path) -> None:
331
- """Tests finding the global config file if it is malformed."""
353
+ def test_find_global_config_file_malformed_raises_validation_error(
354
+ tmp_path: Path,
355
+ ) -> None:
356
+ """Tests that malformed global config file raises ValidationError."""
332
357
  with open(tmp_path / "global_master_config.yml", "w") as f:
333
358
  f.write("foo: bar")
359
+ with pytest.raises(ValidationError):
360
+ _find_global_config_file([tmp_path])
361
+
362
+
363
+ def test_find_global_config_file_skips_invalid_yaml_and_continues(
364
+ tmp_path: Path,
365
+ ) -> None:
366
+ """Tests that function skips files with YAML parse errors and continues."""
367
+ with open(tmp_path / "global_config.yml", "w") as f:
368
+ f.write("key: [unclosed list")
369
+
334
370
  assert _find_global_config_file([tmp_path]) is None
335
371
 
336
372
 
@@ -363,32 +399,55 @@ def test_find_global_variables_file_not_there(tmp_path: Path) -> None:
363
399
  assert _find_global_variables_file([tmp_path / "dne"]) is None
364
400
 
365
401
 
366
- def test_find_global_variables_file_malformed(tmp_path: Path) -> None:
367
- """Tests finding the global variables file if it is malformed."""
402
+ def test_find_global_variables_file_malformed_raises_validation_error(
403
+ tmp_path: Path,
404
+ ) -> None:
405
+ """Tests that malformed global variables file raises ValidationError."""
368
406
  with open(tmp_path / "global_variables.yml", "w") as f:
369
407
  f.write("foo: bar")
370
- assert _find_global_variables_file([tmp_path]) is None
408
+ with pytest.raises(ValidationError):
409
+ _find_global_variables_file([tmp_path])
371
410
 
372
411
 
373
- def test_find_global_variables_file(fmuconfig_with_output: Path) -> None:
374
- """Tests finding the global variables file in fmuconfig."""
412
+ def test_find_global_variables_file_returns_none_when_not_found(
413
+ fmuconfig_with_output: Path,
414
+ ) -> None:
415
+ """Tests that None is returned when no global variables file exists."""
375
416
  tmp_path = fmuconfig_with_output
376
417
  some_dir = tmp_path / "some_dir"
377
418
  some_dir.mkdir()
378
- some_file = some_dir / "some_file"
379
- some_file.touch()
380
419
  does_not_exist = tmp_path / "bad"
381
- assert _find_global_variables_file([does_not_exist, some_dir, some_file]) is None
420
+ assert _find_global_variables_file([does_not_exist, some_dir]) is None
421
+
422
+
423
+ def test_find_global_variables_file_skips_invalid_yaml_and_continues(
424
+ tmp_path: Path,
425
+ ) -> None:
426
+ """Tests that function skips files with YAML parse errors and continues."""
427
+ invalid_yaml_file = tmp_path / "global_variables.yml"
428
+ with open(invalid_yaml_file, "w") as f:
429
+ f.write("key: [unclosed list")
430
+
431
+ assert _find_global_variables_file([tmp_path]) is None
432
+
382
433
 
434
+ def test_find_global_variables_file_raises_on_empty_file(
435
+ fmuconfig_with_output: Path,
436
+ ) -> None:
437
+ """Tests that ValidationError is raised for empty/invalid file."""
438
+ tmp_path = fmuconfig_with_output
439
+ some_file = tmp_path / "some_file"
440
+ some_file.touch()
441
+ with pytest.raises(ValidationError):
442
+ _find_global_variables_file([some_file])
443
+
444
+
445
+ def test_find_global_variables_file_returns_valid_config(
446
+ fmuconfig_with_output: Path,
447
+ ) -> None:
448
+ """Tests finding a valid global variables file in fmuconfig."""
383
449
  assert isinstance(
384
- _find_global_variables_file(
385
- [
386
- does_not_exist,
387
- some_dir,
388
- some_file,
389
- fmuconfig_with_output / "fmuconfig/output",
390
- ]
391
- ),
450
+ _find_global_variables_file([fmuconfig_with_output / "fmuconfig/output"]),
392
451
  GlobalConfiguration,
393
452
  )
394
453
 
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes