Skip to content

chore: Update pre-commit hooks [review required]#120

Draft
PasteurBot wants to merge 1 commit into
mainfrom
_bot/update-precommit
Draft

chore: Update pre-commit hooks [review required]#120
PasteurBot wants to merge 1 commit into
mainfrom
_bot/update-precommit

Conversation

@PasteurBot

Copy link
Copy Markdown
Contributor

Pre-commit is unable to automatically update the hooks due to unresolvable conflicts.
Please review the changes and merge manually.

Log:

check for added large files..............................................Passed
check json...........................................(no files to check)Skipped
check toml...............................................................Passed
check yaml...............................................................Passed
detect private key.......................................................Passed
fix end of files.........................................................Passed
trim trailing whitespace.................................................Passed
ruff (legacy alias)......................................................Failed
- hook id: ruff
- exit code: 1

EXE001 Shebang is present but file is not executable
 --> .github/scripts/detect-changed-solvers.py:1:1
  |
1 | #!/usr/bin/env python3
  | ^^^^^^^^^^^^^^^^^^^^^^
2 |
3 | # Copyright 2026 Pasteur Labs. All Rights Reserved.
  |

EXE001 Shebang is present but file is not executable
 --> .github/scripts/filter-problems-by-solver.py:1:1
  |
1 | #!/usr/bin/env python3
  | ^^^^^^^^^^^^^^^^^^^^^^
2 |
3 | # Copyright 2026 Pasteur Labs. All Rights Reserved.
  |

S112 `try`-`except`-`continue` detected, consider logging the exception
  --> .github/scripts/filter-problems-by-solver.py:51:9
   |
49 |           try:
50 |               names = {s.name for s in get_config(p).solvers}
51 | /         except Exception:
52 | |             continue
   | |____________________^
53 |           if wanted & names:
54 |               hits.append(p)
   |

BLE001 Do not catch blind exception: `Exception`
  --> .github/scripts/filter-problems-by-solver.py:51:16
   |
49 |         try:
50 |             names = {s.name for s in get_config(p).solvers}
51 |         except Exception:
   |                ^^^^^^^^^
52 |             continue
53 |         if wanted & names:
   |

EXE001 Shebang is present but file is not executable
 --> .github/scripts/generate-benchmark-matrix.py:1:1
  |
1 | #!/usr/bin/env python3
  | ^^^^^^^^^^^^^^^^^^^^^^
2 |
3 | # Copyright 2026 Pasteur Labs. All Rights Reserved.
  |

EXE001 Shebang is present but file is not executable
 --> .github/scripts/merge-results.py:1:1
  |
1 | #!/usr/bin/env python3
  | ^^^^^^^^^^^^^^^^^^^^^^
2 |
3 | # Copyright 2026 Pasteur Labs. All Rights Reserved.
  |

S112 `try`-`except`-`continue` detected, consider logging the exception
   --> .github/scripts/merge-results.py:117:9
    |
115 |                       # overwritten; per-solver keys accumulate.
116 |                       merged[key] = np.asarray(data[key])
117 | /         except Exception:
118 | |             continue
    | |____________________^
119 |       if merged:
120 |           out_path.parent.mkdir(parents=True, exist_ok=True)
    |

BLE001 Do not catch blind exception: `Exception`
   --> .github/scripts/merge-results.py:117:16
    |
115 |                     # overwritten; per-solver keys accumulate.
116 |                     merged[key] = np.asarray(data[key])
117 |         except Exception:
    |                ^^^^^^^^^
118 |             continue
119 |     if merged:
    |

BLE001 Do not catch blind exception: `Exception`
   --> .github/scripts/merge-results.py:173:24
    |
171 |                 try:
172 |                     results.append(_load_json(src))
173 |                 except Exception as e:
    |                        ^^^^^^^^^
174 |                     print(f"  warning: failed to load {src}: {e}", file=sys.stderr)
175 |             if not results:
    |

EXE001 Shebang is present but file is not executable
 --> .github/scripts/overlay-results.py:1:1
  |
1 | #!/usr/bin/env python3
  | ^^^^^^^^^^^^^^^^^^^^^^
2 |
3 | # Copyright 2026 Pasteur Labs. All Rights Reserved.
  |

BLE001 Do not catch blind exception: `Exception`
   --> .github/scripts/overlay-results.py:273:20
    |
271 |                 _save_json(merged, out_path)
272 |                 n_merged += 1
273 |             except Exception as e:
    |                    ^^^^^^^^^
274 |                 print(f"  warning: merge failed for {relpath}: {e}", file=sys.stderr)
275 |                 # Fall back to PR version.
    |

BLE001 Do not catch blind exception: `Exception`
   --> .github/scripts/overlay-results.py:284:20
    |
282 |                 _merge_npz_pair(baseline_files[relpath], pr_files[relpath], out_path)
283 |                 n_npz_merged += 1
284 |             except Exception as e:
    |                    ^^^^^^^^^
285 |                 print(
286 |                     f"  warning: npz merge failed for {relpath}: {e}", file=sys.stderr
    |

EXE001 Shebang is present but file is not executable
 --> .github/scripts/pull-solver-images.py:1:1
  |
1 | #!/usr/bin/env python3
  | ^^^^^^^^^^^^^^^^^^^^^^
2 |
3 | # Copyright 2026 Pasteur Labs. All Rights Reserved.
  |

PLW1510 `subprocess.run` without explicit `check` argument
  --> .github/scripts/pull-solver-images.py:45:8
   |
43 |     """Pull *remote* and retag it to *local_tag*. Returns True on success."""
44 |     print(f"Pulling {remote}")
45 |     if subprocess.run(["docker", "pull", remote]).returncode != 0:
   |        ^^^^^^^^^^^^^^
46 |         return False
47 |     subprocess.run(["docker", "tag", remote, local_tag])
   |
help: Add explicit `check=False`

PLW1510 `subprocess.run` without explicit `check` argument
  --> .github/scripts/pull-solver-images.py:47:5
   |
45 |     if subprocess.run(["docker", "pull", remote]).returncode != 0:
46 |         return False
47 |     subprocess.run(["docker", "tag", remote, local_tag])
   |     ^^^^^^^^^^^^^^
48 |     print(f"  Tagged as {local_tag}")
49 |     return True
   |
help: Add explicit `check=False`

S112 `try`-`except`-`continue` detected, consider logging the exception
   --> .github/scripts/pull-solver-images.py:109:9
    |
107 |           try:
108 |               cfg = get_config(p)
109 | /         except Exception:
110 | |             continue
    | |____________________^
111 |           for spec in cfg.solvers:
112 |               # --solvers filter: skip solvers not in the requested set
    |

BLE001 Do not catch blind exception: `Exception`
   --> .github/scripts/pull-solver-images.py:109:16
    |
107 |         try:
108 |             cfg = get_config(p)
109 |         except Exception:
    |                ^^^^^^^^^
110 |             continue
111 |         for spec in cfg.solvers:
    |

EXE001 Shebang is present but file is not executable
 --> .github/scripts/validate-problem-configs.py:1:1
  |
1 | #!/usr/bin/env python3
  | ^^^^^^^^^^^^^^^^^^^^^^
2 |
3 | # Copyright 2026 Pasteur Labs. All Rights Reserved.
  |

EXE001 Shebang is present but file is not executable
 --> .github/scripts/validate-tesseract-configs.py:1:1
  |
1 | #!/usr/bin/env python3
  | ^^^^^^^^^^^^^^^^^^^^^^
2 |
3 | # Copyright 2026 Pasteur Labs. All Rights Reserved.
  |

BLE001 Do not catch blind exception: `Exception`
  --> .github/scripts/validate-tesseract-configs.py:63:12
   |
61 |             if val is not None and not isinstance(val, bool):
62 |                 errors.append(f"{p}: mosaic.{bool_field}={val!r} must be a boolean")
63 |     except Exception as e:
   |            ^^^^^^^^^
64 |         errors.append(f"{p}: {e}")
   |

EXE001 Shebang is present but file is not executable
 --> docs/generate.py:1:1
  |
1 | #!/usr/bin/env python3
  | ^^^^^^^^^^^^^^^^^^^^^^
2 |
3 | # Copyright 2026 Pasteur Labs. All Rights Reserved.
  |

PLW0602 Using global for `_CATEGORY_LABELS` but no assignment is done
  --> docs/generate.py:50:27
   |
48 |     are sourced from the problem configs rather than from this file.
49 |     """
50 |     global _SOLVER_SPECS, _CATEGORY_LABELS
   |                           ^^^^^^^^^^^^^^^^
51 |     if _SOLVER_SPECS is not None:
52 |         return _SOLVER_SPECS
   |

S112 `try`-`except`-`continue` detected, consider logging the exception
  --> docs/generate.py:63:9
   |
61 |           try:
62 |               cfg = get_config(prob)
63 | /         except Exception:
64 | |             continue
   | |____________________^
65 |           domain_dir = cfg.tesseract_dir.name
66 |           # First non-empty category_label per tesseract dir wins. Multiple
   |

BLE001 Do not catch blind exception: `Exception`
  --> docs/generate.py:63:16
   |
61 |         try:
62 |             cfg = get_config(prob)
63 |         except Exception:
   |                ^^^^^^^^^
64 |             continue
65 |         domain_dir = cfg.tesseract_dir.name
   |

S110 `try`-`except`-`pass` detected, consider logging the exception
   --> docs/generate.py:128:17
    |
126 |                   try:
127 |                       return ast.literal_eval(raw)
128 | /                 except Exception:
129 | |                     pass
    | |________________________^
130 |               return raw
131 |       return ""
    |

BLE001 Do not catch blind exception: `Exception`
   --> docs/generate.py:128:24
    |
126 |                 try:
127 |                     return ast.literal_eval(raw)
128 |                 except Exception:
    |                        ^^^^^^^^^
129 |                     pass
130 |             return raw
    |

EXE001 Shebang is present but file is not executable
 --> docs/generate_results.py:1:1
  |
1 | #!/usr/bin/env python3
  | ^^^^^^^^^^^^^^^^^^^^^^
2 |
3 | # Copyright 2026 Pasteur Labs. All Rights Reserved.
  |

BLE001 Do not catch blind exception: `Exception`
   --> docs/generate_results.py:281:12
    |
279 |             return cfg.get_ic_description(experiment)
280 |         return cfg.get_plot_description(suite, experiment)
281 |     except Exception:
    |            ^^^^^^^^^
282 |         return ""
    |

BLE001 Do not catch blind exception: `Exception`
   --> docs/generate_results.py:289:12
    |
287 |     try:
288 |         return _get_config(problem).get_experiment_description(suite, experiment)
289 |     except Exception:
    |            ^^^^^^^^^
290 |         return ""
    |

S110 `try`-`except`-`pass` detected, consider logging the exception
   --> docs/generate_results.py:299:5
    |
297 |           if desc:
298 |               return desc
299 | /     except Exception:
300 | |         pass
    | |____________^
301 |       return PROBLEM_DESCRIPTIONS.get(problem, "")
    |

BLE001 Do not catch blind exception: `Exception`
   --> docs/generate_results.py:299:12
    |
297 |         if desc:
298 |             return desc
299 |     except Exception:
    |            ^^^^^^^^^
300 |         pass
301 |     return PROBLEM_DESCRIPTIONS.get(problem, "")
    |

S110 `try`-`except`-`pass` detected, consider logging the exception
   --> docs/generate_results.py:310:5
    |
308 |           if bc:
309 |               return bc
310 | /     except Exception:
311 | |         pass
    | |____________^
312 |       return PROBLEM_BC_DESCRIPTIONS.get(problem, "")
    |

BLE001 Do not catch blind exception: `Exception`
   --> docs/generate_results.py:310:12
    |
308 |         if bc:
309 |             return bc
310 |     except Exception:
    |            ^^^^^^^^^
311 |         pass
312 |     return PROBLEM_BC_DESCRIPTIONS.get(problem, "")
    |

BLE001 Do not catch blind exception: `Exception`
   --> docs/generate_results.py:354:12
    |
352 |     try:
353 |         return json.loads(path.read_text(encoding="utf-8")).get("results", []) or []
354 |     except Exception:
    |            ^^^^^^^^^
355 |         return []
    |

BLE001 Do not catch blind exception: `Exception`
   --> docs/generate_results.py:534:12
    |
532 |     try:
533 |         ranked = ranker(problem)
534 |     except Exception:
    |            ^^^^^^^^^
535 |         return []
536 |     if not ranked:
    |

S110 `try`-`except`-`pass` detected, consider logging the exception
   --> docs/generate_results.py:651:9
    |
649 |                   params = {**params, "sweep": result["sweep"]}
650 |               return params
651 | /         except Exception:
652 | |             pass
    | |________________^
653 |       return None
    |

BLE001 Do not catch blind exception: `Exception`
   --> docs/generate_results.py:651:16
    |
649 |                 params = {**params, "sweep": result["sweep"]}
650 |             return params
651 |         except Exception:
    |                ^^^^^^^^^
652 |             pass
653 |     return None
    |

ISC004 Unparenthesized implicit string concatenation in collection
   --> docs/generate_results.py:789:13
    |
787 |       if illustration and (OUTPUT_DIR / illustration).exists():
788 |           lines += [
789 | /             f"![]({illustration}){{width=100% "
790 | |             'style="max-width:560px; display:block; margin:0 auto 0.5rem;"}',
    | |____________________________________________________________________________^
791 |               "",
792 |           ]
    |
help: Did you forget a comma?
help: Wrap implicitly concatenated strings in parentheses

S110 `try`-`except`-`pass` detected, consider logging the exception
   --> mosaic/benchmarks/cli/_helpers.py:359:5
    |
358 |           cfg = get_config(cfg.name)
359 | /     except Exception:
360 | |         pass
    | |____________^
361 |       if to_run:
362 |           names = to_run
    |

BLE001 Do not catch blind exception: `Exception`
   --> mosaic/benchmarks/cli/_helpers.py:359:12
    |
358 |         cfg = get_config(cfg.name)
359 |     except Exception:
    |            ^^^^^^^^^
360 |         pass
361 |     if to_run:
    |

BLE001 Do not catch blind exception: `Exception`
   --> mosaic/benchmarks/cli/_helpers.py:385:16
    |
383 |         except FileNotFoundError as exc:
384 |             print_skip(f"{name}: results not found ({exc.filename})")
385 |         except Exception as exc:
    |                ^^^^^^^^^
386 |             if verbose_errors:
387 |                 console.print_exception()
    |

S112 `try`-`except`-`continue` detected, consider logging the exception
   --> mosaic/benchmarks/cli/_helpers.py:474:9
    |
472 |           try:
473 |               all_names |= set(get_config(problem).solver_names)
474 | /         except Exception:
475 | |             # Skip problems that fail to import — they'll surface as
476 | |             # "build failed" later in the loop and aren't relevant to a
477 | |             # name-typo check.
478 | |             continue
    | |____________________^
479 |       # Match case-insensitively against the canonical names.
480 |       known_lower = {n.lower() for n in all_names}
    |

BLE001 Do not catch blind exception: `Exception`
   --> mosaic/benchmarks/cli/_helpers.py:474:16
    |
472 |         try:
473 |             all_names |= set(get_config(problem).solver_names)
474 |         except Exception:
    |                ^^^^^^^^^
475 |             # Skip problems that fail to import — they'll surface as
476 |             # "build failed" later in the loop and aren't relevant to a
    |

BLE001 Do not catch blind exception: `Exception`
  --> mosaic/benchmarks/cli/_status_helpers.py:46:16
   |
44 |         try:
45 |             cfg = get_config(problem)
46 |         except Exception as exc:
   |                ^^^^^^^^^
47 |             print_warn(f"{problem}: {exc}")
48 |             continue
   |

BLE001 Do not catch blind exception: `Exception`
  --> mosaic/benchmarks/cli/_status_helpers.py:59:16
   |
57 |             with open(diff_against) as f:
58 |                 old_snapshot = _json.load(f)
59 |         except Exception as exc:
   |                ^^^^^^^^^
60 |             print_warn(f"could not read --diff-against file: {exc}")
61 |             old_snapshot = None
   |

BLE001 Do not catch blind exception: `Exception`
  --> mosaic/benchmarks/cli/build.py:65:16
   |
63 |             # effect here (see test_build_unknown_problem_records_failure).
64 |             _cli_pkg.build_all(cfg, max_workers=jobs)
65 |         except Exception as exc:
   |                ^^^^^^^^^
66 |             print_warn(f"{problem}: {exc}")
67 |             failed.append((problem, str(exc)))
   |

BLE001 Do not catch blind exception: `Exception`
  --> mosaic/benchmarks/cli/ics.py:53:20
   |
51 |                 fn(cfg)
52 |                 console.print(f"  [green]{name}[/green] ok")
53 |             except Exception as exc:
   |                    ^^^^^^^^^
54 |                 if traceback:
55 |                     console.print_exception()
   |

BLE001 Do not catch blind exception: `Exception`
  --> mosaic/benchmarks/cli/ics.py:63:16
   |
61 |             result = exp_fn(cfg, {})
62 |             console.print(f"  [green]{name}[/green] ok  shape={result['shape']}")
63 |         except Exception as exc:
   |                ^^^^^^^^^
64 |             if traceback:
65 |                 console.print_exception()
   |

S110 `try`-`except`-`pass` detected, consider logging the exception
   --> mosaic/benchmarks/cli/reference.py:177:9
    |
175 |               if sweep and "values" in sweep:
176 |                   return len(sweep["values"])
177 | /         except Exception:
178 | |             pass
    | |________________^
179 |
180 |       # Fallback: count consensus_* keys in the NPZ.
    |

BLE001 Do not catch blind exception: `Exception`
   --> mosaic/benchmarks/cli/reference.py:177:16
    |
175 |             if sweep and "values" in sweep:
176 |                 return len(sweep["values"])
177 |         except Exception:
    |                ^^^^^^^^^
178 |             pass
    |

BLE001 Do not catch blind exception: `Exception`
   --> mosaic/benchmarks/cli/reference.py:184:12
    |
182 |         with np.load(str(fields_path), allow_pickle=False) as data:
183 |             return sum(1 for k in data if k.startswith("consensus_"))
184 |     except Exception:
    |            ^^^^^^^^^
185 |         return 0
    |

S110 `try`-`except`-`pass` detected, consider logging the exception
   --> mosaic/benchmarks/cli/reference.py:196:5
    |
194 |               if "sweep_values" in data:
195 |                   return data["sweep_values"].tolist()
196 | /     except Exception:
197 | |         pass
    | |____________^
198 |       return None
    |

BLE001 Do not catch blind exception: `Exception`
   --> mosaic/benchmarks/cli/reference.py:196:12
    |
194 |             if "sweep_values" in data:
195 |                 return data["sweep_values"].tolist()
196 |     except Exception:
    |            ^^^^^^^^^
197 |         pass
198 |     return None
    |

BLE001 Do not catch blind exception: `Exception`
   --> mosaic/benchmarks/cli/reference.py:284:28
    |
282 |                                 f"    [yellow]✗[/] {s.name} @ {sweep_key}={val}: apply failed"
283 |                             )
284 |                     except Exception as e:
    |                            ^^^^^^^^^
285 |                         console.print(
286 |                             f"    [red]✗[/] {s.name} @ {sweep_key}={val}: {e}"
    |

BLE001 Do not catch blind exception: `Exception`
   --> mosaic/benchmarks/cli/run.py:203:16
    |
201 |                 jobs=jobs,
202 |             )
203 |         except Exception as exc:
    |                ^^^^^^^^^
204 |             msg = f"build failed: {exc}"
205 |             console.print(f"  [red]{msg}[/]")
    |

BLE001 Do not catch blind exception: `Exception`
   --> mosaic/benchmarks/cli/run.py:340:16
    |
338 |             else:
339 |                 run_status[(problem, suite)] = ("skip", "no experiments ran")
340 |         except Exception as exc:
    |                ^^^^^^^^^
341 |             if traceback:
342 |                 console.print_exception()
    |

BLE001 Do not catch blind exception: `Exception`
   --> mosaic/benchmarks/cli/status.py:113:16
    |
111 |         try:
112 |             cfg = get_config(problem)
113 |         except Exception as exc:
    |                ^^^^^^^^^
114 |             print_warn(f"{problem}: {exc}")
115 |             continue
    |

BLE001 Do not catch blind exception: `Exception`
   --> mosaic/benchmarks/core/config.py:875:24
    |
873 |                 try:
874 |                     fn(cfg, **fn_kw)
875 |                 except Exception as exc:
    |                        ^^^^^^^^^
876 |                     print_warn(f"plot {key}#{view_name}: {type(exc).__name__}: {exc}")
    |

BLE001 Do not catch blind exception: `Exception`
    --> mosaic/benchmarks/core/config.py:1173:16
     |
1171 |             with open(config_path) as f:
1172 |                 doc = yaml.safe_load(f)
1173 |         except Exception as exc:
     |                ^^^^^^^^^
1174 |             warnings.warn(
1175 |                 f"Solver discovery: cannot parse {config_path}: {exc}",
     |

BLE001 Do not catch blind exception: `Exception`
    --> mosaic/benchmarks/core/config.py:1256:12
     |
1254 |         with Tesseract.from_image(tag) as t:
1255 |             return "vector_jacobian_product" in t.available_endpoints
1256 |     except Exception:
     |            ^^^^^^^^^
1257 |         return False
     |

BLE001 Do not catch blind exception: `Exception`
   --> mosaic/benchmarks/core/experiment.py:516:24
    |
514 |                     kernel_fn(t, _ctx(name, _sweep_values[0]))
515 |                     console.print(f"  [{color}]{name}[/] warmup ok")
516 |                 except Exception as wex:
    |                        ^^^^^^^^^
517 |                     console.print(
518 |                         f"  [{color}]{name}[/] warmup skipped ({type(wex).__name__})"
    |

BLE001 Do not catch blind exception: `Exception`
   --> mosaic/benchmarks/core/experiment.py:564:28
    |
562 |                         out = kernel_fn(t, _ctx(name, val))
563 |                         exc: Exception | None = None
564 |                     except Exception as e:
    |                            ^^^^^^^^^
565 |                         out, exc = None, e
566 |                 mem = poller.summary
    |

BLE001 Do not catch blind exception: `Exception`
  --> mosaic/benchmarks/core/hardware.py:33:12
   |
31 |             total_mib = nvml.nvmlDeviceGetMemoryInfo(handle).total / (1024 * 1024)
32 |             out.append(f"{name}, {total_mib:.0f} MiB")
33 |     except Exception:
   |            ^^^^^^^^^
34 |         return []
35 |     return out
   |

S110 `try`-`except`-`pass` detected, consider logging the exception
  --> mosaic/benchmarks/core/hardware.py:57:5
   |
55 |                       info["cpu"] = line.split(":", 1)[1].strip()
56 |                       break
57 | /     except Exception:
58 | |         pass
   | |____________^
59 |
60 |       # Total RAM via psutil
   |

BLE001 Do not catch blind exception: `Exception`
  --> mosaic/benchmarks/core/hardware.py:57:12
   |
55 |                     info["cpu"] = line.split(":", 1)[1].strip()
56 |                     break
57 |     except Exception:
   |            ^^^^^^^^^
58 |         pass
   |

S110 `try`-`except`-`pass` detected, consider logging the exception
  --> mosaic/benchmarks/core/hardware.py:65:5
   |
64 |           info["ram_gb"] = round(psutil.virtual_memory().total / 1e9, 1)
65 | /     except Exception:
66 | |         pass
   | |____________^
67 |
68 |       return info
   |

BLE001 Do not catch blind exception: `Exception`
  --> mosaic/benchmarks/core/hardware.py:65:12
   |
64 |         info["ram_gb"] = round(psutil.virtual_memory().total / 1e9, 1)
65 |     except Exception:
   |            ^^^^^^^^^
66 |         pass
   |

BLE001 Do not catch blind exception: `Exception`
  --> mosaic/benchmarks/core/hardware.py:78:12
   |
76 |     try:
77 |         return nvml.nvmlDeviceGetCount() > 0
78 |     except Exception:
   |            ^^^^^^^^^
79 |         return False
   |

PYI034 `__enter__` methods in classes like `ResourceSampler` usually return `self` at runtime
   --> mosaic/benchmarks/core/hardware.py:119:9
    |
117 |         self._ram_mib: float | None = None
118 |
119 |     def __enter__(self) -> ResourceSampler:
    |         ^^^^^^^^^
120 |         self._baseline_vram_mib = sample_vram_mib(self.gpu_id)
121 |         return self
    |
help: Use `Self` as return type

S110 `try`-`except`-`pass` detected, consider logging the exception
   --> mosaic/benchmarks/core/hardware.py:129:9
    |
128 |               self._ram_mib = psutil.Process().memory_info().rss / 1e6
129 | /         except Exception:
130 | |             pass
    | |________________^
131 |
132 |       @property
    |

BLE001 Do not catch blind exception: `Exception`
   --> mosaic/benchmarks/core/hardware.py:129:16
    |
128 |             self._ram_mib = psutil.Process().memory_info().rss / 1e6
129 |         except Exception:
    |                ^^^^^^^^^
130 |             pass
    |

BLE001 Do not catch blind exception: `Exception`
   --> mosaic/benchmarks/core/harness.py:184:12
    |
182 |                     wall_limit_hit = True
183 |                     break
184 |     except Exception as exc:
    |            ^^^^^^^^^
185 |         failure = {
186 |             "failure_type": classify_failure(type(exc).__name__, str(exc)),
    |

BLE001 Do not catch blind exception: `Exception`
   --> mosaic/benchmarks/core/io.py:303:12
    |
301 |     try:
302 |         return load_json(p)
303 |     except Exception:
    |            ^^^^^^^^^
304 |         return None
    |

BLE001 Do not catch blind exception: `Exception`
   --> mosaic/benchmarks/core/io.py:321:12
    |
319 |         with np.load(p, allow_pickle=False) as f:
320 |             return {k: np.asarray(f[k]) for k in f.files}
321 |     except Exception:
    |            ^^^^^^^^^
322 |         return {}
    |

LOG015 `warning()` call on root logger
   --> mosaic/benchmarks/core/io.py:908:9
    |
906 |       _flock_dt = time.monotonic() - _flock_t0
907 |       if _flock_dt > 60:
908 | /         logging.warning(
909 | |             "save_experiment flock held for %.1fs at %s (solvers=%s)",
910 | |             _flock_dt,
911 | |             result_path,
912 | |             sorted(new_tesseract_hashes.keys()),
913 | |         )
    | |_________^
    |
help: Use own logger instead

BLE001 Do not catch blind exception: `Exception`
  --> mosaic/benchmarks/core/memory.py:57:16
   |
55 |             pynvml.nvmlInit()
56 |             _NVML_OK = True
57 |         except Exception:
   |                ^^^^^^^^^
58 |             _NVML_OK = False
59 |             return None
   |

BLE001 Do not catch blind exception: `Exception`
  --> mosaic/benchmarks/core/memory.py:73:12
   |
72 |         return docker.from_env()
73 |     except Exception:
   |            ^^^^^^^^^
74 |         return None
   |

BLE001 Do not catch blind exception: `Exception`
  --> mosaic/benchmarks/core/memory.py:92:12
   |
90 |         handle = nvml.nvmlDeviceGetHandleByIndex(int(gpu_id))
91 |         return nvml.nvmlDeviceGetMemoryInfo(handle).used / (1024 * 1024)
92 |     except Exception:
   |            ^^^^^^^^^
93 |         return None
   |

BLE001 Do not catch blind exception: `Exception`
   --> mosaic/benchmarks/core/memory.py:110:12
    |
108 |         usage = stats.get("memory_stats", {}).get("usage")
109 |         return float(usage) / (1024 * 1024) if usage is not None else None
110 |     except Exception:
    |            ^^^^^^^^^
111 |         return None
    |

PYI034 `__enter__` methods in classes like `MemoryPoller` usually return `self` at runtime
   --> mosaic/benchmarks/core/memory.py:170:9
    |
168 |         self._thread: threading.Thread | None = None
169 |
170 |     def __enter__(self) -> MemoryPoller:
    |         ^^^^^^^^^
171 |         self._thread = threading.Thread(target=self._loop, daemon=True)
172 |         self._thread.start()
    |
help: Use `Self` as return type

BLE001 Do not catch blind exception: `Exception`
  --> mosaic/benchmarks/core/resources.py:32:12
   |
31 |         total_bytes = psutil.virtual_memory().total
32 |     except Exception:
   |            ^^^^^^^^^
33 |         return []
   |

PLW1510 `subprocess.run` without explicit `check` argument
   --> mosaic/benchmarks/core/runner.py:129:13
    |
127 |     for name in names:
128 |         try:
129 |             subprocess.run(
    |             ^^^^^^^^^^^^^^
130 |                 ["docker", "rm", "-f", name],
131 |                 capture_output=True,
    |
help: Add explicit `check=False`

S110 `try`-`except`-`pass` detected, consider logging the exception
   --> mosaic/benchmarks/core/runner.py:134:9
    |
132 |                   timeout=10,
133 |               )
134 | /         except Exception:
135 | |             pass
    | |________________^
    |

BLE001 Do not catch blind exception: `Exception`
   --> mosaic/benchmarks/core/runner.py:134:16
    |
132 |                 timeout=10,
133 |             )
134 |         except Exception:
    |                ^^^^^^^^^
135 |             pass
    |

PLW1510 `subprocess.run` without explicit `check` argument
   --> mosaic/benchmarks/core/runner.py:237:13
    |
235 |         tesseract_path = cfg.tesseract_dir / spec.dir
236 |         t0 = time.monotonic()
237 |         r = subprocess.run(
    |             ^^^^^^^^^^^^^^
238 |             ["tesseract", "build", "--tag", tag, str(tesseract_path)],
239 |             capture_output=True,
    |
help: Add explicit `check=False`

BLE001 Do not catch blind exception: `Exception`
   --> mosaic/benchmarks/core/runner.py:284:24
    |
282 |                     name, img_tag = future.result()
283 |                     images[name] = img_tag
284 |                 except Exception as exc:
    |                        ^^^^^^^^^
285 |                     failed.append(solver_name)
286 |                     print_warn(f"BUILD FAILED: {solver_name} — {exc}")
    |

BLE001 Do not catch blind exception: `Exception`
   --> mosaic/benchmarks/core/runner.py:418:16
    |
416 |         except NotImplementedError as exc:
417 |             print_skip(str(exc))
418 |         except Exception as exc:
    |                ^^^^^^^^^
419 |             if verbose_errors:
420 |                 console.print_exception()
    |

S110 `try`-`except`-`pass` detected, consider logging the exception
   --> mosaic/benchmarks/core/runner.py:431:13
    |
430 |                   jax.clear_caches()
431 | /             except Exception:
432 | |                 pass
    | |____________________^
433 |
434 |       if plots and plot_fns:
    |

BLE001 Do not catch blind exception: `Exception`
   --> mosaic/benchmarks/core/runner.py:431:20
    |
430 |                 jax.clear_caches()
431 |             except Exception:
    |                    ^^^^^^^^^
432 |                 pass
    |

BLE001 Do not catch blind exception: `Exception`
   --> mosaic/benchmarks/core/runner.py:442:16
    |
441 |             _plot_cfg = _get_cfg(cfg.name)
442 |         except Exception:
    |                ^^^^^^^^^
443 |             _plot_cfg = cfg
444 |         # Regular per-experiment plots: only fire when the matching experiment ran.
    |

BLE001 Do not catch blind exception: `Exception`
   --> mosaic/benchmarks/core/runner.py:449:24
    |
447 |                 try:
448 |                     plot_fns[name](_plot_cfg, suffix=suffix)
449 |                 except Exception as exc:
    |                        ^^^^^^^^^
450 |                     if verbose_errors:
451 |                         console.print_exception()
    |

BLE001 Do not catch blind exception: `Exception`
   --> mosaic/benchmarks/core/runner.py:460:20
    |
458 |             try:
459 |                 fn(_plot_cfg)
460 |             except Exception as exc:
    |                    ^^^^^^^^^
461 |                 if verbose_errors:
462 |                     console.print_exception()
    |

BLE001 Do not catch blind exception: `Exception`
   --> mosaic/benchmarks/core/runner.py:684:20
    |
682 |                 with _tracked_tesseract(tags[name], _gpus, _NO_HC) as t:
683 |                     fn(name, t)
684 |             except Exception as exc:
    |                    ^^^^^^^^^
685 |                 print_warn(f"{name} failed: {exc}")
686 |                 if on_error is not None:
    |

BLE001 Do not catch blind exception: `Exception`
   --> mosaic/benchmarks/core/runner.py:703:16
    |
701 |             with _tracked_tesseract(tags[name], [gid], _NO_HC) as t:
702 |                 fn(name, t)
703 |         except Exception as exc:
    |                ^^^^^^^^^
704 |             print_warn(f"{name} failed: {exc}")
705 |             if on_error is not None:
    |

BLE001 Do not catch blind exception: `Exception`
   --> mosaic/benchmarks/core/runner.py:804:12
    |
802 |         }
803 |         return arr, extras, state
804 |     except Exception as exc:
    |            ^^^^^^^^^
805 |         _exc_name = type(exc).__name__
806 |         if isinstance(exc, TimeoutError):
    |

BLE001 Do not catch blind exception: `Exception`
   --> mosaic/benchmarks/core/status.py:220:12
    |
218 |     try:
219 |         return isinstance(x, float) and math.isnan(x)
220 |     except Exception:
    |            ^^^^^^^^^
221 |         return False
    |

PERF102 When using only the values of a dict use the `values()` method
   --> mosaic/benchmarks/core/status.py:347:25
    |
345 |         best_cos = None
346 |         best_rel = None
347 |         for _eps, st in sweep.items():
    |                         ^^^^^^^^^^^
348 |             if not isinstance(st, dict):
349 |                 continue
    |
help: Replace `.items()` with `.values()`

BLE001 Do not catch blind exception: `Exception`
   --> mosaic/benchmarks/core/status.py:676:12
    |
674 |         target = getattr(mod, attr_path)
675 |         h = harness_fn_hash(target) or None
676 |     except Exception:
    |            ^^^^^^^^^
677 |         h = None
678 |     cache[qualname] = h
    |

BLE001 Do not catch blind exception: `Exception`
   --> mosaic/benchmarks/core/status.py:900:12
    |
898 |     try:
899 |         data = load_json(result_path)
900 |     except Exception as exc:
    |            ^^^^^^^^^
901 |         row.cells = {s: Cell(FAILED, f"unreadable result.json: {exc}") for s in solvers}
902 |         # Even when the file is corrupted, exclusions still take precedence —
    |

ISC004 Unparenthesized implicit string concatenation in collection
   --> mosaic/benchmarks/core/status_checks.py:109:13
    |
107 |           return (
108 |               "anomaly",
109 | /             f"error {worst[1]:.3g} at sweep={worst[0]} is {ratio:.1f}× peer median ({worst[2]:.3g}); "
110 | |             f"threshold k={k}",
    | |______________________________^
111 |           )
    |
help: Did you forget a comma?
help: Wrap implicitly concatenated strings in parentheses

ISC004 Unparenthesized implicit string concatenation in collection
   --> mosaic/benchmarks/core/status_checks.py:143:13
    |
141 |           return (
142 |               "anomaly",
143 | /             f"median time {s.solver_median_time:.1f}s is {ratio:.0f}× peer median "
144 | |             f"({s.peer_median_time:.2f}s); threshold k={k}",
    | |___________________________________________________________^
145 |           )
    |
help: Did you forget a comma?
help: Wrap implicitly concatenated strings in parentheses

ISC004 Unparenthesized implicit string concatenation in collection
   --> mosaic/benchmarks/core/status_checks.py:188:13
    |
186 |           return (
187 |               "anomaly",
188 | /             f"best-ε rel_err {s.best_rel_err:.2e} is {ratio:.1f}× peer median "
189 | |             f"({s.peer_rel_err_median:.2e}); threshold k={k}",
    | |_____________________________________________________________^
190 |           )
    |
help: Did you forget a comma?
help: Wrap implicitly concatenated strings in parentheses

PERF402 Use `list` or `list.copy` to create a copy of a list
   --> mosaic/benchmarks/core/utils.py:165:13
    |
163 |     if experiment:
164 |         for p in experiment.split("/"):
165 |             parts.append(p)
    |             ^^^^^^^^^^^^^^^
166 |     if sub:
167 |         for p in sub.split("/"):
    |

PERF402 Use `list` or `list.copy` to create a copy of a list
   --> mosaic/benchmarks/core/utils.py:168:13
    |
166 |     if sub:
167 |         for p in sub.split("/"):
168 |             parts.append(p)
    |             ^^^^^^^^^^^^^^^
169 |     # Try longest prefix first.
170 |     for n in range(len(parts), 0, -1):
    |

BLE001 Do not catch blind exception: `Exception`
  --> mosaic/benchmarks/problems/__init__.py:58:16
   |
56 |         try:
57 |             mod = importlib.import_module(module_name)
58 |         except Exception as exc:
   |                ^^^^^^^^^
59 |             log.warning("skipping %s: %s", module_name, exc)
60 |             continue
   |

BLE001 Do not catch blind exception: `Exception`
   --> mosaic/benchmarks/problems/navier_stokes_3d_grid/optimization.py:270:16
    |
268 |             )
269 |             tgt = apply_tesseract(t, inp_true)[output_key]
270 |         except Exception as exc:
    |                ^^^^^^^^^
271 |             from mosaic.benchmarks.core.console import print_warn
    |

BLE001 Do not catch blind exception: `Exception`
   --> mosaic/benchmarks/problems/navier_stokes_3d_grid/optimization.py:434:12
    |
432 |             grad_proj_fn=grad_proj_fn,
433 |         )
434 |     except Exception as exc:
    |            ^^^^^^^^^
435 |         from mosaic.benchmarks.core.console import print_warn
    |

BLE001 Do not catch blind exception: `Exception`
   --> mosaic/benchmarks/problems/navier_stokes_3d_grid/optimization.py:489:12
    |
487 |         )
488 |         target = apply_tesseract(t, inputs_true_fixed)[output_key]
489 |     except Exception as exc:
    |            ^^^^^^^^^
490 |         from mosaic.benchmarks.core.console import print_warn
    |

BLE001 Do not catch blind exception: `Exception`
    --> mosaic/benchmarks/problems/navier_stokes_3d_grid/optimization.py:1040:12
     |
1038 |         inp_rec = make_inputs(name, ic_opt, domain_extent=domain_extent, **fphys)
1039 |         snaps["final_rec"] = np.asarray(apply_tesseract(t, inp_rec)[output_key])
1040 |     except Exception:
     |            ^^^^^^^^^
1041 |         snaps["final_rec"] = np.zeros_like(np.asarray(ic_opt))
     |

BLE001 Do not catch blind exception: `Exception`
    --> mosaic/benchmarks/problems/navier_stokes_3d_grid/optimization.py:1056:16
     |
1054 |             )
1055 |             snaps["final_perturbed"] = np.asarray(apply_tesseract(t, inp_p)[output_key])
1056 |         except Exception:
     |                ^^^^^^^^^
1057 |             snaps["final_perturbed"] = np.zeros_like(np.asarray(ic_true))
     |

S110 `try`-`except`-`pass` detected, consider logging the exception
  --> mosaic/benchmarks/problems/navier_stokes_grid/optimization.py:61:5
   |
59 |           if vel is not None:
60 |               return np.array(vel)
61 | /     except Exception:
62 | |         pass
   | |____________^
63 |       return None
   |

BLE001 Do not catch blind exception: `Exception`
  --> mosaic/benchmarks/problems/navier_stokes_grid/optimization.py:61:12
   |
59 |         if vel is not None:
60 |             return np.array(vel)
61 |     except Exception:
   |            ^^^^^^^^^
62 |         pass
63 |     return None
   |

BLE001 Do not catch blind exception: `Exception`
   --> mosaic/benchmarks/problems/navier_stokes_grid/optimization.py:124:12
    |
122 |         vel = out_f.get("result")
123 |         return final_drag, (np.array(vel) if vel is not None else None)
124 |     except Exception:
    |            ^^^^^^^^^
125 |         return (losses[-1] if losses else float("nan")), None
    |

BLE001 Do not catch blind exception: `Exception`
   --> mosaic/benchmarks/problems/shared/optimization.py:191:16
    |
189 |         try:
190 |             live = len(jax.live_arrays())
191 |         except Exception:
    |                ^^^^^^^^^
192 |             live = -1
193 |         print(
    |

BLE001 Do not catch blind exception: `Exception`
  --> mosaic/benchmarks/problems/shared/plots/ics.py:94:12
   |
92 |         candidate = np.asarray(to_2d(ic), dtype=np.float32)
93 |         arr2d = candidate if candidate.ndim == 2 else None
94 |     except Exception:
   |            ^^^^^^^^^
95 |         arr2d = None
96 |     if arr2d is None:
   |

S112 `try`-`except`-`continue` detected, consider logging the exception
   --> mosaic/benchmarks/problems/shared/plots/ics.py:175:13
    |
173 |               try:
174 |                   arr = spec(**plot_params)
175 | /             except Exception:
176 | |                 continue
    | |________________________^
177 |           projected = _ic_to_2d(
178 |               arr,
    |

BLE001 Do not catch blind exception: `Exception`
   --> mosaic/benchmarks/problems/shared/plots/ics.py:175:20
    |
173 |             try:
174 |                 arr = spec(**plot_params)
175 |             except Exception:
    |                    ^^^^^^^^^
176 |                 continue
177 |         projected = _ic_to_2d(
    |

BLE001 Do not catch blind exception: `Exception`
   --> mosaic/benchmarks/problems/thermal_mesh/physics.py:206:12
    |
204 |     try:
205 |         T_nodal = spla.spsolve(K.tocsc(), f)
206 |     except Exception:
    |            ^^^^^^^^^
207 |         T_nodal = np.zeros(n_nodes, dtype=np.float64)
208 |     return T_nodal.astype(np.float32)
    |

TRY004 Prefer `TypeError` exception for invalid type
  --> mosaic/templates/scaffold.py:79:9
   |
77 |         doc = yaml.safe_load(f)
78 |     if not isinstance(doc, dict):
79 |         raise ValueError(f"{path}: expected a YAML mapping, got {type(doc).__name__}")
   |         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
80 |     for key in ("name", "schema_module", "output_key"):
81 |         if key not in doc:
   |

PLW1510 `subprocess.run` without explicit `check` argument
  --> mosaic/tesseracts/navier-stokes-grid/openfoam/tesseract_api.py:51:14
   |
49 | def _run_of(cmd: str, cwd: Path) -> None:
50 |     """Run an OpenFOAM command by sourcing the OF environment first."""
51 |     result = subprocess.run(
   |              ^^^^^^^^^^^^^^
52 |         ["bash", "-c", f". {_OF_BASHRC} && {cmd}"],
53 |         cwd=str(cwd),
   |
help: Add explicit `check=False`

PLR0124 Name compared with itself, consider replacing `v != v`
  --> mosaic/tesseracts/navier-stokes-grid/warp-ns/tesseract_api.py:41:8
   |
39 |     """
40 |     # NaN check: v != v is true only for NaN
41 |     if v != v:
   |        ^
42 |         v = wp.float32(0.0)
43 |     if v > wp.float32(1.0e30):
   |

PLW1510 `subprocess.run` without explicit `check` argument
   --> mosaic/tesseracts/structural-mesh/dealii-structural/tesseract_api.py:164:14
    |
162 |     """Invoke the deal.II struct_solver binary."""
163 |     cmd = [_DEALII_SOLVER, str(wd / "input.json")]
164 |     result = subprocess.run(cmd, cwd=str(wd), capture_output=True, text=True)
    |              ^^^^^^^^^^^^^^
165 |     if result.returncode != 0:
166 |         raise RuntimeError(
    |
help: Add explicit `check=False`

PLW1510 `subprocess.run` without explicit `check` argument
   --> mosaic/tesseracts/thermal-mesh/dealii-heat/tesseract_api.py:152:14
    |
150 |     """Invoke the deal.II heat_solver binary."""
151 |     cmd = [_DEALII_SOLVER, str(wd / "input.json")]
152 |     result = subprocess.run(cmd, cwd=str(wd), capture_output=True, text=True)
    |              ^^^^^^^^^^^^^^
153 |     if result.returncode != 0:
154 |         raise RuntimeError(
    |
help: Add explicit `check=False`

BLE001 Do not catch blind exception: `Exception`
  --> tests/core/test_npz_merge.py:78:20
   |
76 |                 barrier.wait(timeout=5)
77 |                 save_npz_merged(path, {key: np.array([value])})
78 |             except Exception as exc:
   |                    ^^^^^^^^^
79 |                 errors.append(exc)
   |

PERF102 When using only the values of a dict use the `values()` method
   --> tests/core/test_status.py:307:24
    |
306 |     def test_every_score_weight_maps_to_a_colour(self) -> None:
307 |         for _key, w in SCORE_WEIGHTS.items():
    |                        ^^^^^^^^^^^^^^^^^^^
308 |             color = weight_color(w)
309 |             self.assertTrue(
    |
help: Replace `.items()` with `.values()`

PLW1510 `subprocess.run` without explicit `check` argument
  --> tests/test_cli_smoke.py:23:12
   |
22 | def _run_help(args: list[str]) -> subprocess.CompletedProcess:
23 |     return subprocess.run(
   |            ^^^^^^^^^^^^^^
24 |         [*MOSAIC, *args, "--help"],
25 |         capture_output=True,
   |
help: Add explicit `check=False`

BLE001 Do not catch blind exception: `Exception`
   --> tests/test_dummy_integration.py:396:24
    |
394 |                 try:
395 |                     cfg.experiments[exp_key].fn(cfg, tags)
396 |                 except Exception as exc:
    |                        ^^^^^^^^^
397 |                     errors[(problem, exp_key)] = exc
398 |         yield {"results_root": results_root, "errors": errors}
    |

PLW1510 `subprocess.run` without explicit `check` argument
  --> tests/test_integration.py:28:13
   |
26 |     try:
27 |         return (
28 |             subprocess.run(
   |             ^^^^^^^^^^^^^^
29 |                 ["docker", "info"],
30 |                 capture_output=True,
   |
help: Add explicit `check=False`

PLW1510 `subprocess.run` without explicit `check` argument
  --> tests/test_integration.py:51:14
   |
49 | def built_solver():
50 |     """Build the Exponax tesseract once for all tests in this module."""
51 |     result = subprocess.run(
   |              ^^^^^^^^^^^^^^
52 |         ["tesseract", "build", _SOLVER_DIR],
53 |         capture_output=True,
   |
help: Add explicit `check=False`

PLW1510 `subprocess.run` without explicit `check` argument
  --> tests/test_plots_only.py:40:14
   |
38 | def test_plots_only_gradient():
39 |     """Mosaic run --plots-only must succeed with existing gradient results."""
40 |     result = subprocess.run(
   |              ^^^^^^^^^^^^^^
41 |         [*MOSAIC, "run", "--plots-only", "-p", "ns-grid", "--suites", "gradient"],
42 |         capture_output=True,
   |
help: Add explicit `check=False`

Found 130 errors.
No fixes available (8 hidden fixes can be enabled with the `--unsafe-fixes` option).

ruff format..............................................................Passed
update-uv-env............................................................Passed
update-requirements......................................................Passed
prettier.................................................................Passed

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant