Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use qualibrate config package #31

Merged
merged 1 commit into from
Jan 13, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
940 changes: 517 additions & 423 deletions poetry.lock

Large diffs are not rendered by default.

4 changes: 3 additions & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -15,14 +15,16 @@ tomli = { version = "^2.0.1", python = "<3.11" }
tomli-w = "^1.0.0"
jsonpatch = "^1.33"
qualibrate-core = "^0.2.0"
qualibrate-config = "^0.1.0"

[tool.poetry.group.dev.dependencies]
mypy = "^1.10.0"
ruff = "^0.7.0"
poethepoet = "^0.26.1"

#[tool.poetry.group.qm-dev.dependencies]
#qualibrate-core = {path = "../qualibrate-core", optional = true}
#qualibrate-config = {path = "../qualibrate-config", develop = true}
#qualibrate-core = {path = "../qualibrate-core", develop = true}

[tool.poetry.scripts]
qualibrate-runner = "qualibrate_runner.__main__:main"
Expand Down
3 changes: 2 additions & 1 deletion qualibrate_runner/__main__.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import click
from qualibrate_config.cli.config import config_command

from qualibrate_runner.cli import config_command, start_command
from qualibrate_runner.cli import start_command


@click.group()
Expand Down
15 changes: 5 additions & 10 deletions qualibrate_runner/api/dependencies.py
Original file line number Diff line number Diff line change
@@ -1,14 +1,11 @@
from collections.abc import Mapping
from functools import cache
from typing import Annotated
from typing import Annotated, cast

from fastapi import Depends, HTTPException
from qualibrate_config.models import CalibrationLibraryConfig

from qualibrate_runner.config import (
QualibrateRunnerSettings,
State,
get_settings,
)
from qualibrate_runner.config import State, get_settings
from qualibrate_runner.core.types import QGraphType, QLibraryType, QNodeType


Expand All @@ -19,11 +16,9 @@ def get_state() -> State:

@cache
def get_cached_library(
settings: Annotated[QualibrateRunnerSettings, Depends(get_settings)],
config: Annotated[CalibrationLibraryConfig, Depends(get_settings)],
) -> QLibraryType:
return settings.calibration_library_resolver(
settings.calibration_library_folder
)
return cast(QLibraryType, config.resolver(config.folder))


def get_library(
Expand Down
3 changes: 1 addition & 2 deletions qualibrate_runner/cli/__init__.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
from .config import config_command
from .start import start_command

__all__ = ["start_command", "config_command"]
__all__ = ["start_command"]
162 changes: 0 additions & 162 deletions qualibrate_runner/cli/config.py

This file was deleted.

7 changes: 2 additions & 5 deletions qualibrate_runner/cli/start.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,9 @@
from pathlib import Path

import click
from qualibrate_config.vars import DEFAULT_CONFIG_FILENAME, QUALIBRATE_PATH

from qualibrate_runner.config import (
CONFIG_PATH_ENV_NAME,
DEFAULT_CONFIG_FILENAME,
QUALIBRATE_PATH,
)
from qualibrate_runner.config import CONFIG_PATH_ENV_NAME


@click.command(name="start")
Expand Down
14 changes: 3 additions & 11 deletions qualibrate_runner/config/__init__.py
Original file line number Diff line number Diff line change
@@ -1,24 +1,16 @@
from .file import get_config_file, read_config_file
from .models import QualibrateRunnerSettings, State
from .models import State
from .resolvers import get_config_path, get_settings
from .vars import (
CONFIG_KEY,
CONFIG_PATH_ENV_NAME,
DEFAULT_CONFIG_FILENAME,
DEFAULT_QUALIBRATE_CONFIG_FILENAME,
QUALIBRATE_PATH,
DEFAULT_QUALIBRATE_RUNNER_CONFIG_FILENAME,
)

__all__ = [
"CONFIG_KEY",
"DEFAULT_CONFIG_FILENAME",
"DEFAULT_QUALIBRATE_CONFIG_FILENAME",
"QUALIBRATE_PATH",
"DEFAULT_QUALIBRATE_RUNNER_CONFIG_FILENAME",
"CONFIG_PATH_ENV_NAME",
"State",
"QualibrateRunnerSettings",
"get_config_file",
"read_config_file",
"get_config_path",
"get_settings",
]
58 changes: 0 additions & 58 deletions qualibrate_runner/config/file.py

This file was deleted.

15 changes: 3 additions & 12 deletions qualibrate_runner/config/models.py
Original file line number Diff line number Diff line change
@@ -1,11 +1,9 @@
from pathlib import Path
from typing import Callable, Optional, Union
from typing import Optional, Union

from pydantic import BaseModel, ConfigDict, DirectoryPath, ImportString
from pydantic_settings import BaseSettings, SettingsConfigDict
from pydantic import BaseModel, ConfigDict

from qualibrate_runner.core.models.last_run import LastRun, RunStatus
from qualibrate_runner.core.types import QGraphType, QLibraryType, QNodeType
from qualibrate_runner.core.types import QGraphType, QNodeType


class State(BaseModel):
Expand All @@ -20,10 +18,3 @@ def is_running(self) -> bool:
self.last_run is not None
and self.last_run.status == RunStatus.RUNNING
)


class QualibrateRunnerSettings(BaseSettings):
model_config = SettingsConfigDict(frozen=True)

calibration_library_resolver: ImportString[Callable[[Path], QLibraryType]]
calibration_library_folder: DirectoryPath
Empty file.
19 changes: 0 additions & 19 deletions qualibrate_runner/config/references/models.py

This file was deleted.

Loading
Loading