Skip to content

Commit

Permalink
refactor: workaround for existing configs to work in new version
Browse files Browse the repository at this point in the history
  • Loading branch information
makkus committed Mar 13, 2024
1 parent 28793a1 commit 797957f
Show file tree
Hide file tree
Showing 2 changed files with 38 additions and 5 deletions.
25 changes: 22 additions & 3 deletions src/kiara/context/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,15 @@
import atexit
import os
import uuid
from pathlib import Path
from typing import TYPE_CHECKING, Any, Dict, Iterable, List, Mapping, Set, Type, Union

import structlog

# from alembic import command # type: ignore
from pydantic import Field

from kiara.context.config import KiaraConfig, KiaraContextConfig
from kiara.context.config import KiaraArchiveConfig, KiaraConfig, KiaraContextConfig
from kiara.context.runtime_config import KiaraRuntimeConfig
from kiara.data_types import DataType
from kiara.exceptions import KiaraContextException
Expand All @@ -30,7 +31,7 @@
from kiara.models.module.manifest import Manifest
from kiara.models.runtime_environment import RuntimeEnvironment
from kiara.models.values.value import ValueMap
from kiara.registries import KiaraArchive
from kiara.registries import KiaraArchive, SqliteArchiveConfig
from kiara.registries.aliases import AliasRegistry
from kiara.registries.data import DataRegistry
from kiara.registries.environment import EnvironmentRegistry
Expand Down Expand Up @@ -162,10 +163,28 @@ def __init__(

for archive_alias, archive in self._config.archives.items():

# this is just to make old context that still had that not error out
# TODO: this is just to make old context that still had that not error out
if "_destiny_" in archive.archive_type:
continue

if (
archive_alias == "default_job_store"
and archive.archive_type == "filesystem_job_store"
):

# this is a temporary solution for contexts that still have the old filesystem job store
# TODO: remove this at some stage

archive_path = Path(archive.config["archive_path"])
file_name = f"{archive_path.name}.kiarchive"

js_config = SqliteArchiveConfig.create_new_store_config(
store_base_path=archive.config["archive_path"], file_name=file_name
)
archive = KiaraArchiveConfig(
archive_type="sqlite_job_store", config=js_config.model_dump()
)

archive_cls = self._archive_types.get(archive.archive_type, None)

if archive_cls is None:
Expand Down
18 changes: 16 additions & 2 deletions src/kiara/registries/jobs/job_store/filesystem_store.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,12 +8,12 @@
import shutil
import uuid
from pathlib import Path
from typing import Any, Dict, Iterable, Mapping, Union
from typing import Any, Dict, Generator, Iterable, Mapping, Union

import orjson
import structlog

from kiara.models.module.jobs import JobRecord
from kiara.models.module.jobs import JobMatcher, JobRecord
from kiara.registries import ArchiveDetails, FileSystemArchiveConfig
from kiara.registries.jobs import MANIFEST_SUB_PATH, JobArchive, JobStore
from kiara.utils.windows import fix_windows_longpath
Expand Down Expand Up @@ -135,6 +135,20 @@ def _retrieve_record_for_job_hash(self, job_hash: str) -> Union[JobRecord, None]
job_record._is_stored = True
return job_record

def _retrieve_all_job_ids(self) -> Mapping[uuid.UUID, datetime.datetime]:

raise NotImplementedError()

def _retrieve_matching_job_records(
self, matcher: JobMatcher
) -> Generator[JobRecord, None, None]:

raise NotImplementedError()

def _retrieve_record_for_job_id(self, job_id: uuid.UUID) -> Union[JobRecord, None]:

raise NotImplementedError()

# def find_matching_job_record(
# self, inputs_manifest: InputsManifest
# ) -> Optional[JobRecord]:
Expand Down

0 comments on commit 797957f

Please sign in to comment.