From 17261e7547bb56a66b59b27258804c1b3e099ec8 Mon Sep 17 00:00:00 2001 From: Markus Binsteiner Date: Wed, 17 Apr 2024 16:40:02 +0200 Subject: [PATCH] fix: register list & dict value data --- src/kiara/data_types/included_core_types/__init__.py | 9 ++++++++- src/kiara/registries/data/__init__.py | 1 + src/kiara/registries/data/data_store/sqlite_store.py | 7 +++++-- src/kiara/registries/jobs/__init__.py | 6 +++++- 4 files changed, 19 insertions(+), 4 deletions(-) diff --git a/src/kiara/data_types/included_core_types/__init__.py b/src/kiara/data_types/included_core_types/__init__.py index 9dae7539c..23d89d4a6 100644 --- a/src/kiara/data_types/included_core_types/__init__.py +++ b/src/kiara/data_types/included_core_types/__init__.py @@ -403,7 +403,14 @@ def parse_python_obj(self, data: Any) -> KiaraDict: dict_data = orjson.loads(data) schema = {"title": "dict", "type": "object"} except Exception: - pass + try: + from kiara.utils.cli import dict_from_cli_args + + tokens = data.split(",") + dict_data = dict_from_cli_args(*tokens) + schema = {"title": "dict", "type": "object"} + except Exception: + pass if dict_data is None or schema is None: raise Exception(f"Invalid data for value type 'dict': {data}") diff --git a/src/kiara/registries/data/__init__.py b/src/kiara/registries/data/__init__.py index 1318a97cd..236aeb62a 100644 --- a/src/kiara/registries/data/__init__.py +++ b/src/kiara/registries/data/__init__.py @@ -1014,6 +1014,7 @@ def _create_value( data_type: Union[None, DataType] = None if reuse_existing and not isinstance(data, (Value, uuid.UUID, SpecialValue)): + data_type = self._kiara.type_registry.retrieve_data_type( data_type_name=schema.type, data_type_config=schema.type_config ) diff --git a/src/kiara/registries/data/data_store/sqlite_store.py b/src/kiara/registries/data/data_store/sqlite_store.py index 6c7188ec9..7932c8a31 100644 --- a/src/kiara/registries/data/data_store/sqlite_store.py +++ b/src/kiara/registries/data/data_store/sqlite_store.py @@ -309,10 +309,13 @@ def _find_values_with_hash( raise NotImplementedError() sql = text( - f"SELECT value_id FROM {TABLE_NAME_DATA_METADATA} WHERE value_hash = ?" + f"SELECT value_id FROM {TABLE_NAME_DATA_METADATA} WHERE value_hash = :value_hash" ) + params = { + "value_hash": value_hash, + } with self.sqlite_engine.connect() as conn: - cursor = conn.execute(sql, (value_hash,)) + cursor = conn.execute(sql, parameters=params) result = cursor.fetchall() return {uuid.UUID(x[0]) for x in result} diff --git a/src/kiara/registries/jobs/__init__.py b/src/kiara/registries/jobs/__init__.py index b36b3b83d..24c292a86 100644 --- a/src/kiara/registries/jobs/__init__.py +++ b/src/kiara/registries/jobs/__init__.py @@ -387,7 +387,11 @@ def get_job_record(self, job_id: uuid.UUID) -> JobRecord: if r.job_id == job_id: return r - raise NotImplementedError() + # raise a FailedJobException if the job is in the failed jobs list + self.get_active_job(job_id=job_id) + + # this should never happen + raise KiaraException("Can't find job record with id: {job_id}") def find_job_records(self, matcher: JobMatcher) -> Mapping[uuid.UUID, JobRecord]: