Coverage for src/backoffice/_cli.py: 0%
28 statements
« prev ^ index » next coverage.py v7.15.4, created at 2026-08-13 03:07 +0000
« prev ^ index » next coverage.py v7.15.4, created at 2026-08-13 03:07 +0000
1from __future__ import annotations
3import sys
5from pydantic import BaseModel
6from pydantic_settings import BaseSettings, CliSubCommand
8from ._summarize import summarize_reports, summarize_reports_parallel
9from .index import create_index
12class CmdBase(BaseModel, use_attribute_docstrings=True, cli_implicit_flags=True):
13 pass
16class IndexCmd(CmdBase):
17 def run(self):
18 """Index the bioimage.io collection"""
19 _ = create_index()
22class SummarizeCmd(CmdBase):
23 max_workers: int | None = None
24 """Maximum number of worker threads to use for parallel processing."""
26 def run(self):
27 """Conflate tool summaries"""
28 if self.max_workers == 0:
29 summarize_reports()
30 else:
31 summarize_reports_parallel(max_workers=self.max_workers)
34class Backoffice(
35 BaseSettings,
36 cli_implicit_flags=True,
37 cli_parse_args=True,
38 cli_kebab_case=True,
39 cli_prog_name="backoffice",
40 cli_use_class_docs_for_groups=True,
41 use_attribute_docstrings=True,
42):
43 """backoffice - manage the bioimage.io collection"""
45 index: CliSubCommand[IndexCmd]
46 """index the bioimage.io collection"""
48 summarize: CliSubCommand[SummarizeCmd]
49 """conflate tool summaries"""
51 def run(self):
52 cmd = self.index or self.summarize
53 if cmd is None:
54 raise ValueError(
55 "No command specified. Use 'backoffice --help' to see available commands."
56 )
57 else:
58 sys.exit(cmd.run())