Skip to content

Commit

Permalink
feat: add 'import_archive' API endpoint
Browse files Browse the repository at this point in the history
  • Loading branch information
makkus committed Feb 19, 2024
1 parent 8dba5ed commit 11f505d
Show file tree
Hide file tree
Showing 19 changed files with 238 additions and 130 deletions.
2 changes: 1 addition & 1 deletion src/kiara/context/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -336,7 +336,7 @@ def register_external_archive(
for archive_type, _archive_inst in archive_instances.items():
log_message(
"register.external.archive",
archive=_archive_inst.archive_alias,
archive=_archive_inst.archive_name,
allow_write_access=allow_write_access,
)

Expand Down
3 changes: 3 additions & 0 deletions src/kiara/defaults.py
Original file line number Diff line number Diff line change
Expand Up @@ -295,3 +295,6 @@ class CHUNK_COMPRESSION_TYPE(Enum):


DEFAULT_CHUNK_COMPRESSION = CHUNK_COMPRESSION_TYPE.ZSTD

ARCHIVE_NAME_MARKER = "archive_name"
DATA_ARCHIVE_DEFAULT_VALUE_MARKER = "default_value"
22 changes: 16 additions & 6 deletions src/kiara/interfaces/cli/archive/commands.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
# Copyright (c) 2021, Markus Binsteiner
#
# Mozilla Public License, version 2.0 (see LICENSE or https://www.mozilla.org/en-US/MPL/2.0/)

import rich_click as click

from kiara.utils.cli import (
Expand Down Expand Up @@ -35,19 +34,30 @@ def explain_archive(

kiara_api: KiaraAPI = ctx.obj.kiara_api

info = kiara_api.retrieve_kiarchive_info(archive)
info = kiara_api.retrieve_archive_info(archive)

terminal_print_model(info, format=format, in_panel=f"Archive info: {archive}")


@archive.command("import")
@click.argument("archive", nargs=1, required=True)
# @click.option(
# "--all-values",
# "-a",
# is_flag=True,
# default=False,
# help="Import all values from the archive, even if they don't have an alias associated with them.",
# )
@click.pass_context
@handle_exception()
def import_archive(ctx, archive: str):
def import_archive(ctx, archive: str, all_values: bool = False):
"""Import an archive file."""

# kiara_api: KiaraAPI = ctx.obj.kiara_api
from kiara.interfaces.python_api import KiaraAPI

kiara_api: KiaraAPI = ctx.obj.kiara_api

result = kiara_api.import_archive(archive)

raise NotImplementedError()
# kiara_api.import_archive(archive)
render_config = {"add_field_column": False}
terminal_print_model(result, **render_config)
3 changes: 2 additions & 1 deletion src/kiara/interfaces/cli/data/commands.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
import rich_click as click
import structlog

from kiara.defaults import DATA_ARCHIVE_DEFAULT_VALUE_MARKER
from kiara.exceptions import InvalidCommandLineInvocation
from kiara.utils import log_exception, log_message
from kiara.utils.cli import output_format_option, terminal_print, terminal_print_model
Expand Down Expand Up @@ -647,7 +648,7 @@ def export_data_archive(
if not no_default_value:
try:
data_store.set_archive_metadata_value(
"default_value", str(values[0][0].value_id)
DATA_ARCHIVE_DEFAULT_VALUE_MARKER, str(values[0][0].value_id)
)
except Exception as e:
data_store.delete_archive(archive_id=data_store.archive_id)
Expand Down
Loading

0 comments on commit 11f505d

Please sign in to comment.