Backfill Language CLI
Module: aibs_backend.interfaces.cli.backfill_language
Purpose
Populate or repair persisted Document.language values for already-ingested
documents. Use this when documents predate language detection, parser output has
changed, or a workspace has incomplete language metadata.
This CLI changes document metadata only. It does not rebuild catalog or retrieval indexes; run the projection rebuild CLIs afterward if projected language fields need to be refreshed.
Command
pdm run python -m aibs_backend.interfaces.cli.backfill_language \
[--workspace <uuid>] [--dry-run] [--force]
or:
python -m aibs_backend.interfaces.cli.backfill_language \
[--workspace <uuid>] [--dry-run] [--force]
Options
Option |
Meaning |
|---|---|
|
Process only one workspace. Omit to process all workspaces. |
|
Detect and report without saving document changes. |
|
Re-detect even when |
Execution Flow
Validate the optional workspace ID.
Build the application container from
.env.Page documents through the document repository.
Skip documents that already have language unless
--forceis set.Build a language-detection sample from parsed content, metadata, title, and chunk summaries.
Run the configured language detector.
Save changed documents unless
--dry-runis set.Print a summary report.
Report Fields
Field |
Meaning |
|---|---|
|
Documents inspected. |
|
Documents updated with a detected language. |
|
Detector matched the existing value. |
|
Existing language was present and |
|
Detector returned no acceptable result. |
|
No usable text sample was available. |
|
Per-document detection failures. |
Exit Codes
Code |
Meaning |
|---|---|
|
Completed successfully. |
|
Invalid workspace ID or workspace not found. |
Unexpected runtime exceptions exit non-zero through the Python process.
Operating Notes
Run
--dry-runfirst on large workspaces.Use
--forceonly when existing language values are suspected stale.Follow with catalog/retrieval projection rebuilds if the UI or planner depends on projected language fields.