Skip to content

Commit

Permalink
feat: initial version that requires comments for run_job
Browse files Browse the repository at this point in the history
  • Loading branch information
makkus committed Mar 13, 2024
1 parent 0a1d2ee commit 99b2f85
Show file tree
Hide file tree
Showing 23 changed files with 667 additions and 131 deletions.
26 changes: 16 additions & 10 deletions src/kiara/context/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -393,6 +393,7 @@ def create_default_store_config(


class KiaraConfig(BaseSettings):

model_config = SettingsConfigDict(
env_prefix="kiara_", extra="forbid", use_enum_values=True
)
Expand Down Expand Up @@ -890,18 +891,23 @@ def save(self, path: Union[Path, None] = None):

path.parent.mkdir(parents=True, exist_ok=True)

data = self.model_dump(
exclude={
"context",
"auto_generate_contexts",
"stores_base_path",
"context_search_paths",
"default_context",
"runtime_config",
}
)

if data["default_store_type"] == DEFAULT_STORE_TYPE:
data.pop("default_store_type")

with path.open("wt") as f:
yaml.dump(
self.model_dump(
exclude={
"context",
"auto_generate_contexts",
"stores_base_path",
"context_search_paths",
"default_context",
"runtime_config",
}
),
data,
f,
)

Expand Down
6 changes: 6 additions & 0 deletions src/kiara/context/runtime_config.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
# -*- coding: utf-8 -*-
from enum import Enum
from typing import Literal

from pydantic import Field
from pydantic_settings import BaseSettings, SettingsConfigDict
Expand Down Expand Up @@ -32,6 +33,11 @@ class KiaraRuntimeConfig(BaseSettings):
lock_context: bool = Field(
description="Whether to lock context(s) on creation.", default=False
)
runtime_profile: Literal["default", "dharpa"] = Field(
description="The runtime profile to use, this determines for example whether comments need to be provided when running a job.",
default="dharpa",
)

# ignore_errors: bool = Field(
# description="If set, kiara will try to ignore most errors (that can be ignored).",
# default=False,
Expand Down
2 changes: 2 additions & 0 deletions src/kiara/interfaces/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -334,6 +334,8 @@ def kiara_config(self) -> "KiaraConfig":
else:
kiara_config = KiaraConfig.load_from_file(config_file_path)

kiara_config.runtime_config.runtime_profile = "default"

self._kiara_config = kiara_config
return self._kiara_config

Expand Down
18 changes: 7 additions & 11 deletions src/kiara/interfaces/cli/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,6 @@
import rich_click as click
import structlog

from kiara.defaults import (
SYMLINK_ISSUE_MSG,
)
from kiara.interfaces import KiaraAPIWrap
from kiara.utils import is_debug, log_message
from kiara.utils.class_loading import find_all_cli_subcommands
Expand Down Expand Up @@ -95,15 +92,14 @@ def cli(
For more information, visit the [i][b]kiara[/b] homepage[/i]: https://dharpa.org/kiara.documentation .
"""
# check if windows symlink work
from kiara.utils.windows import check_symlink_works

if not check_symlink_works():

terminal_print()
from rich.markdown import Markdown

terminal_print(Markdown(SYMLINK_ISSUE_MSG))
sys.exit(1)
# if not check_symlink_works():
#
# terminal_print()
# from rich.markdown import Markdown
#
# terminal_print(Markdown(SYMLINK_ISSUE_MSG))
# sys.exit(1)

context_subcommand = ctx.invoked_subcommand == "context"
if context_subcommand and use_background_service:
Expand Down
5 changes: 5 additions & 0 deletions src/kiara/interfaces/cli/run.py
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,9 @@
@click.option(
"--output", "-o", help="The output format and configuration.", multiple=True
)
@click.option(
"--comment", "-c", help="Add comment metadata to the job you run.", required=False
)
@click.option(
"--save",
"-s",
Expand All @@ -67,6 +70,7 @@ def run(
module_config: Iterable[str],
inputs: Iterable[str],
output: Iterable[str],
comment: Union[str, None],
explain: bool,
save: Iterable[str],
print_properties: bool,
Expand Down Expand Up @@ -249,6 +253,7 @@ def run(
api=api,
operation=kiara_op,
inputs=inputs_value_map,
comment=comment,
silent=silent,
save_results=bool(final_aliases),
aliases=final_aliases,
Expand Down
Loading

0 comments on commit 99b2f85

Please sign in to comment.