ci: enforce Ruff lint checks
All checks were successful
ENGIN CI / Build, test and smoke (push) Successful in 31s
All checks were successful
ENGIN CI / Build, test and smoke (push) Successful in 31s
This commit is contained in:
parent
f2df616285
commit
8981ae0a00
@ -27,6 +27,18 @@ jobs:
|
|||||||
- name: Build production image
|
- name: Build production image
|
||||||
run: docker build --tag engin-console:ci .
|
run: docker build --tag engin-console:ci .
|
||||||
|
|
||||||
|
- name: Run Ruff
|
||||||
|
run: |
|
||||||
|
docker run --rm \
|
||||||
|
--entrypoint sh \
|
||||||
|
engin-console:ci \
|
||||||
|
-c "python -m pip install --quiet \
|
||||||
|
--disable-pip-version-check \
|
||||||
|
--root-user-action=ignore \
|
||||||
|
ruff==0.16.4 &&
|
||||||
|
ruff check --no-cache \
|
||||||
|
app.py engin tests final_pipeline.py ml_polish_benchmark.py"
|
||||||
|
|
||||||
- name: Check installed dependencies
|
- name: Check installed dependencies
|
||||||
run: |
|
run: |
|
||||||
docker run --rm \
|
docker run --rm \
|
||||||
|
|||||||
5
app.py
5
app.py
@ -13,12 +13,12 @@ import streamlit as st
|
|||||||
|
|
||||||
from engin.charts import cylinder_spectrum, deviation_chart, engine_heatmap
|
from engin.charts import cylinder_spectrum, deviation_chart, engine_heatmap
|
||||||
from engin.config import (
|
from engin.config import (
|
||||||
AppConfig,
|
|
||||||
LABEL_COLORS,
|
LABEL_COLORS,
|
||||||
LABEL_DISPLAY,
|
LABEL_DISPLAY,
|
||||||
LABEL_ICONS,
|
LABEL_ICONS,
|
||||||
NOT_APPLICABLE,
|
NOT_APPLICABLE,
|
||||||
SEVERITY_DISPLAY,
|
SEVERITY_DISPLAY,
|
||||||
|
AppConfig,
|
||||||
)
|
)
|
||||||
from engin.errors import UserFacingError
|
from engin.errors import UserFacingError
|
||||||
from engin.explainability import (
|
from engin.explainability import (
|
||||||
@ -32,7 +32,6 @@ from engin.model import PrecomputedPredictionModel, SklearnPredictionModel
|
|||||||
from engin.service import DiagnosisResult, DiagnosticService
|
from engin.service import DiagnosisResult, DiagnosticService
|
||||||
from engin.validation import SpectrumFrameValidator
|
from engin.validation import SpectrumFrameValidator
|
||||||
|
|
||||||
|
|
||||||
LOGGER = logging.getLogger("engin.app")
|
LOGGER = logging.getLogger("engin.app")
|
||||||
BASE_DIR = Path(__file__).resolve().parent
|
BASE_DIR = Path(__file__).resolve().parent
|
||||||
|
|
||||||
@ -62,7 +61,7 @@ def build_dependencies() -> AppDependencies:
|
|||||||
service=DiagnosticService(reader=reader, validator=validator, model=model),
|
service=DiagnosticService(reader=reader, validator=validator, model=model),
|
||||||
demo_payload=demo_payload,
|
demo_payload=demo_payload,
|
||||||
)
|
)
|
||||||
except Exception as exc:
|
except Exception:
|
||||||
LOGGER.exception("Live model initialization failed; enabling demo fallback")
|
LOGGER.exception("Live model initialization failed; enabling demo fallback")
|
||||||
submission = pd.read_csv(BASE_DIR / "predictions.csv")
|
submission = pd.read_csv(BASE_DIR / "predictions.csv")
|
||||||
diagnostics = pd.read_csv(BASE_DIR / "prediction_diagnostics.csv")
|
diagnostics = pd.read_csv(BASE_DIR / "prediction_diagnostics.csv")
|
||||||
|
|||||||
@ -1,5 +1,5 @@
|
|||||||
"""Core application package for the ENGIN diagnostic console."""
|
"""Core application package for the ENGIN diagnostic console."""
|
||||||
|
|
||||||
from .service import DiagnosticService, DiagnosisResult
|
from .service import DiagnosisResult, DiagnosticService
|
||||||
|
|
||||||
__all__ = ["DiagnosticService", "DiagnosisResult"]
|
__all__ = ["DiagnosticService", "DiagnosisResult"]
|
||||||
|
|||||||
@ -8,7 +8,6 @@ import plotly.graph_objects as go
|
|||||||
from .config import FREQ_COLS, LABEL_COLORS
|
from .config import FREQ_COLS, LABEL_COLORS
|
||||||
from .explainability import EngineAnalysis
|
from .explainability import EngineAnalysis
|
||||||
|
|
||||||
|
|
||||||
PLOT_BG = "#101820"
|
PLOT_BG = "#101820"
|
||||||
GRID = "rgba(148, 163, 184, 0.14)"
|
GRID = "rgba(148, 163, 184, 0.14)"
|
||||||
TEXT = "#dce8ee"
|
TEXT = "#dce8ee"
|
||||||
|
|||||||
@ -4,8 +4,13 @@ from __future__ import annotations
|
|||||||
|
|
||||||
from dataclasses import dataclass
|
from dataclasses import dataclass
|
||||||
|
|
||||||
from benchmark_grouped import FAULT_LABELS, FREQ_COLS, LABELS, NOT_APPLICABLE, SEVERITIES
|
from benchmark_grouped import (
|
||||||
|
FAULT_LABELS,
|
||||||
|
FREQ_COLS,
|
||||||
|
LABELS,
|
||||||
|
NOT_APPLICABLE,
|
||||||
|
SEVERITIES,
|
||||||
|
)
|
||||||
|
|
||||||
ALLOWED_ENGINE_SIZES = (8, 12, 16)
|
ALLOWED_ENGINE_SIZES = (8, 12, 16)
|
||||||
MAX_UPLOAD_BYTES = 10 * 1024 * 1024
|
MAX_UPLOAD_BYTES = 10 * 1024 * 1024
|
||||||
|
|||||||
@ -7,7 +7,12 @@ from typing import Protocol
|
|||||||
|
|
||||||
import pandas as pd
|
import pandas as pd
|
||||||
|
|
||||||
from final_pipeline import DiagnosticModels, predict_test, train_models, validate_submission
|
from final_pipeline import (
|
||||||
|
DiagnosticModels,
|
||||||
|
predict_test,
|
||||||
|
train_models,
|
||||||
|
validate_submission,
|
||||||
|
)
|
||||||
|
|
||||||
from .errors import InferenceError
|
from .errors import InferenceError
|
||||||
|
|
||||||
|
|||||||
@ -8,7 +8,7 @@ from typing import Protocol
|
|||||||
import numpy as np
|
import numpy as np
|
||||||
import pandas as pd
|
import pandas as pd
|
||||||
|
|
||||||
from .config import AppConfig, FREQ_COLS
|
from .config import FREQ_COLS, AppConfig
|
||||||
from .errors import InputDataError
|
from .errors import InputDataError
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@ -28,7 +28,6 @@ from benchmark_grouped import (
|
|||||||
LABELS,
|
LABELS,
|
||||||
NOT_APPLICABLE,
|
NOT_APPLICABLE,
|
||||||
SEVERITIES,
|
SEVERITIES,
|
||||||
make_pipeline,
|
|
||||||
validate_data,
|
validate_data,
|
||||||
)
|
)
|
||||||
from severity_benchmark import (
|
from severity_benchmark import (
|
||||||
@ -39,7 +38,6 @@ from severity_benchmark import (
|
|||||||
prepare_labeled_frame,
|
prepare_labeled_frame,
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
LABEL_MODEL_NAME = "deviation_logistic_c10"
|
LABEL_MODEL_NAME = "deviation_logistic_c10"
|
||||||
LABEL_FEATURE_SET = "deviation"
|
LABEL_FEATURE_SET = "deviation"
|
||||||
SEVERITY_CANDIDATE_ID = "deviation_extra_trees_mf03"
|
SEVERITY_CANDIDATE_ID = "deviation_extra_trees_mf03"
|
||||||
|
|||||||
@ -19,8 +19,8 @@ from benchmark_grouped import (
|
|||||||
FAULT_LABELS,
|
FAULT_LABELS,
|
||||||
LABELS,
|
LABELS,
|
||||||
NOT_APPLICABLE,
|
NOT_APPLICABLE,
|
||||||
make_splits,
|
|
||||||
macro_f1,
|
macro_f1,
|
||||||
|
make_splits,
|
||||||
ml_points,
|
ml_points,
|
||||||
raw_score,
|
raw_score,
|
||||||
validate_data,
|
validate_data,
|
||||||
@ -38,7 +38,6 @@ from severity_benchmark import (
|
|||||||
prepare_labeled_frame,
|
prepare_labeled_frame,
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
DEFAULT_SEEDS = [7, 21, 42, 77, 123]
|
DEFAULT_SEEDS = [7, 21, 42, 77, 123]
|
||||||
|
|
||||||
|
|
||||||
@ -166,7 +165,7 @@ def main() -> None:
|
|||||||
"ood_overrides": ood_count[scenario],
|
"ood_overrides": ood_count[scenario],
|
||||||
}
|
}
|
||||||
row.update(
|
row.update(
|
||||||
{f"f1_{label}": float(value) for label, value in zip(LABELS, per_class)}
|
{f"f1_{label}": float(value) for label, value in zip(LABELS, per_class, strict=True)}
|
||||||
)
|
)
|
||||||
run_rows.append(row)
|
run_rows.append(row)
|
||||||
|
|
||||||
|
|||||||
5
ruff.toml
Normal file
5
ruff.toml
Normal file
@ -0,0 +1,5 @@
|
|||||||
|
target-version = "py312"
|
||||||
|
extend-exclude = ["archive/legacy_experiments"]
|
||||||
|
|
||||||
|
[lint]
|
||||||
|
select = ["E4", "E7", "E9", "F", "I", "B"]
|
||||||
@ -5,7 +5,6 @@ from pathlib import Path
|
|||||||
|
|
||||||
from streamlit.testing.v1 import AppTest
|
from streamlit.testing.v1 import AppTest
|
||||||
|
|
||||||
|
|
||||||
ROOT = Path(__file__).resolve().parents[1]
|
ROOT = Path(__file__).resolve().parents[1]
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@ -14,7 +14,6 @@ from engin.explainability import (
|
|||||||
)
|
)
|
||||||
from engin.service import DiagnosisResult
|
from engin.service import DiagnosisResult
|
||||||
|
|
||||||
|
|
||||||
ROOT = Path(__file__).resolve().parents[1]
|
ROOT = Path(__file__).resolve().parents[1]
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@ -4,7 +4,7 @@ import unittest
|
|||||||
|
|
||||||
import pandas as pd
|
import pandas as pd
|
||||||
|
|
||||||
from engin.model import PredictionBundle, PrecomputedPredictionModel
|
from engin.model import PrecomputedPredictionModel, PredictionBundle
|
||||||
from engin.service import DiagnosticService
|
from engin.service import DiagnosticService
|
||||||
from engin.validation import ValidationResult
|
from engin.validation import ValidationResult
|
||||||
|
|
||||||
|
|||||||
@ -10,7 +10,6 @@ from engin.config import FREQ_COLS
|
|||||||
from engin.errors import InputDataError
|
from engin.errors import InputDataError
|
||||||
from engin.validation import SpectrumFrameValidator
|
from engin.validation import SpectrumFrameValidator
|
||||||
|
|
||||||
|
|
||||||
ROOT = Path(__file__).resolve().parents[1]
|
ROOT = Path(__file__).resolve().parents[1]
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user