From b7e61ec012d511a7febf84cf1516d99cd7dfdf2e Mon Sep 17 00:00:00 2001 From: Alexis S <132259399+picsalex@users.noreply.github.com> Date: Tue, 2 Apr 2024 18:36:05 +0200 Subject: [PATCH] feat: engine CI runs tests and coverage (#121) --- .github/workflows/engine_tests.yaml | 10 ++++++---- requirements-dev.txt | 7 +++++++ src/decorators/pipeline_decorator.py | 2 +- src/logger.py | 6 +++--- 4 files changed, 17 insertions(+), 8 deletions(-) create mode 100644 requirements-dev.txt diff --git a/.github/workflows/engine_tests.yaml b/.github/workflows/engine_tests.yaml index b26a8f0e..6fb8c50d 100644 --- a/.github/workflows/engine_tests.yaml +++ b/.github/workflows/engine_tests.yaml @@ -22,7 +22,7 @@ jobs: runs-on: ubuntu-latest strategy: matrix: - python-version: [3.8, 3.9, 3.10, 3.11] + python-version: ["3.8", "3.9", "3.10", "3.11"] steps: - uses: actions/checkout@v3 @@ -39,14 +39,16 @@ jobs: - name: Lint with flake8 run: | - flake8 . --count --select=E9,F63,F7,F82 --show-source --statistics --exclude=tests/ + flake8 . --count --select=E9,F63,F7,F82 --show-source --statistics --exclude=tests/ --max-line-length=88 - name: Test with pytest run: | pytest tests/decorators tests/logger --cov=src/decorators src/logger.py --cov-report=xml - - name: Codecov - uses: codecov/codecov-action@v4.1.1 + - name: Upload coverage reports to Codecov + uses: codecov/codecov-action@v4.0.1 with: file: ./coverage.xml fail_ci_if_error: true + token: ${{ secrets.CODECOV_TOKEN }} + slug: picselliahq/picsellia-training-engine diff --git a/requirements-dev.txt b/requirements-dev.txt new file mode 100644 index 00000000..41786168 --- /dev/null +++ b/requirements-dev.txt @@ -0,0 +1,7 @@ +black +mypy +pre-commit +pytest +pytest-cov +ruff +tabulate diff --git a/src/decorators/pipeline_decorator.py b/src/decorators/pipeline_decorator.py index 8deebc85..cc3a7755 100644 --- a/src/decorators/pipeline_decorator.py +++ b/src/decorators/pipeline_decorator.py @@ -13,7 +13,7 @@ class Pipeline: ACTIVE_PIPELINE: Optional["Pipeline"] = None - STEPS_REGISTRY: dict[str, StepMetadata] = {} + STEPS_REGISTRY: Dict[str, StepMetadata] = {} def __init__( self, diff --git a/src/logger.py b/src/logger.py index cf516c54..a7e8ef7e 100644 --- a/src/logger.py +++ b/src/logger.py @@ -5,7 +5,7 @@ import sys import tempfile from datetime import datetime -from typing import Optional, TextIO, cast +from typing import Optional, TextIO, cast, List from src.models.logging.stream_to_logger import StreamToLogger from src.models.steps.step_metadata import StepMetadata @@ -53,7 +53,7 @@ def configure_pipeline_initialization_log_file(self) -> str: return pipeline_initialization_log_file_path - def configure_log_files(self, steps_metadata: list[StepMetadata]) -> None: + def configure_log_files(self, steps_metadata: List[StepMetadata]) -> None: """Configures the folders and log files for the pipeline and its steps. If the `log_folder_path` is not provided when decorating a pipeline, a temporary directory is created instead. @@ -144,7 +144,7 @@ def prepare_logger(self, log_file_path: Optional[str]) -> logging.Logger: return self.logger - def _configure_steps_log_files(self, steps_metadata: list[StepMetadata]) -> None: + def _configure_steps_log_files(self, steps_metadata: List[StepMetadata]) -> None: """Configures the log files for each step. For each step, will look at the metadata to create a log file.