fmu-settings 0.1.0__tar.gz → 0.2.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.
- {fmu_settings-0.1.0 → fmu_settings-0.2.0}/PKG-INFO +1 -1
- {fmu_settings-0.1.0 → fmu_settings-0.2.0}/src/fmu/settings/_fmu_dir.py +3 -3
- fmu_settings-0.2.0/src/fmu/settings/_resources/__init__.py +5 -0
- {fmu_settings-0.1.0/src/fmu/settings/resources → fmu_settings-0.2.0/src/fmu/settings/_resources}/config_managers.py +1 -1
- {fmu_settings-0.1.0 → fmu_settings-0.2.0}/src/fmu/settings/_version.py +3 -3
- {fmu_settings-0.1.0 → fmu_settings-0.2.0}/src/fmu/settings/models/user_config.py +18 -4
- {fmu_settings-0.1.0 → fmu_settings-0.2.0}/src/fmu_settings.egg-info/PKG-INFO +1 -1
- {fmu_settings-0.1.0 → fmu_settings-0.2.0}/src/fmu_settings.egg-info/SOURCES.txt +3 -2
- {fmu_settings-0.1.0 → fmu_settings-0.2.0}/tests/conftest.py +1 -1
- {fmu_settings-0.1.0 → fmu_settings-0.2.0}/tests/test_fmu_dir.py +17 -6
- {fmu_settings-0.1.0 → fmu_settings-0.2.0}/tests/test_init.py +1 -1
- {fmu_settings-0.1.0 → fmu_settings-0.2.0}/tests/test_resources/test_project_config.py +3 -3
- {fmu_settings-0.1.0 → fmu_settings-0.2.0}/tests/test_resources/test_resource_managers.py +1 -1
- {fmu_settings-0.1.0 → fmu_settings-0.2.0}/.coveragerc +0 -0
- {fmu_settings-0.1.0 → fmu_settings-0.2.0}/.github/pull_request_template.md +0 -0
- {fmu_settings-0.1.0 → fmu_settings-0.2.0}/.github/workflows/ci.yml +0 -0
- {fmu_settings-0.1.0 → fmu_settings-0.2.0}/.github/workflows/codeql.yml +0 -0
- {fmu_settings-0.1.0 → fmu_settings-0.2.0}/.github/workflows/publish.yml +0 -0
- {fmu_settings-0.1.0 → fmu_settings-0.2.0}/.gitignore +0 -0
- {fmu_settings-0.1.0 → fmu_settings-0.2.0}/CONTRIBUTING.md +0 -0
- {fmu_settings-0.1.0 → fmu_settings-0.2.0}/LICENSE +0 -0
- {fmu_settings-0.1.0 → fmu_settings-0.2.0}/README.md +0 -0
- {fmu_settings-0.1.0 → fmu_settings-0.2.0}/SECURITY.md +0 -0
- {fmu_settings-0.1.0 → fmu_settings-0.2.0}/pyproject.toml +0 -0
- {fmu_settings-0.1.0 → fmu_settings-0.2.0}/setup.cfg +0 -0
- {fmu_settings-0.1.0 → fmu_settings-0.2.0}/src/fmu/__init__.py +0 -0
- {fmu_settings-0.1.0 → fmu_settings-0.2.0}/src/fmu/settings/__init__.py +0 -0
- {fmu_settings-0.1.0 → fmu_settings-0.2.0}/src/fmu/settings/_init.py +0 -0
- {fmu_settings-0.1.0 → fmu_settings-0.2.0}/src/fmu/settings/_logging.py +0 -0
- /fmu_settings-0.1.0/src/fmu/settings/resources/managers.py → /fmu_settings-0.2.0/src/fmu/settings/_resources/pydantic_resource_manager.py +0 -0
- {fmu_settings-0.1.0 → fmu_settings-0.2.0}/src/fmu/settings/models/__init__.py +0 -0
- {fmu_settings-0.1.0 → fmu_settings-0.2.0}/src/fmu/settings/models/_enums.py +0 -0
- {fmu_settings-0.1.0 → fmu_settings-0.2.0}/src/fmu/settings/models/_mappings.py +0 -0
- {fmu_settings-0.1.0 → fmu_settings-0.2.0}/src/fmu/settings/models/project_config.py +0 -0
- {fmu_settings-0.1.0 → fmu_settings-0.2.0}/src/fmu/settings/py.typed +0 -0
- {fmu_settings-0.1.0 → fmu_settings-0.2.0}/src/fmu/settings/types.py +0 -0
- {fmu_settings-0.1.0 → fmu_settings-0.2.0}/src/fmu_settings.egg-info/dependency_links.txt +0 -0
- {fmu_settings-0.1.0 → fmu_settings-0.2.0}/src/fmu_settings.egg-info/requires.txt +0 -0
- {fmu_settings-0.1.0 → fmu_settings-0.2.0}/src/fmu_settings.egg-info/top_level.txt +0 -0
- {fmu_settings-0.1.0 → fmu_settings-0.2.0}/tests/test_resources/test_user_config.py +0 -0
|
@@ -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 .
|
|
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
|
|
|
@@ -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 .
|
|
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
|
|
@@ -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.
|
|
32
|
-
__version_tuple__ = version_tuple = (0,
|
|
31
|
+
__version__ = version = '0.2.0'
|
|
32
|
+
__version_tuple__ = version_tuple = (0, 2, 0)
|
|
33
33
|
|
|
34
|
-
__commit_id__ = commit_id = '
|
|
34
|
+
__commit_id__ = commit_id = 'g944134f32'
|
|
@@ -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
|
|
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
|
-
|
|
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
|
-
|
|
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
|
-
|
|
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
|
|
|
@@ -17,13 +17,14 @@ src/fmu/settings/_logging.py
|
|
|
17
17
|
src/fmu/settings/_version.py
|
|
18
18
|
src/fmu/settings/py.typed
|
|
19
19
|
src/fmu/settings/types.py
|
|
20
|
+
src/fmu/settings/_resources/__init__.py
|
|
21
|
+
src/fmu/settings/_resources/config_managers.py
|
|
22
|
+
src/fmu/settings/_resources/pydantic_resource_manager.py
|
|
20
23
|
src/fmu/settings/models/__init__.py
|
|
21
24
|
src/fmu/settings/models/_enums.py
|
|
22
25
|
src/fmu/settings/models/_mappings.py
|
|
23
26
|
src/fmu/settings/models/project_config.py
|
|
24
27
|
src/fmu/settings/models/user_config.py
|
|
25
|
-
src/fmu/settings/resources/config_managers.py
|
|
26
|
-
src/fmu/settings/resources/managers.py
|
|
27
28
|
src/fmu_settings.egg-info/PKG-INFO
|
|
28
29
|
src/fmu_settings.egg-info/SOURCES.txt
|
|
29
30
|
src/fmu_settings.egg-info/dependency_links.txt
|
|
@@ -288,30 +288,41 @@ def test_update_user_config(user_fmu_dir: UserFMUDirectory) -> None:
|
|
|
288
288
|
"""Tests update_config updates and saves the user config for multiple values."""
|
|
289
289
|
recent_dir = "/foo/bar"
|
|
290
290
|
updated_config = user_fmu_dir.update_config(
|
|
291
|
-
{"version": "2.0.0", "
|
|
291
|
+
{"version": "2.0.0", "recent_project_directories": [recent_dir]}
|
|
292
292
|
)
|
|
293
293
|
|
|
294
294
|
assert updated_config.version == "2.0.0"
|
|
295
|
-
assert updated_config.
|
|
295
|
+
assert updated_config.recent_project_directories == [Path(recent_dir)]
|
|
296
296
|
|
|
297
297
|
assert user_fmu_dir.config.load() is not None
|
|
298
298
|
assert user_fmu_dir.get_config_value("version", None) == "2.0.0"
|
|
299
|
-
assert user_fmu_dir.get_config_value("
|
|
299
|
+
assert user_fmu_dir.get_config_value("recent_project_directories") == [
|
|
300
|
+
Path(recent_dir)
|
|
301
|
+
]
|
|
300
302
|
|
|
301
303
|
config_file = user_fmu_dir.config.path
|
|
302
304
|
with open(config_file, encoding="utf-8") as f:
|
|
303
305
|
saved_config = json.load(f)
|
|
304
306
|
|
|
305
307
|
assert saved_config["version"] == "2.0.0"
|
|
306
|
-
assert saved_config["
|
|
308
|
+
assert saved_config["recent_project_directories"] == [recent_dir]
|
|
307
309
|
|
|
308
310
|
|
|
309
311
|
def test_update_user_config_invalid_data(user_fmu_dir: UserFMUDirectory) -> None:
|
|
310
312
|
"""Tests that update_config raises ValidationError on bad data."""
|
|
311
|
-
updates = {"
|
|
313
|
+
updates = {"recent_project_directories": [123]}
|
|
312
314
|
with pytest.raises(
|
|
313
315
|
ValueError,
|
|
314
316
|
match="Invalid value set for 'UserConfigManager' with updates "
|
|
315
|
-
"'{'
|
|
317
|
+
"'{'recent_project_directories':",
|
|
316
318
|
):
|
|
317
319
|
user_fmu_dir.update_config(updates)
|
|
320
|
+
|
|
321
|
+
|
|
322
|
+
def test_update_user_config_non_unique_recent_projects(
|
|
323
|
+
user_fmu_dir: UserFMUDirectory,
|
|
324
|
+
) -> None:
|
|
325
|
+
"""Tests that update_config raises on non-unique recent_project_directories."""
|
|
326
|
+
updates = {"recent_project_directories": [Path("/foo/bar"), Path("/foo/bar")]}
|
|
327
|
+
with pytest.raises(ValueError, match="unique entries"):
|
|
328
|
+
user_fmu_dir.update_config(updates)
|
|
@@ -134,7 +134,7 @@ def test_init_user_fmu_directory(
|
|
|
134
134
|
assert config_json["version"] == __version__
|
|
135
135
|
assert config_json["created_at"] != str(unix_epoch_utc)
|
|
136
136
|
assert config_json["user_api_keys"] == {"smda_subscription": None}
|
|
137
|
-
assert config_json["
|
|
137
|
+
assert config_json["recent_project_directories"] == []
|
|
138
138
|
|
|
139
139
|
created_at = datetime.fromisoformat(config_json["created_at"])
|
|
140
140
|
now = datetime.now(UTC)
|
|
@@ -9,12 +9,12 @@ import pytest
|
|
|
9
9
|
|
|
10
10
|
from fmu.datamodels.fmu_results.fields import Access, Model, Smda
|
|
11
11
|
from fmu.settings._fmu_dir import ProjectFMUDirectory, UserFMUDirectory
|
|
12
|
-
from fmu.settings.
|
|
13
|
-
from fmu.settings.models.user_config import UserConfig
|
|
14
|
-
from fmu.settings.resources.config_managers import (
|
|
12
|
+
from fmu.settings._resources.config_managers import (
|
|
15
13
|
ProjectConfigManager,
|
|
16
14
|
UserConfigManager,
|
|
17
15
|
)
|
|
16
|
+
from fmu.settings.models.project_config import ProjectConfig
|
|
17
|
+
from fmu.settings.models.user_config import UserConfig
|
|
18
18
|
|
|
19
19
|
|
|
20
20
|
@pytest.fixture
|
|
@@ -8,7 +8,7 @@ import pytest
|
|
|
8
8
|
from pydantic import BaseModel
|
|
9
9
|
|
|
10
10
|
from fmu.settings._fmu_dir import ProjectFMUDirectory
|
|
11
|
-
from fmu.settings.
|
|
11
|
+
from fmu.settings._resources.pydantic_resource_manager import PydanticResourceManager
|
|
12
12
|
|
|
13
13
|
|
|
14
14
|
class A(BaseModel):
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|