diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 0b1099825f4e1b0ee1ad9cd946b7846b79fd94c9..78f7e19351e8b23ebeba3e7249e4e9af5bb5a277 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -1,14 +1,13 @@ repos: - repo: https://github.com/astral-sh/ruff-pre-commit # Ruff version. - rev: v0.0.282 + rev: v0.1.6 hooks: + # Run the linter. - id: ruff args: [--fix, --exit-non-zero-on-fix] - - repo: https://github.com/ambv/black - rev: 23.7.0 - hooks: - - id: black + # Run the formatter. + - id: ruff-format - repo: https://github.com/pre-commit/pre-commit-hooks rev: v4.4.0 hooks: diff --git a/dan/ocr/manager/metrics.py b/dan/ocr/manager/metrics.py index e9a3174e3c4147ed50fbb7ee4a1f277b4609b45a..102fddafbaa334845dc9251c630df18a6ae353dc 100644 --- a/dan/ocr/manager/metrics.py +++ b/dan/ocr/manager/metrics.py @@ -106,7 +106,14 @@ class MetricManager: display_values["sample_time"] = float(round(sample_time, 4)) display_values[metric_name] = value continue - case "cer" | "cer_no_token" | "wer" | "wer_no_punct" | "wer_no_token" | "ner": + case ( + "cer" + | "cer_no_token" + | "wer" + | "wer_no_punct" + | "wer_no_token" + | "ner" + ): keyword = METRICS_KEYWORD[metric_name[:3]] suffix = metric_name[3:] num_name, denom_name = ( @@ -150,7 +157,14 @@ class MetricManager: gt, prediction = values["str_y"], values["str_x"] for metric_name in metric_names: match metric_name: - case "cer" | "cer_no_token" | "wer" | "wer_no_punct" | "wer_no_token" | "ner": + case ( + "cer" + | "cer_no_token" + | "wer" + | "wer_no_punct" + | "wer_no_token" + | "ner" + ): task = metric_name[:3] keyword = METRICS_KEYWORD[task] suffix = metric_name[3:] diff --git a/dan/ocr/mlflow.py b/dan/ocr/mlflow.py index fe166e8364b3f04a3d5dfa657618c143b7db6d9f..b2a9f24c3f0a6f95e0461dcc4ca8d2e4ba90d2a3 100644 --- a/dan/ocr/mlflow.py +++ b/dan/ocr/mlflow.py @@ -144,7 +144,8 @@ def start_mlflow_run(config: dict): assert experiment_id, "Missing MLflow experiment ID in the configuration" # Start run - yield mlflow.start_run( - run_id=run_id, run_name=run_name, experiment_id=experiment_id - ), run_id is None + yield ( + mlflow.start_run(run_id=run_id, run_name=run_name, experiment_id=experiment_id), + run_id is None, + ) mlflow.end_run()