From 35cebbb59309099ebaa45ca8ef075032dcfb4a26 Mon Sep 17 00:00:00 2001 From: Markus Binsteiner Date: Tue, 5 Mar 2024 12:36:09 +0100 Subject: [PATCH] fix: archive creation order --- .../interfaces/python_api/models/archive.py | 18 +++++++++--------- .../metadata/metadata_store/sqlite_store.py | 11 +++++++++++ 2 files changed, 20 insertions(+), 9 deletions(-) diff --git a/src/kiara/interfaces/python_api/models/archive.py b/src/kiara/interfaces/python_api/models/archive.py index d7cc32fe9..5f964a1de 100644 --- a/src/kiara/interfaces/python_api/models/archive.py +++ b/src/kiara/interfaces/python_api/models/archive.py @@ -138,15 +138,6 @@ def create_kiarchive( if isinstance(compression, str): compression = CHUNK_COMPRESSION_TYPE[compression.upper()] - metadata_store: MetadataStore = create_new_archive( # type: ignore - archive_name=archive_name, - store_base_path=archive_base_path, - store_type="sqlite_metadata_store", - file_name=archive_file_name, - allow_write_access=True, - ) - metadata_store_config = metadata_store.config - data_store: DataStore = create_new_archive( # type: ignore archive_name=archive_name, store_base_path=archive_base_path, @@ -157,6 +148,15 @@ def create_kiarchive( ) data_store_config = data_store.config + metadata_store: MetadataStore = create_new_archive( # type: ignore + archive_name=archive_name, + store_base_path=archive_base_path, + store_type="sqlite_metadata_store", + file_name=archive_file_name, + allow_write_access=True, + ) + metadata_store_config = metadata_store.config + alias_store: AliasStore = create_new_archive( # type: ignore archive_name=archive_name, store_base_path=archive_base_path, diff --git a/src/kiara/registries/metadata/metadata_store/sqlite_store.py b/src/kiara/registries/metadata/metadata_store/sqlite_store.py index 3cbafeebe..1d46e9582 100644 --- a/src/kiara/registries/metadata/metadata_store/sqlite_store.py +++ b/src/kiara/registries/metadata/metadata_store/sqlite_store.py @@ -165,6 +165,17 @@ def _load_archive_config( # config = SqliteArchiveConfig(sqlite_db_path=store_uri) return {"sqlite_db_path": archive_uri} + def _set_archive_metadata_value(self, key: str, value: Any): + """Set custom metadata for the archive.""" + + sql = text( + "INSERT OR REPLACE INTO archive_metadata (key, value) VALUES (:key, :value)" + ) + with self.sqlite_engine.connect() as conn: + params = {"key": key, "value": value} + conn.execute(sql, params) + conn.commit() + def _store_metadata_schema( self, model_schema_hash: str, model_type_id: str, model_schema: str ):