From 6bfd6028b5e0a0da5edd9327bbf115bfb4129f67 Mon Sep 17 00:00:00 2001 From: Nicolas Drebenstedt <897972+cutoffthetop@users.noreply.github.com> Date: Wed, 24 Jul 2024 14:52:34 +0200 Subject: [PATCH] Feature/computed field adjustments (#107) # PR Context - uses https://github.com/robert-koch-institut/mex-common/pull/230 # Added - add support for computed fields in graph queries # Changes - BREAKING: make `MEX_EXTRACTED_PRIMARY_SOURCE` an instance of its own class instead of ExtractedPrimarySource in order to set static provenance identifiers --- CHANGELOG.md | 5 + mex/backend/fields.py | 25 ++--- mex/backend/graph/connector.py | 41 +++++--- mex/backend/main.py | 9 +- pdm.lock | 175 ++++++++++++++++----------------- pyproject.toml | 4 +- tests/conftest.py | 18 ++-- tests/ingest/test_main.py | 9 +- tests/test_roundtrip.py | 11 ++- tests/test_security.py | 5 +- 10 files changed, 157 insertions(+), 145 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 49b28054..0d4b4578 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -9,8 +9,13 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ### Added +- add support for computed fields in graph queries + ### Changes +- BREAKING: make `MEX_EXTRACTED_PRIMARY_SOURCE` an instance of its own class + instead of ExtractedPrimarySource in order to set static provenance identifiers + ### Deprecated ### Removed diff --git a/mex/backend/fields.py b/mex/backend/fields.py index 01561fab..84b836f9 100644 --- a/mex/backend/fields.py +++ b/mex/backend/fields.py @@ -1,22 +1,15 @@ from collections.abc import Callable, Generator, Mapping from types import NoneType, UnionType -from typing import ( - Annotated, - Any, - Union, - get_args, - get_origin, -) - -from pydantic import BaseModel -from pydantic.fields import FieldInfo +from typing import Annotated, Any, Union, get_args, get_origin from mex.common.models import ( ADDITIVE_MODEL_CLASSES_BY_NAME, EXTRACTED_MODEL_CLASSES_BY_NAME, PREVENTIVE_MODEL_CLASSES_BY_NAME, SUBTRACTIVE_MODEL_CLASSES_BY_NAME, + BaseModel, ) +from mex.common.models.base import GenericFieldInfo from mex.common.types import MERGED_IDENTIFIER_CLASSES, Link, LiteralStringType, Text @@ -38,14 +31,14 @@ def _get_inner_types(annotation: Any) -> Generator[type, None, None]: yield annotation -def _contains_only_types(field: FieldInfo, *types: type) -> bool: +def _contains_only_types(field: GenericFieldInfo, *types: type) -> bool: """Return whether a `field` is annotated as one of the given `types`. Unions, lists and type annotations are checked for their inner types and only the non-`NoneType` types are considered for the type-check. Args: - field: A pydantic `FieldInfo` object + field: A `GenericFieldInfo` instance types: Types to look for in the field's annotation Returns: @@ -58,7 +51,7 @@ def _contains_only_types(field: FieldInfo, *types: type) -> bool: def _group_fields_by_class_name( model_classes_by_name: Mapping[str, type[BaseModel]], - predicate: Callable[[FieldInfo], bool], + predicate: Callable[[GenericFieldInfo], bool], ) -> dict[str, list[str]]: """Group the field names by model class and filter them by the given predicate. @@ -73,7 +66,7 @@ def _group_fields_by_class_name( name: sorted( { field_name - for field_name, field_info in cls.model_fields.items() + for field_name, field_info in cls.get_all_fields().items() if predicate(field_info) } ) @@ -144,7 +137,7 @@ def _group_fields_by_class_name( name: sorted( { field_name - for field_name in cls.model_fields + for field_name in cls.get_all_fields() if field_name not in ( *FROZEN_FIELDS_BY_CLASS_NAME[name], @@ -162,7 +155,7 @@ def _group_fields_by_class_name( name: sorted( { field_name - for field_name in cls.model_fields + for field_name in cls.get_all_fields() if field_name in FROZEN_FIELDS_BY_CLASS_NAME[name] and field_name not in ( diff --git a/mex/backend/graph/connector.py b/mex/backend/graph/connector.py index 724e669d..3c9e8177 100644 --- a/mex/backend/graph/connector.py +++ b/mex/backend/graph/connector.py @@ -1,8 +1,9 @@ import json from string import Template -from typing import Any +from typing import Annotated, Any, Literal, cast from neo4j import Driver, GraphDatabase +from pydantic import Field from mex.backend.fields import ( FINAL_FIELDS_BY_CLASS_NAME, @@ -15,9 +16,7 @@ ) from mex.backend.graph.models import Result from mex.backend.graph.query import QueryBuilder -from mex.backend.graph.transform import ( - expand_references_in_search_result, -) +from mex.backend.graph.transform import expand_references_in_search_result from mex.backend.settings import BackendSettings from mex.backend.transform import to_primitive from mex.common.connector import BaseConnector @@ -33,17 +32,35 @@ AnyRuleModel, ExtractedPrimarySource, ) +from mex.common.models.primary_source import BasePrimarySource from mex.common.transform import ensure_prefix, to_key_and_values -from mex.common.types import AnyPrimitiveType, Identifier, Link, Text - -MEX_EXTRACTED_PRIMARY_SOURCE = ExtractedPrimarySource.model_construct( - hadPrimarySource=MEX_PRIMARY_SOURCE_STABLE_TARGET_ID, - identifier=MEX_PRIMARY_SOURCE_IDENTIFIER, - identifierInPrimarySource=MEX_PRIMARY_SOURCE_IDENTIFIER_IN_PRIMARY_SOURCE, - stableTargetId=MEX_PRIMARY_SOURCE_STABLE_TARGET_ID, +from mex.common.types import ( + AnyPrimitiveType, + ExtractedPrimarySourceIdentifier, + Identifier, + Link, + MergedPrimarySourceIdentifier, + Text, ) +class MExPrimarySource(BasePrimarySource): + """An automatically extracted metadata set describing a primary source.""" + + entityType: Annotated[ + Literal["ExtractedPrimarySource"], Field(alias="$type", frozen=True) + ] = "ExtractedPrimarySource" + hadPrimarySource: MergedPrimarySourceIdentifier = ( + MEX_PRIMARY_SOURCE_STABLE_TARGET_ID + ) + identifier: ExtractedPrimarySourceIdentifier = MEX_PRIMARY_SOURCE_IDENTIFIER + identifierInPrimarySource: str = MEX_PRIMARY_SOURCE_IDENTIFIER_IN_PRIMARY_SOURCE + stableTargetId: MergedPrimarySourceIdentifier = MEX_PRIMARY_SOURCE_STABLE_TARGET_ID + + +MEX_EXTRACTED_PRIMARY_SOURCE = MExPrimarySource() + + class GraphConnector(BaseConnector): """Connector to handle authentication and transactions with the graph database.""" @@ -112,7 +129,7 @@ def _seed_indices(self) -> Result: def _seed_data(self) -> list[Identifier]: """Ensure the primary source `mex` is seeded and linked to itself.""" - return self.ingest([MEX_EXTRACTED_PRIMARY_SOURCE]) + return self.ingest([cast(ExtractedPrimarySource, MEX_EXTRACTED_PRIMARY_SOURCE)]) def close(self) -> None: """Close the connector's underlying requests session.""" diff --git a/mex/backend/main.py b/mex/backend/main.py index d70770f8..c0038b89 100644 --- a/mex/backend/main.py +++ b/mex/backend/main.py @@ -1,5 +1,6 @@ from collections.abc import AsyncIterator from contextlib import asynccontextmanager +from itertools import chain from typing import Any import uvicorn @@ -19,7 +20,7 @@ from mex.backend.settings import BackendSettings from mex.common.cli import entrypoint from mex.common.connector import CONNECTOR_STORE -from mex.common.types import Identifier +from mex.common.types import EXTRACTED_IDENTIFIER_CLASSES, MERGED_IDENTIFIER_CLASSES from mex.common.types.identifier import MEX_ID_PATTERN @@ -45,12 +46,12 @@ def create_openapi_schema() -> dict[str, Any]: routes=app.routes, servers=[dict(url=settings.backend_api_url)], ) - for subclass in Identifier.__subclasses__(): - name = subclass.__name__ + for identifier in chain(EXTRACTED_IDENTIFIER_CLASSES, MERGED_IDENTIFIER_CLASSES): + name = identifier.__name__ openapi_schema["components"]["schemas"][name] = { "title": name, "type": "string", - "description": subclass.__doc__, + "description": identifier.__doc__, "pattern": MEX_ID_PATTERN, } diff --git a/pdm.lock b/pdm.lock index 4cfc0033..22b319d3 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:5ce89d1a94f79b40515bc90f9c2829485ef75b54d66924b2790280ce3a6403fa" +content_hash = "sha256:840f57e6bf6d6cc616c0f9e3ba95a783b2b846f6b9af794d4f5907cc232c7726" [[metadata.targets]] requires_python = ">=3.11,<3.13" @@ -57,7 +57,6 @@ name = "asttokens" version = "2.4.1" summary = "Annotate AST trees with source code positions" groups = ["dev"] -marker = "python_version >= \"3.11\"" dependencies = [ "six>=1.12.0", "typing; python_version < \"3.5\"", @@ -270,7 +269,6 @@ version = "5.1.1" requires_python = ">=3.5" summary = "Decorators for Humans" groups = ["dev"] -marker = "python_version >= \"3.11\"" files = [ {file = "decorator-5.1.1-py3-none-any.whl", hash = "sha256:b8c3f85900b9dc423225913c5aace94729fe1fa9763b38939a95226f02d37186"}, {file = "decorator-5.1.1.tar.gz", hash = "sha256:637996211036b6385ef91435e4fae22989472f9d571faba8927ba8253acbc330"}, @@ -319,7 +317,6 @@ version = "2.0.1" requires_python = ">=3.5" summary = "Get the currently executing AST node of a frame, and other information" groups = ["dev"] -marker = "python_version >= \"3.11\"" files = [ {file = "executing-2.0.1-py2.py3-none-any.whl", hash = "sha256:eac49ca94516ccc753f9fb5ce82603156e590b27525a8bc32cce8ae302eb61bc"}, {file = "executing-2.0.1.tar.gz", hash = "sha256:35afe2ce3affba8ee97f2d69927fa823b08b472b7b994e36a52a964b93d16147"}, @@ -502,7 +499,6 @@ version = "8.26.0" requires_python = ">=3.10" summary = "IPython: Productive Interactive Computing" groups = ["dev"] -marker = "python_version >= \"3.11\"" dependencies = [ "colorama; sys_platform == \"win32\"", "decorator", @@ -527,7 +523,6 @@ version = "0.19.1" requires_python = ">=3.6" summary = "An autocompletion tool for Python that can be used for text editors." groups = ["dev"] -marker = "python_version >= \"3.11\"" dependencies = [ "parso<0.9.0,>=0.8.3", ] @@ -625,7 +620,6 @@ version = "0.1.7" requires_python = ">=3.8" summary = "Inline Matplotlib backend for Jupyter" groups = ["dev"] -marker = "python_version >= \"3.11\"" dependencies = [ "traitlets", ] @@ -647,11 +641,11 @@ files = [ [[package]] name = "mex-common" -version = "0.27.1" +version = "0.32.0" requires_python = "<3.13,>=3.11" git = "https://github.com/robert-koch-institut/mex-common.git" -ref = "0.27.1" -revision = "575cd77a829d2f2293d47c171f9acc3d741dfb21" +ref = "0.32.0" +revision = "bea6732316094b40103f49a16134a24da0e2caba" summary = "Common library for MEx python projects." groups = ["default"] dependencies = [ @@ -660,11 +654,11 @@ dependencies = [ "langdetect==1.0.9", "ldap3==2.9.1", "mex-model @ git+https://github.com/robert-koch-institut/mex-model.git@2.5.0", - "numpy==1.26.4", + "numpy==2.0.0", "pandas==2.2.2", - "pyarrow==16.1.0", - "pydantic-settings==2.3.3", - "pydantic==2.7.4", + "pyarrow==17.0.0", + "pydantic-settings==2.3.4", + "pydantic==2.8.2", "requests==2.32.3", ] @@ -731,28 +725,32 @@ files = [ [[package]] name = "numpy" -version = "1.26.4" +version = "2.0.0" requires_python = ">=3.9" summary = "Fundamental package for array computing in Python" groups = ["default"] files = [ - {file = "numpy-1.26.4-cp311-cp311-macosx_10_9_x86_64.whl", hash = "sha256:4c66707fabe114439db9068ee468c26bbdf909cac0fb58686a42a24de1760c71"}, - {file = "numpy-1.26.4-cp311-cp311-macosx_11_0_arm64.whl", hash = "sha256:edd8b5fe47dab091176d21bb6de568acdd906d1887a4584a15a9a96a1dca06ef"}, - {file = "numpy-1.26.4-cp311-cp311-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:7ab55401287bfec946ced39700c053796e7cc0e3acbef09993a9ad2adba6ca6e"}, - {file = "numpy-1.26.4-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:666dbfb6ec68962c033a450943ded891bed2d54e6755e35e5835d63f4f6931d5"}, - {file = "numpy-1.26.4-cp311-cp311-musllinux_1_1_aarch64.whl", hash = "sha256:96ff0b2ad353d8f990b63294c8986f1ec3cb19d749234014f4e7eb0112ceba5a"}, - {file = "numpy-1.26.4-cp311-cp311-musllinux_1_1_x86_64.whl", hash = "sha256:60dedbb91afcbfdc9bc0b1f3f402804070deed7392c23eb7a7f07fa857868e8a"}, - {file = "numpy-1.26.4-cp311-cp311-win32.whl", hash = "sha256:1af303d6b2210eb850fcf03064d364652b7120803a0b872f5211f5234b399f20"}, - {file = "numpy-1.26.4-cp311-cp311-win_amd64.whl", hash = "sha256:cd25bcecc4974d09257ffcd1f098ee778f7834c3ad767fe5db785be9a4aa9cb2"}, - {file = "numpy-1.26.4-cp312-cp312-macosx_10_9_x86_64.whl", hash = "sha256:b3ce300f3644fb06443ee2222c2201dd3a89ea6040541412b8fa189341847218"}, - {file = "numpy-1.26.4-cp312-cp312-macosx_11_0_arm64.whl", hash = "sha256:03a8c78d01d9781b28a6989f6fa1bb2c4f2d51201cf99d3dd875df6fbd96b23b"}, - {file = "numpy-1.26.4-cp312-cp312-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:9fad7dcb1aac3c7f0584a5a8133e3a43eeb2fe127f47e3632d43d677c66c102b"}, - {file = "numpy-1.26.4-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:675d61ffbfa78604709862923189bad94014bef562cc35cf61d3a07bba02a7ed"}, - {file = "numpy-1.26.4-cp312-cp312-musllinux_1_1_aarch64.whl", hash = "sha256:ab47dbe5cc8210f55aa58e4805fe224dac469cde56b9f731a4c098b91917159a"}, - {file = "numpy-1.26.4-cp312-cp312-musllinux_1_1_x86_64.whl", hash = "sha256:1dda2e7b4ec9dd512f84935c5f126c8bd8b9f2fc001e9f54af255e8c5f16b0e0"}, - {file = "numpy-1.26.4-cp312-cp312-win32.whl", hash = "sha256:50193e430acfc1346175fcbdaa28ffec49947a06918b7b92130744e81e640110"}, - {file = "numpy-1.26.4-cp312-cp312-win_amd64.whl", hash = "sha256:08beddf13648eb95f8d867350f6a018a4be2e5ad54c8d8caed89ebca558b2818"}, - {file = "numpy-1.26.4.tar.gz", hash = "sha256:2a02aba9ed12e4ac4eb3ea9421c420301a0c6460d9830d74a9df87efa4912010"}, + {file = "numpy-2.0.0-cp311-cp311-macosx_10_9_x86_64.whl", hash = "sha256:ad0c86f3455fbd0de6c31a3056eb822fc939f81b1618f10ff3406971893b62a5"}, + {file = "numpy-2.0.0-cp311-cp311-macosx_11_0_arm64.whl", hash = "sha256:e7f387600d424f91576af20518334df3d97bc76a300a755f9a8d6e4f5cadd289"}, + {file = "numpy-2.0.0-cp311-cp311-macosx_14_0_arm64.whl", hash = "sha256:34f003cb88b1ba38cb9a9a4a3161c1604973d7f9d5552c38bc2f04f829536609"}, + {file = "numpy-2.0.0-cp311-cp311-macosx_14_0_x86_64.whl", hash = "sha256:b6f6a8f45d0313db07d6d1d37bd0b112f887e1369758a5419c0370ba915b3871"}, + {file = "numpy-2.0.0-cp311-cp311-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:5f64641b42b2429f56ee08b4f427a4d2daf916ec59686061de751a55aafa22e4"}, + {file = "numpy-2.0.0-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:a7039a136017eaa92c1848152827e1424701532ca8e8967fe480fe1569dae581"}, + {file = "numpy-2.0.0-cp311-cp311-musllinux_1_1_x86_64.whl", hash = "sha256:46e161722e0f619749d1cd892167039015b2c2817296104487cd03ed4a955995"}, + {file = "numpy-2.0.0-cp311-cp311-musllinux_1_2_aarch64.whl", hash = "sha256:0e50842b2295ba8414c8c1d9d957083d5dfe9e16828b37de883f51fc53c4016f"}, + {file = "numpy-2.0.0-cp311-cp311-win32.whl", hash = "sha256:2ce46fd0b8a0c947ae047d222f7136fc4d55538741373107574271bc00e20e8f"}, + {file = "numpy-2.0.0-cp311-cp311-win_amd64.whl", hash = "sha256:fbd6acc766814ea6443628f4e6751d0da6593dae29c08c0b2606164db026970c"}, + {file = "numpy-2.0.0-cp312-cp312-macosx_10_9_x86_64.whl", hash = "sha256:354f373279768fa5a584bac997de6a6c9bc535c482592d7a813bb0c09be6c76f"}, + {file = "numpy-2.0.0-cp312-cp312-macosx_11_0_arm64.whl", hash = "sha256:4d2f62e55a4cd9c58c1d9a1c9edaedcd857a73cb6fda875bf79093f9d9086f85"}, + {file = "numpy-2.0.0-cp312-cp312-macosx_14_0_arm64.whl", hash = "sha256:1e72728e7501a450288fc8e1f9ebc73d90cfd4671ebbd631f3e7857c39bd16f2"}, + {file = "numpy-2.0.0-cp312-cp312-macosx_14_0_x86_64.whl", hash = "sha256:84554fc53daa8f6abf8e8a66e076aff6ece62de68523d9f665f32d2fc50fd66e"}, + {file = "numpy-2.0.0-cp312-cp312-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:c73aafd1afca80afecb22718f8700b40ac7cab927b8abab3c3e337d70e10e5a2"}, + {file = "numpy-2.0.0-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:49d9f7d256fbc804391a7f72d4a617302b1afac1112fac19b6c6cec63fe7fe8a"}, + {file = "numpy-2.0.0-cp312-cp312-musllinux_1_1_x86_64.whl", hash = "sha256:0ec84b9ba0654f3b962802edc91424331f423dcf5d5f926676e0150789cb3d95"}, + {file = "numpy-2.0.0-cp312-cp312-musllinux_1_2_aarch64.whl", hash = "sha256:feff59f27338135776f6d4e2ec7aeeac5d5f7a08a83e80869121ef8164b74af9"}, + {file = "numpy-2.0.0-cp312-cp312-win32.whl", hash = "sha256:c5a59996dc61835133b56a32ebe4ef3740ea5bc19b3983ac60cc32be5a665d54"}, + {file = "numpy-2.0.0-cp312-cp312-win_amd64.whl", hash = "sha256:a356364941fb0593bb899a1076b92dfa2029f6f5b8ba88a14fd0984aaf76d0df"}, + {file = "numpy-2.0.0.tar.gz", hash = "sha256:cf5d1c9e6837f8af9f92b6bd3e86d513cdc11f60fd62185cc49ec7d1aba34864"}, ] [[package]] @@ -804,7 +802,6 @@ version = "0.8.4" requires_python = ">=3.6" summary = "A Python Parser" groups = ["dev"] -marker = "python_version >= \"3.11\"" files = [ {file = "parso-0.8.4-py2.py3-none-any.whl", hash = "sha256:a418670a20291dacd2dddc80c377c5c3791378ee1e8d12bffc35420643d43f18"}, {file = "parso-0.8.4.tar.gz", hash = "sha256:eb3a7b58240fb99099a345571deecc0f9540ea5f4dd2fe14c2a99d6b281ab92d"}, @@ -826,7 +823,7 @@ name = "pexpect" version = "4.9.0" summary = "Pexpect allows easy control of interactive console applications." groups = ["dev"] -marker = "(sys_platform != \"win32\" and sys_platform != \"emscripten\") and python_version >= \"3.11\"" +marker = "sys_platform != \"win32\" and sys_platform != \"emscripten\"" dependencies = [ "ptyprocess>=0.5", ] @@ -863,7 +860,6 @@ version = "3.0.47" requires_python = ">=3.7.0" summary = "Library for building powerful interactive command lines in Python" groups = ["dev"] -marker = "python_version >= \"3.11\"" dependencies = [ "wcwidth", ] @@ -877,7 +873,7 @@ name = "ptyprocess" version = "0.7.0" summary = "Run a subprocess in a pseudo terminal" groups = ["dev"] -marker = "(sys_platform != \"win32\" and sys_platform != \"emscripten\") and python_version >= \"3.11\"" +marker = "sys_platform != \"win32\" and sys_platform != \"emscripten\"" files = [ {file = "ptyprocess-0.7.0-py2.py3-none-any.whl", hash = "sha256:4b41f3967fce3af57cc7e94b888626c18bf37a083e3651ca8feeb66d492fef35"}, {file = "ptyprocess-0.7.0.tar.gz", hash = "sha256:5c5d0a3b48ceee0b48485e0c26037c0acd7d29765ca3fbb5cb3831d347423220"}, @@ -888,7 +884,6 @@ name = "pure-eval" version = "0.2.3" summary = "Safely evaluate AST nodes without side effects" groups = ["dev"] -marker = "python_version >= \"3.11\"" files = [ {file = "pure_eval-0.2.3-py3-none-any.whl", hash = "sha256:1db8e35b67b3d218d818ae653e27f06c3aa420901fa7b081ca98cbedc874e0d0"}, {file = "pure_eval-0.2.3.tar.gz", hash = "sha256:5f4e983f40564c576c7c8635ae88db5956bb2229d7e9237d03b3c0b0190eaf42"}, @@ -896,7 +891,7 @@ files = [ [[package]] name = "pyarrow" -version = "16.1.0" +version = "17.0.0" requires_python = ">=3.8" summary = "Python library for Apache Arrow" groups = ["default"] @@ -904,21 +899,21 @@ dependencies = [ "numpy>=1.16.6", ] files = [ - {file = "pyarrow-16.1.0-cp311-cp311-macosx_10_15_x86_64.whl", hash = "sha256:d0ebea336b535b37eee9eee31761813086d33ed06de9ab6fc6aaa0bace7b250c"}, - {file = "pyarrow-16.1.0-cp311-cp311-macosx_11_0_arm64.whl", hash = "sha256:2e73cfc4a99e796727919c5541c65bb88b973377501e39b9842ea71401ca6c1c"}, - {file = "pyarrow-16.1.0-cp311-cp311-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:bf9251264247ecfe93e5f5a0cd43b8ae834f1e61d1abca22da55b20c788417f6"}, - {file = "pyarrow-16.1.0-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:ddf5aace92d520d3d2a20031d8b0ec27b4395cab9f74e07cc95edf42a5cc0147"}, - {file = "pyarrow-16.1.0-cp311-cp311-manylinux_2_28_aarch64.whl", hash = "sha256:25233642583bf658f629eb230b9bb79d9af4d9f9229890b3c878699c82f7d11e"}, - {file = "pyarrow-16.1.0-cp311-cp311-manylinux_2_28_x86_64.whl", hash = "sha256:a33a64576fddfbec0a44112eaf844c20853647ca833e9a647bfae0582b2ff94b"}, - {file = "pyarrow-16.1.0-cp311-cp311-win_amd64.whl", hash = "sha256:185d121b50836379fe012753cf15c4ba9638bda9645183ab36246923875f8d1b"}, - {file = "pyarrow-16.1.0-cp312-cp312-macosx_10_15_x86_64.whl", hash = "sha256:2e51ca1d6ed7f2e9d5c3c83decf27b0d17bb207a7dea986e8dc3e24f80ff7d6f"}, - {file = "pyarrow-16.1.0-cp312-cp312-macosx_11_0_arm64.whl", hash = "sha256:06ebccb6f8cb7357de85f60d5da50e83507954af617d7b05f48af1621d331c9a"}, - {file = "pyarrow-16.1.0-cp312-cp312-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:b04707f1979815f5e49824ce52d1dceb46e2f12909a48a6a753fe7cafbc44a0c"}, - {file = "pyarrow-16.1.0-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:0d32000693deff8dc5df444b032b5985a48592c0697cb6e3071a5d59888714e2"}, - {file = "pyarrow-16.1.0-cp312-cp312-manylinux_2_28_aarch64.whl", hash = "sha256:8785bb10d5d6fd5e15d718ee1d1f914fe768bf8b4d1e5e9bf253de8a26cb1628"}, - {file = "pyarrow-16.1.0-cp312-cp312-manylinux_2_28_x86_64.whl", hash = "sha256:e1369af39587b794873b8a307cc6623a3b1194e69399af0efd05bb202195a5a7"}, - {file = "pyarrow-16.1.0-cp312-cp312-win_amd64.whl", hash = "sha256:febde33305f1498f6df85e8020bca496d0e9ebf2093bab9e0f65e2b4ae2b3444"}, - {file = "pyarrow-16.1.0.tar.gz", hash = "sha256:15fbb22ea96d11f0b5768504a3f961edab25eaf4197c341720c4a387f6c60315"}, + {file = "pyarrow-17.0.0-cp311-cp311-macosx_10_15_x86_64.whl", hash = "sha256:1c8856e2ef09eb87ecf937104aacfa0708f22dfeb039c363ec99735190ffb977"}, + {file = "pyarrow-17.0.0-cp311-cp311-macosx_11_0_arm64.whl", hash = "sha256:2e19f569567efcbbd42084e87f948778eb371d308e137a0f97afe19bb860ccb3"}, + {file = "pyarrow-17.0.0-cp311-cp311-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:6b244dc8e08a23b3e352899a006a26ae7b4d0da7bb636872fa8f5884e70acf15"}, + {file = "pyarrow-17.0.0-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:0b72e87fe3e1db343995562f7fff8aee354b55ee83d13afba65400c178ab2597"}, + {file = "pyarrow-17.0.0-cp311-cp311-manylinux_2_28_aarch64.whl", hash = "sha256:dc5c31c37409dfbc5d014047817cb4ccd8c1ea25d19576acf1a001fe07f5b420"}, + {file = "pyarrow-17.0.0-cp311-cp311-manylinux_2_28_x86_64.whl", hash = "sha256:e3343cb1e88bc2ea605986d4b94948716edc7a8d14afd4e2c097232f729758b4"}, + {file = "pyarrow-17.0.0-cp311-cp311-win_amd64.whl", hash = "sha256:a27532c38f3de9eb3e90ecab63dfda948a8ca859a66e3a47f5f42d1e403c4d03"}, + {file = "pyarrow-17.0.0-cp312-cp312-macosx_10_15_x86_64.whl", hash = "sha256:9b8a823cea605221e61f34859dcc03207e52e409ccf6354634143e23af7c8d22"}, + {file = "pyarrow-17.0.0-cp312-cp312-macosx_11_0_arm64.whl", hash = "sha256:f1e70de6cb5790a50b01d2b686d54aaf73da01266850b05e3af2a1bc89e16053"}, + {file = "pyarrow-17.0.0-cp312-cp312-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:0071ce35788c6f9077ff9ecba4858108eebe2ea5a3f7cf2cf55ebc1dbc6ee24a"}, + {file = "pyarrow-17.0.0-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:757074882f844411fcca735e39aae74248a1531367a7c80799b4266390ae51cc"}, + {file = "pyarrow-17.0.0-cp312-cp312-manylinux_2_28_aarch64.whl", hash = "sha256:9ba11c4f16976e89146781a83833df7f82077cdab7dc6232c897789343f7891a"}, + {file = "pyarrow-17.0.0-cp312-cp312-manylinux_2_28_x86_64.whl", hash = "sha256:b0c6ac301093b42d34410b187bba560b17c0330f64907bfa4f7f7f2444b0cf9b"}, + {file = "pyarrow-17.0.0-cp312-cp312-win_amd64.whl", hash = "sha256:392bc9feabc647338e6c89267635e111d71edad5fcffba204425a7c8d13610d7"}, + {file = "pyarrow-17.0.0.tar.gz", hash = "sha256:4beca9521ed2c0921c1023e68d097d0299b62c362639ea315572a58f3f50fd28"}, ] [[package]] @@ -934,23 +929,24 @@ files = [ [[package]] name = "pydantic" -version = "2.7.4" +version = "2.8.2" requires_python = ">=3.8" summary = "Data validation using Python type hints" groups = ["default"] dependencies = [ "annotated-types>=0.4.0", - "pydantic-core==2.18.4", - "typing-extensions>=4.6.1", + "pydantic-core==2.20.1", + "typing-extensions>=4.12.2; python_version >= \"3.13\"", + "typing-extensions>=4.6.1; python_version < \"3.13\"", ] files = [ - {file = "pydantic-2.7.4-py3-none-any.whl", hash = "sha256:ee8538d41ccb9c0a9ad3e0e5f07bf15ed8015b481ced539a1759d8cc89ae90d0"}, - {file = "pydantic-2.7.4.tar.gz", hash = "sha256:0c84efd9548d545f63ac0060c1e4d39bb9b14db8b3c0652338aecc07b5adec52"}, + {file = "pydantic-2.8.2-py3-none-any.whl", hash = "sha256:73ee9fddd406dc318b885c7a2eab8a6472b68b8fb5ba8150949fc3db939f23c8"}, + {file = "pydantic-2.8.2.tar.gz", hash = "sha256:6f62c13d067b0755ad1c21a34bdd06c0c12625a22b0fc09c6b149816604f7c2a"}, ] [[package]] name = "pydantic-core" -version = "2.18.4" +version = "2.20.1" requires_python = ">=3.8" summary = "Core functionality for Pydantic validation and serialization" groups = ["default"] @@ -958,38 +954,36 @@ dependencies = [ "typing-extensions!=4.7.0,>=4.6.0", ] files = [ - {file = "pydantic_core-2.18.4-cp311-cp311-macosx_10_12_x86_64.whl", hash = "sha256:942ba11e7dfb66dc70f9ae66b33452f51ac7bb90676da39a7345e99ffb55402d"}, - {file = "pydantic_core-2.18.4-cp311-cp311-macosx_11_0_arm64.whl", hash = "sha256:b2ebef0e0b4454320274f5e83a41844c63438fdc874ea40a8b5b4ecb7693f1c4"}, - {file = "pydantic_core-2.18.4-cp311-cp311-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:a642295cd0c8df1b86fc3dced1d067874c353a188dc8e0f744626d49e9aa51c4"}, - {file = "pydantic_core-2.18.4-cp311-cp311-manylinux_2_17_armv7l.manylinux2014_armv7l.whl", hash = "sha256:5f09baa656c904807e832cf9cce799c6460c450c4ad80803517032da0cd062e2"}, - {file = "pydantic_core-2.18.4-cp311-cp311-manylinux_2_17_ppc64le.manylinux2014_ppc64le.whl", hash = "sha256:98906207f29bc2c459ff64fa007afd10a8c8ac080f7e4d5beff4c97086a3dabd"}, - {file = "pydantic_core-2.18.4-cp311-cp311-manylinux_2_17_s390x.manylinux2014_s390x.whl", hash = "sha256:19894b95aacfa98e7cb093cd7881a0c76f55731efad31073db4521e2b6ff5b7d"}, - {file = "pydantic_core-2.18.4-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:0fbbdc827fe5e42e4d196c746b890b3d72876bdbf160b0eafe9f0334525119c8"}, - {file = "pydantic_core-2.18.4-cp311-cp311-manylinux_2_5_i686.manylinux1_i686.whl", hash = "sha256:f85d05aa0918283cf29a30b547b4df2fbb56b45b135f9e35b6807cb28bc47951"}, - {file = "pydantic_core-2.18.4-cp311-cp311-musllinux_1_1_aarch64.whl", hash = "sha256:e85637bc8fe81ddb73fda9e56bab24560bdddfa98aa64f87aaa4e4b6730c23d2"}, - {file = "pydantic_core-2.18.4-cp311-cp311-musllinux_1_1_x86_64.whl", hash = "sha256:2f5966897e5461f818e136b8451d0551a2e77259eb0f73a837027b47dc95dab9"}, - {file = "pydantic_core-2.18.4-cp311-none-win32.whl", hash = "sha256:44c7486a4228413c317952e9d89598bcdfb06399735e49e0f8df643e1ccd0558"}, - {file = "pydantic_core-2.18.4-cp311-none-win_amd64.whl", hash = "sha256:8a7164fe2005d03c64fd3b85649891cd4953a8de53107940bf272500ba8a788b"}, - {file = "pydantic_core-2.18.4-cp311-none-win_arm64.whl", hash = "sha256:4e99bc050fe65c450344421017f98298a97cefc18c53bb2f7b3531eb39bc7805"}, - {file = "pydantic_core-2.18.4-cp312-cp312-macosx_10_12_x86_64.whl", hash = "sha256:6f5c4d41b2771c730ea1c34e458e781b18cc668d194958e0112455fff4e402b2"}, - {file = "pydantic_core-2.18.4-cp312-cp312-macosx_11_0_arm64.whl", hash = "sha256:2fdf2156aa3d017fddf8aea5adfba9f777db1d6022d392b682d2a8329e087cef"}, - {file = "pydantic_core-2.18.4-cp312-cp312-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:4748321b5078216070b151d5271ef3e7cc905ab170bbfd27d5c83ee3ec436695"}, - {file = "pydantic_core-2.18.4-cp312-cp312-manylinux_2_17_armv7l.manylinux2014_armv7l.whl", hash = "sha256:847a35c4d58721c5dc3dba599878ebbdfd96784f3fb8bb2c356e123bdcd73f34"}, - {file = "pydantic_core-2.18.4-cp312-cp312-manylinux_2_17_ppc64le.manylinux2014_ppc64le.whl", hash = "sha256:3c40d4eaad41f78e3bbda31b89edc46a3f3dc6e171bf0ecf097ff7a0ffff7cb1"}, - {file = "pydantic_core-2.18.4-cp312-cp312-manylinux_2_17_s390x.manylinux2014_s390x.whl", hash = "sha256:21a5e440dbe315ab9825fcd459b8814bb92b27c974cbc23c3e8baa2b76890077"}, - {file = "pydantic_core-2.18.4-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:01dd777215e2aa86dfd664daed5957704b769e726626393438f9c87690ce78c3"}, - {file = "pydantic_core-2.18.4-cp312-cp312-manylinux_2_5_i686.manylinux1_i686.whl", hash = "sha256:4b06beb3b3f1479d32befd1f3079cc47b34fa2da62457cdf6c963393340b56e9"}, - {file = "pydantic_core-2.18.4-cp312-cp312-musllinux_1_1_aarch64.whl", hash = "sha256:564d7922e4b13a16b98772441879fcdcbe82ff50daa622d681dd682175ea918c"}, - {file = "pydantic_core-2.18.4-cp312-cp312-musllinux_1_1_x86_64.whl", hash = "sha256:0eb2a4f660fcd8e2b1c90ad566db2b98d7f3f4717c64fe0a83e0adb39766d5b8"}, - {file = "pydantic_core-2.18.4-cp312-none-win32.whl", hash = "sha256:8b8bab4c97248095ae0c4455b5a1cd1cdd96e4e4769306ab19dda135ea4cdb07"}, - {file = "pydantic_core-2.18.4-cp312-none-win_amd64.whl", hash = "sha256:14601cdb733d741b8958224030e2bfe21a4a881fb3dd6fbb21f071cabd48fa0a"}, - {file = "pydantic_core-2.18.4-cp312-none-win_arm64.whl", hash = "sha256:c1322d7dd74713dcc157a2b7898a564ab091ca6c58302d5c7b4c07296e3fd00f"}, - {file = "pydantic_core-2.18.4.tar.gz", hash = "sha256:ec3beeada09ff865c344ff3bc2f427f5e6c26401cc6113d77e372c3fdac73864"}, + {file = "pydantic_core-2.20.1-cp311-cp311-macosx_10_12_x86_64.whl", hash = "sha256:d2a8fa9d6d6f891f3deec72f5cc668e6f66b188ab14bb1ab52422fe8e644f312"}, + {file = "pydantic_core-2.20.1-cp311-cp311-macosx_11_0_arm64.whl", hash = "sha256:175873691124f3d0da55aeea1d90660a6ea7a3cfea137c38afa0a5ffabe37b88"}, + {file = "pydantic_core-2.20.1-cp311-cp311-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:37eee5b638f0e0dcd18d21f59b679686bbd18917b87db0193ae36f9c23c355fc"}, + {file = "pydantic_core-2.20.1-cp311-cp311-manylinux_2_17_armv7l.manylinux2014_armv7l.whl", hash = "sha256:25e9185e2d06c16ee438ed39bf62935ec436474a6ac4f9358524220f1b236e43"}, + {file = "pydantic_core-2.20.1-cp311-cp311-manylinux_2_17_ppc64le.manylinux2014_ppc64le.whl", hash = "sha256:150906b40ff188a3260cbee25380e7494ee85048584998c1e66df0c7a11c17a6"}, + {file = "pydantic_core-2.20.1-cp311-cp311-manylinux_2_17_s390x.manylinux2014_s390x.whl", hash = "sha256:8ad4aeb3e9a97286573c03df758fc7627aecdd02f1da04516a86dc159bf70121"}, + {file = "pydantic_core-2.20.1-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:d3f3ed29cd9f978c604708511a1f9c2fdcb6c38b9aae36a51905b8811ee5cbf1"}, + {file = "pydantic_core-2.20.1-cp311-cp311-manylinux_2_5_i686.manylinux1_i686.whl", hash = "sha256:b0dae11d8f5ded51699c74d9548dcc5938e0804cc8298ec0aa0da95c21fff57b"}, + {file = "pydantic_core-2.20.1-cp311-cp311-musllinux_1_1_aarch64.whl", hash = "sha256:faa6b09ee09433b87992fb5a2859efd1c264ddc37280d2dd5db502126d0e7f27"}, + {file = "pydantic_core-2.20.1-cp311-cp311-musllinux_1_1_x86_64.whl", hash = "sha256:9dc1b507c12eb0481d071f3c1808f0529ad41dc415d0ca11f7ebfc666e66a18b"}, + {file = "pydantic_core-2.20.1-cp311-none-win32.whl", hash = "sha256:fa2fddcb7107e0d1808086ca306dcade7df60a13a6c347a7acf1ec139aa6789a"}, + {file = "pydantic_core-2.20.1-cp311-none-win_amd64.whl", hash = "sha256:40a783fb7ee353c50bd3853e626f15677ea527ae556429453685ae32280c19c2"}, + {file = "pydantic_core-2.20.1-cp312-cp312-macosx_10_12_x86_64.whl", hash = "sha256:595ba5be69b35777474fa07f80fc260ea71255656191adb22a8c53aba4479231"}, + {file = "pydantic_core-2.20.1-cp312-cp312-macosx_11_0_arm64.whl", hash = "sha256:a4f55095ad087474999ee28d3398bae183a66be4823f753cd7d67dd0153427c9"}, + {file = "pydantic_core-2.20.1-cp312-cp312-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:f9aa05d09ecf4c75157197f27cdc9cfaeb7c5f15021c6373932bf3e124af029f"}, + {file = "pydantic_core-2.20.1-cp312-cp312-manylinux_2_17_armv7l.manylinux2014_armv7l.whl", hash = "sha256:e97fdf088d4b31ff4ba35db26d9cc472ac7ef4a2ff2badeabf8d727b3377fc52"}, + {file = "pydantic_core-2.20.1-cp312-cp312-manylinux_2_17_ppc64le.manylinux2014_ppc64le.whl", hash = "sha256:bc633a9fe1eb87e250b5c57d389cf28998e4292336926b0b6cdaee353f89a237"}, + {file = "pydantic_core-2.20.1-cp312-cp312-manylinux_2_17_s390x.manylinux2014_s390x.whl", hash = "sha256:d573faf8eb7e6b1cbbcb4f5b247c60ca8be39fe2c674495df0eb4318303137fe"}, + {file = "pydantic_core-2.20.1-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:26dc97754b57d2fd00ac2b24dfa341abffc380b823211994c4efac7f13b9e90e"}, + {file = "pydantic_core-2.20.1-cp312-cp312-manylinux_2_5_i686.manylinux1_i686.whl", hash = "sha256:33499e85e739a4b60c9dac710c20a08dc73cb3240c9a0e22325e671b27b70d24"}, + {file = "pydantic_core-2.20.1-cp312-cp312-musllinux_1_1_aarch64.whl", hash = "sha256:bebb4d6715c814597f85297c332297c6ce81e29436125ca59d1159b07f423eb1"}, + {file = "pydantic_core-2.20.1-cp312-cp312-musllinux_1_1_x86_64.whl", hash = "sha256:516d9227919612425c8ef1c9b869bbbee249bc91912c8aaffb66116c0b447ebd"}, + {file = "pydantic_core-2.20.1-cp312-none-win32.whl", hash = "sha256:469f29f9093c9d834432034d33f5fe45699e664f12a13bf38c04967ce233d688"}, + {file = "pydantic_core-2.20.1-cp312-none-win_amd64.whl", hash = "sha256:035ede2e16da7281041f0e626459bcae33ed998cca6a0a007a5ebb73414ac72d"}, + {file = "pydantic_core-2.20.1.tar.gz", hash = "sha256:26ca695eeee5f9f1aeeb211ffc12f10bcb6f71e2989988fda61dabd65db878d4"}, ] [[package]] name = "pydantic-settings" -version = "2.3.3" +version = "2.3.4" requires_python = ">=3.8" summary = "Settings management using Pydantic" groups = ["default"] @@ -998,8 +992,8 @@ dependencies = [ "python-dotenv>=0.21.0", ] files = [ - {file = "pydantic_settings-2.3.3-py3-none-any.whl", hash = "sha256:e4ed62ad851670975ec11285141db888fd24947f9440bd4380d7d8788d4965de"}, - {file = "pydantic_settings-2.3.3.tar.gz", hash = "sha256:87fda838b64b5039b970cd47c3e8a1ee460ce136278ff672980af21516f6e6ce"}, + {file = "pydantic_settings-2.3.4-py3-none-any.whl", hash = "sha256:11ad8bacb68a045f00e4f862c7a718c8a9ec766aa8fd4c32e39a0594b207b53a"}, + {file = "pydantic_settings-2.3.4.tar.gz", hash = "sha256:c5802e3d62b78e82522319bbc9b8f8ffb28ad1c988a99311d04f2a6051fca0a7"}, ] [[package]] @@ -1337,7 +1331,6 @@ name = "stack-data" version = "0.6.3" summary = "Extract data from python stack frames and tracebacks for informative displays" groups = ["dev"] -marker = "python_version >= \"3.11\"" dependencies = [ "asttokens>=2.1.0", "executing>=1.2.0", @@ -1369,7 +1362,6 @@ version = "5.14.3" requires_python = ">=3.8" summary = "Traitlets Python configuration system" groups = ["dev"] -marker = "python_version >= \"3.11\"" files = [ {file = "traitlets-5.14.3-py3-none-any.whl", hash = "sha256:b74e89e397b1ed28cc831db7aea759ba6640cb3de13090ca145426688ff1ac4f"}, {file = "traitlets-5.14.3.tar.gz", hash = "sha256:9ed0579d3502c94b4b3732ac120375cda96f923114522847de4b3bb98b96b6b7"}, @@ -1541,7 +1533,6 @@ name = "wcwidth" version = "0.2.13" summary = "Measures the displayed width of unicode strings in a terminal" groups = ["dev"] -marker = "python_version >= \"3.11\"" dependencies = [ "backports-functools-lru-cache>=1.2.1; python_version < \"3.2\"", ] diff --git a/pyproject.toml b/pyproject.toml index 897cfc31..280dc4f0 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -10,9 +10,9 @@ requires-python = "<3.13,>=3.11" dependencies = [ "fastapi==0.111.1", "httpx==0.27.0", - "mex-common@git+https://github.com/robert-koch-institut/mex-common.git@0.27.1", + "mex-common @ git+https://github.com/robert-koch-institut/mex-common.git@0.32.0", "neo4j==5.22.0", - "pydantic==2.7.4", + "pydantic==2.8.2", "uvicorn[standard]==0.30.3", ] optional-dependencies.dev = [ diff --git a/tests/conftest.py b/tests/conftest.py index 28bf9556..dc590dec 100644 --- a/tests/conftest.py +++ b/tests/conftest.py @@ -151,15 +151,15 @@ def generate(cls: type[Identifier], seed: int | None = None) -> Identifier: @pytest.fixture(autouse=True) def set_identity_provider(is_integration_test: bool, monkeypatch: MonkeyPatch) -> None: """Ensure the identifier provider is set correctly for unit and int tests.""" - settings = BaseSettings.get() - if is_integration_test: - # yuck, all this needs cleaning up after MX-1596 - monkeypatch.setitem(settings.model_config, "validate_assignment", False) - monkeypatch.setattr( - settings, "identity_provider", BackendIdentityProvider.GRAPH - ) - else: - monkeypatch.setattr(settings, "identity_provider", IdentityProvider.MEMORY) + # yuck, all this needs cleaning up after MX-1596 + for settings in (BaseSettings.get(), BackendSettings.get()): + if is_integration_test: + monkeypatch.setitem(settings.model_config, "validate_assignment", False) + monkeypatch.setattr( + settings, "identity_provider", BackendIdentityProvider.GRAPH + ) + else: + monkeypatch.setattr(settings, "identity_provider", IdentityProvider.MEMORY) @pytest.fixture(autouse=True) diff --git a/tests/ingest/test_main.py b/tests/ingest/test_main.py index 8972f3f3..17d8af94 100644 --- a/tests/ingest/test_main.py +++ b/tests/ingest/test_main.py @@ -62,9 +62,12 @@ def test_bulk_insert_malformed( assert response.json() == { "detail": [ { - "type": "dict_type", - "loc": ["body", "ExtractedContactPoint", 0, 1], - "msg": "Input should be a valid dictionary", + "ctx": {"error": {}}, + "type": "assertion_error", + "loc": ["body", "ExtractedContactPoint", 0], + "msg": "Assertion failed, Input should be a valid dictionary, " + "validating other types is not supported for models with computed " + "fields.", "input": "FAIL!", } ] diff --git a/tests/test_roundtrip.py b/tests/test_roundtrip.py index 906bd826..d2ac2a88 100644 --- a/tests/test_roundtrip.py +++ b/tests/test_roundtrip.py @@ -11,7 +11,9 @@ def test_graph_ingest_and_query_roundtrip( load_dummy_data: list[AnyExtractedModel], ) -> None: - seeded_models = [*load_dummy_data, MEX_EXTRACTED_PRIMARY_SOURCE] + seeded_models = sorted( + [*load_dummy_data, MEX_EXTRACTED_PRIMARY_SOURCE], key=lambda x: x.identifier + ) connector = GraphConnector.get() result = connector.fetch_extracted_data(None, None, None, 0, len(seeded_models)) @@ -20,6 +22,9 @@ def test_graph_ingest_and_query_roundtrip( list[Annotated[AnyExtractedModel, Field(discriminator="entityType")]] ) - assert extracted_model_adapter.validate_python(result["items"]) == sorted( - seeded_models, key=lambda x: x.identifier + expected = extracted_model_adapter.validate_python( + [e.model_dump() for e in seeded_models] ) + fetched = extracted_model_adapter.validate_python(result["items"]) + + assert fetched == expected diff --git a/tests/test_security.py b/tests/test_security.py index f0752fa9..15cd7e80 100644 --- a/tests/test_security.py +++ b/tests/test_security.py @@ -2,10 +2,7 @@ from fastapi import HTTPException from fastapi.security import HTTPBasicCredentials -from mex.backend.security import ( - has_read_access, - has_write_access, -) +from mex.backend.security import has_read_access, has_write_access read_credentials = HTTPBasicCredentials( **{"username": "Reader", "password": "read_password"}