From abc2bb18b99398cedc59f6328ef47d7798ee4b6e Mon Sep 17 00:00:00 2001 From: Marco Cucchi Date: Mon, 16 Oct 2023 18:23:08 +0200 Subject: [PATCH 1/4] refactor get_qos_status_from_request --- cads_broker/database.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/cads_broker/database.py b/cads_broker/database.py index 82025262..f5b9bd32 100644 --- a/cads_broker/database.py +++ b/cads_broker/database.py @@ -307,9 +307,9 @@ def count_users(status: str, entry_point: str, session: sa.orm.Session) -> int: ) -def get_qos_status_from_request(request: dict[str, Any]) -> dict[str, list[str]]: +def get_qos_status_from_request(request: SystemRequest) -> dict[str, list[str]]: ret_value: dict[str, list[str]] = {} - for rule_name, rules in request["qos_status"].items(): + for rule_name, rules in request.qos_status.items(): ret_value[rule_name] = [] for rule in rules.values(): ret_value[rule_name].append(rule.get("info", "")) From 16d2504d2e7cd6cffbd2eeb0bc60df57ae74134c Mon Sep 17 00:00:00 2001 From: Marco Cucchi Date: Tue, 17 Oct 2023 16:04:42 +0200 Subject: [PATCH 2/4] merge main --- tests/test_02_database.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/tests/test_02_database.py b/tests/test_02_database.py index 815cf6a4..611915bf 100644 --- a/tests/test_02_database.py +++ b/tests/test_02_database.py @@ -521,7 +521,7 @@ def test_set_request_qos_rule(session_obj: sa.orm.sessionmaker) -> None: def test_get_qos_status_from_request() -> None: - test_request = { + test_qos_status = { "qos_status": { "rule_name_1": { "rule_key_1_1": { @@ -538,6 +538,7 @@ def test_get_qos_status_from_request() -> None: "rule_name_2": {"rule_key_2_1": {}}, } } + test_request = db.SystemRequest(**test_qos_status) exp_qos_status = { "rule_name_1": [("info_1_1", "conclusion_1_1"), ("info_1_2", "conclusion_1_2")], "rule_name_2": [("", "")], From a91574338b818b3ed62899ea952c65489c0d4c8a Mon Sep 17 00:00:00 2001 From: Marco Cucchi Date: Wed, 18 Oct 2023 10:00:00 +0200 Subject: [PATCH 3/4] solve deprecation warning --- cads_broker/config.py | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/cads_broker/config.py b/cads_broker/config.py index 6aa6fc4e..a3e5033f 100644 --- a/cads_broker/config.py +++ b/cads_broker/config.py @@ -51,14 +51,13 @@ class SqlalchemySettings(pydantic_settings.BaseSettings): def password_must_be_set( cls: pydantic_settings.BaseSettings, v: str | None, - info: pydantic_core.core_schema.FieldValidationInfo, + info: pydantic_core.core_schema.ValidationInfo, ) -> str | None: """Check that password is explicitly set.""" if v is None: raise ValueError(f"{info.field_name} must be set") return v - @property def connection_string(self) -> str: """Create reader psql connection string.""" From 9f7f9d247198ce15ec065187da88aa6e23905fcd Mon Sep 17 00:00:00 2001 From: Marco Cucchi Date: Fri, 20 Oct 2023 14:04:26 +0200 Subject: [PATCH 4/4] lazy loading of adaptor_properties --- cads_broker/database.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cads_broker/database.py b/cads_broker/database.py index 916a7d4b..269863ce 100644 --- a/cads_broker/database.py +++ b/cads_broker/database.py @@ -83,7 +83,7 @@ class SystemRequest(BaseModel): # joined is temporary cache_entry = sa.orm.relationship(cacholote.database.CacheEntry, lazy="joined") - adaptor_properties = sa.orm.relationship(AdaptorProperties, lazy="joined") + adaptor_properties = sa.orm.relationship(AdaptorProperties, lazy="select") @property def age(self):