Skip to content
Snippets Groups Projects
Commit ea6286c1 authored by Yoann Schneider's avatar Yoann Schneider :tennis:
Browse files

Merge branch 'ruff-formatter' into 'main'

Update ruff pre commit hook and add formatter

Closes #238

See merge request !330
parents 41e0c881 56af98f8
No related branches found
No related tags found
1 merge request!330Update ruff pre commit hook and add formatter
repos: repos:
- repo: https://github.com/astral-sh/ruff-pre-commit - repo: https://github.com/astral-sh/ruff-pre-commit
# Ruff version. # Ruff version.
rev: v0.0.282 rev: v0.1.6
hooks: hooks:
# Run the linter.
- id: ruff - id: ruff
args: [--fix, --exit-non-zero-on-fix] args: [--fix, --exit-non-zero-on-fix]
- repo: https://github.com/ambv/black # Run the formatter.
rev: 23.7.0 - id: ruff-format
hooks:
- id: black
- repo: https://github.com/pre-commit/pre-commit-hooks - repo: https://github.com/pre-commit/pre-commit-hooks
rev: v4.4.0 rev: v4.4.0
hooks: hooks:
......
...@@ -106,7 +106,14 @@ class MetricManager: ...@@ -106,7 +106,14 @@ class MetricManager:
display_values["sample_time"] = float(round(sample_time, 4)) display_values["sample_time"] = float(round(sample_time, 4))
display_values[metric_name] = value display_values[metric_name] = value
continue 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]] keyword = METRICS_KEYWORD[metric_name[:3]]
suffix = metric_name[3:] suffix = metric_name[3:]
num_name, denom_name = ( num_name, denom_name = (
...@@ -150,7 +157,14 @@ class MetricManager: ...@@ -150,7 +157,14 @@ class MetricManager:
gt, prediction = values["str_y"], values["str_x"] gt, prediction = values["str_y"], values["str_x"]
for metric_name in metric_names: for metric_name in metric_names:
match metric_name: 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] task = metric_name[:3]
keyword = METRICS_KEYWORD[task] keyword = METRICS_KEYWORD[task]
suffix = metric_name[3:] suffix = metric_name[3:]
......
...@@ -144,7 +144,8 @@ def start_mlflow_run(config: dict): ...@@ -144,7 +144,8 @@ def start_mlflow_run(config: dict):
assert experiment_id, "Missing MLflow experiment ID in the configuration" assert experiment_id, "Missing MLflow experiment ID in the configuration"
# Start run # Start run
yield mlflow.start_run( yield (
run_id=run_id, run_name=run_name, experiment_id=experiment_id mlflow.start_run(run_id=run_id, run_name=run_name, experiment_id=experiment_id),
), run_id is None run_id is None,
)
mlflow.end_run() mlflow.end_run()
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment