diff --git a/CHANGELOG.md b/CHANGELOG.md index fbce056..e1a907f 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -11,10 +11,16 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ### Changes +- update mex-common to version 0.48.0 + ### Deprecated ### Removed +- remove BackendIdentityProvider in favor of mex-common version +- remove identity_provider from EditorSettings in favor of mex-common setting +- remove EditorIdentityProvider enum in favor of mex-common enum + ### Fixed ### Security diff --git a/mex/editor/identity.py b/mex/editor/identity.py deleted file mode 100644 index 388c2be..0000000 --- a/mex/editor/identity.py +++ /dev/null @@ -1,66 +0,0 @@ -from functools import cache -from urllib.parse import urljoin - -from mex.common.connector.http import HTTPConnector -from mex.common.identity.base import BaseProvider -from mex.common.identity.models import Identity -from mex.common.types import Identifier, MergedPrimarySourceIdentifier -from mex.editor.settings import EditorSettings - -# TODO(ND): use mex-common version of BackendIdentityProvider (stop-gap MX-1763) - - -class BackendIdentityProvider(BaseProvider, HTTPConnector): - """Identity provider that communicates with the backend HTTP API.""" - - API_VERSION = "v0" - - def _check_availability(self) -> None: - """Send a GET request to verify the API is available.""" - self.request("GET", "_system/check") - - def _set_authentication(self) -> None: - """Set the backend API key to all session headers.""" - settings = EditorSettings.get() - self.session.headers["X-API-Key"] = settings.backend_api_key.get_secret_value() - - def _set_url(self) -> None: - """Set the backend api url with the version path.""" - settings = EditorSettings.get() - self.url = urljoin(str(settings.backend_api_url), self.API_VERSION) - - @cache # noqa: B019 safe to ignore because this class is a singleton - def assign( - self, - had_primary_source: MergedPrimarySourceIdentifier, - identifier_in_primary_source: str, - ) -> Identity: - """Find an Identity in a database or assign a new one.""" - payload = { - "hadPrimarySource": had_primary_source, - "identifierInPrimarySource": identifier_in_primary_source, - } - identity = self.request("POST", "identity", payload) - - return Identity.model_validate(identity) - - def fetch( - self, - *, - had_primary_source: Identifier | None = None, - identifier_in_primary_source: str | None = None, - stable_target_id: Identifier | None = None, - ) -> list[Identity]: - """Find Identity instances matching the given filters. - - Either provide `stableTargetId` or `hadPrimarySource` - and `identifierInPrimarySource` together to get a unique result. - """ - params = { - "hadPrimarySource": had_primary_source, - "identifierInPrimarySource": identifier_in_primary_source, - "stableTargetId": stable_target_id, - } - params_cleaned = {key: str(value) for key, value in params.items() if value} - results = self.request("GET", "identity", params=params_cleaned) - return [Identity.model_validate(i) for i in results["items"]] diff --git a/mex/editor/settings.py b/mex/editor/settings.py index 657ba9b..e1d15d1 100644 --- a/mex/editor/settings.py +++ b/mex/editor/settings.py @@ -1,8 +1,7 @@ from pydantic import Field from mex.common.settings import BaseSettings -from mex.common.types import IdentityProvider -from mex.editor.types import EditorIdentityProvider, EditorUserDatabase +from mex.editor.types import EditorUserDatabase class EditorSettings(BaseSettings): @@ -13,8 +12,3 @@ class EditorSettings(BaseSettings): description="Database of users.", validation_alias="MEX_BACKEND_API_USER_DATABASE", ) - identity_provider: IdentityProvider | EditorIdentityProvider = Field( - IdentityProvider.MEMORY, - description="Provider to assign stableTargetIds to new model instances.", - validation_alias="MEX_IDENTITY_PROVIDER", - ) # type: ignore[assignment] diff --git a/mex/editor/types.py b/mex/editor/types.py index 45c4e00..5268a1e 100644 --- a/mex/editor/types.py +++ b/mex/editor/types.py @@ -1,4 +1,3 @@ -from enum import Enum from typing import cast from pydantic import SecretStr @@ -21,9 +20,3 @@ def __getitem__( ) -> dict[str, EditorUserPassword]: # stop-gap: MX-1596 """Return an attribute in indexing syntax.""" return cast(dict[str, EditorUserPassword], getattr(self, key)) - - -class EditorIdentityProvider(Enum): - """Identity providers implemented by the mex-editor.""" - - BACKEND = "backend" diff --git a/mex/mex.py b/mex/mex.py index 9e11c39..2481948 100644 --- a/mex/mex.py +++ b/mex/mex.py @@ -2,21 +2,16 @@ from reflex.components.radix import themes from reflex.utils.console import info as log_info -from mex.common.identity.registry import register_provider from mex.common.logging import logger from mex.editor.api.main import check_system_status from mex.editor.edit.main import index as edit_index from mex.editor.edit.state import EditState -from mex.editor.identity import BackendIdentityProvider from mex.editor.login.main import index as login_index from mex.editor.merge.main import index as merge_index from mex.editor.search.main import index as search_index from mex.editor.search.state import SearchState from mex.editor.settings import EditorSettings from mex.editor.state import State -from mex.editor.types import EditorIdentityProvider - -register_provider(EditorIdentityProvider.BACKEND, BackendIdentityProvider) app = rx.App( html_lang="en", diff --git a/pdm.lock b/pdm.lock index 524525b..eee3c4f 100644 --- a/pdm.lock +++ b/pdm.lock @@ -5,7 +5,7 @@ groups = ["default", "dev"] strategy = ["inherit_metadata"] lock_version = "4.5.0" -content_hash = "sha256:98c96a8b4bdff1e90da8ee1bffd435883fda3fba8ab132cb81141ff20c33a690" +content_hash = "sha256:a5f76fd4c8be5e3d9a6e61c87da043bb60baaf531790e0ced41fbba4cdd7e107" [[metadata.targets]] requires_python = "==3.11.*" @@ -768,11 +768,11 @@ files = [ [[package]] name = "mex-common" -version = "0.46.0" +version = "0.48.0" requires_python = ">=3.11,<3.13" git = "https://github.com/robert-koch-institut/mex-common.git" -ref = "0.46.0" -revision = "ca1f62afdf09587d68fbb86c89bdbb2a1176377c" +ref = "0.48.0" +revision = "9a917770bf36f04e5fe62cdb7b0ca36ee68d143c" summary = "Common library for MEx python projects." groups = ["default"] dependencies = [ @@ -783,7 +783,7 @@ dependencies = [ "mex-model @ git+https://github.com/robert-koch-institut/mex-model.git@3.4.0", "numpy<3,>=2", "pandas<3,>=2", - "pyarrow<19,>=18", + "pyarrow<20,>=19", "pydantic-settings<3,>=2", "pydantic<2.10,>=2", "pytz<2024.2,>=2024", @@ -1049,19 +1049,19 @@ files = [ [[package]] name = "pyarrow" -version = "18.1.0" +version = "19.0.0" requires_python = ">=3.9" summary = "Python library for Apache Arrow" groups = ["default"] files = [ - {file = "pyarrow-18.1.0-cp311-cp311-macosx_12_0_arm64.whl", hash = "sha256:eaeabf638408de2772ce3d7793b2668d4bb93807deed1725413b70e3156a7854"}, - {file = "pyarrow-18.1.0-cp311-cp311-macosx_12_0_x86_64.whl", hash = "sha256:3b2e2239339c538f3464308fd345113f886ad031ef8266c6f004d49769bb074c"}, - {file = "pyarrow-18.1.0-cp311-cp311-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:f39a2e0ed32a0970e4e46c262753417a60c43a3246972cfc2d3eb85aedd01b21"}, - {file = "pyarrow-18.1.0-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:e31e9417ba9c42627574bdbfeada7217ad8a4cbbe45b9d6bdd4b62abbca4c6f6"}, - {file = "pyarrow-18.1.0-cp311-cp311-manylinux_2_28_aarch64.whl", hash = "sha256:01c034b576ce0eef554f7c3d8c341714954be9b3f5d5bc7117006b85fcf302fe"}, - {file = "pyarrow-18.1.0-cp311-cp311-manylinux_2_28_x86_64.whl", hash = "sha256:f266a2c0fc31995a06ebd30bcfdb7f615d7278035ec5b1cd71c48d56daaf30b0"}, - {file = "pyarrow-18.1.0-cp311-cp311-win_amd64.whl", hash = "sha256:d4f13eee18433f99adefaeb7e01d83b59f73360c231d4782d9ddfaf1c3fbde0a"}, - {file = "pyarrow-18.1.0.tar.gz", hash = "sha256:9386d3ca9c145b5539a1cfc75df07757dff870168c959b473a0bccbc3abc8c73"}, + {file = "pyarrow-19.0.0-cp311-cp311-macosx_12_0_arm64.whl", hash = "sha256:8e3a839bf36ec03b4315dc924d36dcde5444a50066f1c10f8290293c0427b46a"}, + {file = "pyarrow-19.0.0-cp311-cp311-macosx_12_0_x86_64.whl", hash = "sha256:ce42275097512d9e4e4a39aade58ef2b3798a93aa3026566b7892177c266f735"}, + {file = "pyarrow-19.0.0-cp311-cp311-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:9348a0137568c45601b031a8d118275069435f151cbb77e6a08a27e8125f59d4"}, + {file = "pyarrow-19.0.0-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:2a0144a712d990d60f7f42b7a31f0acaccf4c1e43e957f7b1ad58150d6f639c1"}, + {file = "pyarrow-19.0.0-cp311-cp311-manylinux_2_28_aarch64.whl", hash = "sha256:2a1a109dfda558eb011e5f6385837daffd920d54ca00669f7a11132d0b1e6042"}, + {file = "pyarrow-19.0.0-cp311-cp311-manylinux_2_28_x86_64.whl", hash = "sha256:be686bf625aa7b9bada18defb3a3ea3981c1099697239788ff111d87f04cd263"}, + {file = "pyarrow-19.0.0-cp311-cp311-win_amd64.whl", hash = "sha256:239ca66d9a05844bdf5af128861af525e14df3c9591bcc05bac25918e650d3a2"}, + {file = "pyarrow-19.0.0.tar.gz", hash = "sha256:8d47c691765cf497aaeed4954d226568563f1b3b74ff61139f2d77876717084b"}, ] [[package]] diff --git a/pyproject.toml b/pyproject.toml index 41b0a2b..6661944 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -10,7 +10,7 @@ requires-python = ">=3.11,<3.12" dependencies = [ "babel>=2,<3", "fastapi>=0.115,<1", - "mex-common @ git+https://github.com/robert-koch-institut/mex-common.git@0.46.0", + "mex-common @ git+https://github.com/robert-koch-institut/mex-common.git@0.48.0", "pydantic>=2,<3", "pytz>=2024,<2025", "pyyaml>=6,<7", diff --git a/tests/conftest.py b/tests/conftest.py index 627de46..a240002 100644 --- a/tests/conftest.py +++ b/tests/conftest.py @@ -23,11 +23,7 @@ YearMonthDay, ) from mex.editor.settings import EditorSettings -from mex.editor.types import ( - EditorIdentityProvider, - EditorUserDatabase, - EditorUserPassword, -) +from mex.editor.types import EditorUserDatabase, EditorUserPassword from mex.mex import app pytest_plugins = ("mex.common.testing.plugin",) @@ -53,9 +49,7 @@ def set_identity_provider(is_integration_test: bool, monkeypatch: MonkeyPatch) - settings = EditorSettings.get() if is_integration_test: monkeypatch.setitem(settings.model_config, "validate_assignment", False) - monkeypatch.setattr( - settings, "identity_provider", EditorIdentityProvider.BACKEND - ) + monkeypatch.setattr(settings, "identity_provider", IdentityProvider.BACKEND) else: monkeypatch.setattr(settings, "identity_provider", IdentityProvider.MEMORY)