-
Notifications
You must be signed in to change notification settings - Fork 1
Refactor / small improvements #122
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
Merged
Merged
Changes from all commits
Commits
Show all changes
11 commits
Select commit
Hold shift + click to select a range
8467a1c
ci: migrate to post node 20 actions
g-braeunlich 23601c4
ci: run non containerized tests
g-braeunlich b5934c3
fix(experiment_data_repository): add guard for default None value
g-braeunlich f1f32aa
refactor: rename HardwareController -> ZedboardController
g-braeunlich 1996ac1
refactor(experiment_data_repository): change ResultDict and Experimen…
g-braeunlich 9ecb6f3
refactor(config): import unchanged config structure from latest into …
g-braeunlich 237015b
refactor(config-reload): move reloading logic of reloadable experimen…
g-braeunlich 4dee86d
refactor(config): move config saving from config controller to config…
g-braeunlich a9365a9
feat(configuration_controller): support list indexing of nested struc…
g-braeunlich 72eddaa
feat: suppress stacktrace if ctrl-c is pressed
g-braeunlich fdaa829
refactor(typing): dict -> dict[str, Any]
g-braeunlich File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,28 @@ | ||
| --- | ||
| name: Python tests | ||
|
|
||
| on: | ||
| push: | ||
| branches: [main] | ||
| pull_request: | ||
| branches: [main] | ||
|
|
||
| jobs: | ||
| linux-test: | ||
| runs-on: ubuntu-latest | ||
| timeout-minutes: 30 | ||
| strategy: | ||
| matrix: | ||
| python-version: ["3.10", "3.11", "3.12", "3.13"] | ||
| steps: | ||
| - uses: actions/checkout@v6 | ||
| - name: Set up Python ${{ matrix.python-version }} | ||
| uses: actions/setup-python@v6 | ||
| with: | ||
| python-version: ${{ matrix.python-version }} | ||
| - name: Install dependencies | ||
| run: | | ||
| pipx install uv | ||
| uv sync --extra server --extra client | ||
| - name: Full Python tests | ||
| run: uv run pytest -v -m "not container" |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,73 @@ | ||
| from pathlib import Path | ||
| from typing import Any | ||
|
|
||
| from confz import BaseConfig | ||
| from pydantic import BaseModel | ||
|
|
||
| __version__ = 2 | ||
|
|
||
|
|
||
| class HealthCheckConfig(BaseModel): | ||
| interval_seconds: float = 10.0 | ||
|
|
||
|
|
||
| class DataConfiguration(BaseModel): | ||
| results_dir: str = str(Path.cwd() / "output") | ||
|
|
||
|
|
||
| class ExperimentLibraryConfig(BaseModel): | ||
| module: str = "icon.server.data_access.pycrystal_experiment_library_client" | ||
| client_class: str = "AsyncPyCrystalClient" | ||
| client_args: dict[str, Any] = {} | ||
| update_interval: int = 30 | ||
|
|
||
|
|
||
| class InfluxDBv1Config(BaseModel): | ||
| host: str = "localhost" | ||
| port: int = 8087 | ||
| username: str = "admin" | ||
| password: str = "admin" # noqa: S105 | ||
| database: str = "testing" | ||
| measurement: str = "Experiment Parameters" | ||
| ssl: bool = False | ||
| verify_ssl: bool = False | ||
| headers: dict[str, str] = {} | ||
|
|
||
|
|
||
| class SQLiteConfig(BaseModel): | ||
| file: str = str(Path.cwd() / "icon.db") | ||
|
|
||
|
|
||
| class DatabaseConfig(BaseModel): | ||
| influxdbv1: InfluxDBv1Config = InfluxDBv1Config() | ||
| sqlite: SQLiteConfig = SQLiteConfig() | ||
|
|
||
|
|
||
| class DateConfig(BaseModel): | ||
| timezone: str = "Europe/Zurich" | ||
|
|
||
|
|
||
| class PreProcessingConfig(BaseModel): | ||
| workers: int = 2 | ||
|
|
||
|
|
||
| class ServerConfig(BaseModel): | ||
| port: int = 8004 | ||
| host: str = "0.0.0.0" | ||
| pre_processing: PreProcessingConfig = PreProcessingConfig() | ||
|
|
||
|
|
||
| class HardwareConfig(BaseModel): | ||
| host: str = "localhost" | ||
| port: int = 6007 | ||
|
|
||
|
|
||
| class ServiceConfig(BaseConfig): # type: ignore[misc] | ||
| version: int = __version__ | ||
| experiment_library: ExperimentLibraryConfig = ExperimentLibraryConfig() | ||
| databases: DatabaseConfig = DatabaseConfig() | ||
| date: DateConfig = DateConfig() | ||
| server: ServerConfig = ServerConfig() | ||
| hardware: HardwareConfig = HardwareConfig() | ||
| health_check: HealthCheckConfig = HealthCheckConfig() | ||
| data: DataConfiguration = DataConfiguration() |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,44 @@ | ||
| import logging | ||
| from collections.abc import Callable | ||
| from typing import TYPE_CHECKING, Any | ||
|
|
||
| from icon.config.config import get_config | ||
|
|
||
| if TYPE_CHECKING: | ||
| from icon.config.latest import ServiceConfig | ||
|
|
||
| logger = logging.getLogger(__name__) | ||
|
|
||
|
|
||
| class ReloadError(Exception): | ||
| pass | ||
|
|
||
|
|
||
| class Reloader: | ||
| def __init__( | ||
| self, | ||
| obj_factory: Callable[..., Any], | ||
| fallback_obj: Any, | ||
| subconfig: "Callable[[ServiceConfig], dict[str, Any]]", | ||
| ) -> None: | ||
| self.current_config: dict[str, Any] = {} | ||
| self.obj_factory = staticmethod(obj_factory) | ||
| self.obj = fallback_obj | ||
| self.fallback_obj = fallback_obj | ||
| self.subconfig = staticmethod(subconfig) | ||
|
|
||
| def reload(self) -> Any: | ||
| new_config = self.subconfig(get_config()) | ||
| if new_config == self.current_config: | ||
| return self.obj | ||
| try: | ||
| self.obj = self.obj_factory(**new_config) | ||
| except ReloadError as e: | ||
| logger.warning(format(e)) | ||
| self.obj = self.fallback_obj | ||
|
|
||
| self.current_config = new_config | ||
| return self.obj | ||
|
|
||
| def is_configured(self) -> bool: | ||
| return self.obj is not self.fallback_obj |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.