Coverage for documents/management/commands/document_create_classifier.py: 0%
14 statements
« prev ^ index » next coverage.py v7.15.2, created at 2026-10-10 09:07 +0000
« prev ^ index » next coverage.py v7.15.2, created at 2026-10-10 09:07 +0000
1from __future__ import annotations
3import time
5from documents.management.commands.base import PaperlessCommand
6from documents.tasks import train_classifier
9class Command(PaperlessCommand):
10 help = (
11 "Trains the classifier on your data and saves the resulting models to a "
12 "file. The document consumer will then automatically use this new model."
13 )
14 supports_progress_bar = False
15 supports_multiprocessing = False
17 def handle(self, *args, **options) -> None:
18 start = time.monotonic()
20 with (
21 self.buffered_logging("paperless.tasks"),
22 self.buffered_logging("paperless.classifier"),
23 ):
24 train_classifier(
25 status_callback=lambda msg: self.console.print(f" {msg}"),
26 )
28 elapsed = time.monotonic() - start
29 self.console.print(
30 f"[green]✓[/green] Classifier training complete ({elapsed:.1f}s)",
31 )