mirror of
https://github.com/docling-project/docling-core.git
synced 2026-11-18 20:27:00 +00:00
* What was removed The legacy_doc document model and the rec (Record) types, plus all code/resources/tests that existed only to serve them. Deleted packages/modules - docling_core/types/legacy_doc/ (whole folder) - docling_core/types/rec/ (whole folder) - docling_core/utils/legacy.py (legacy conversion functions) - docling_core/utils/validate.py (RAW/ANN/OCR CLI) Edited production code - types/__init__.py — dropped the Record export - utils/validators.py — removed validate_schema/validate_raw_schema/validate_ann_schema/validate_ocr_schema and their now-unused imports; kept validate_unique_list/validate_datetime - utils/generate_docs.py — dropped Record from MODELS Removed resources/artifacts - resources/schemas/doc/ (legacy RAW/ANN/OCR/DOC), resources/schemas/generated/ccs_document_schema.json, docs/Record.json Tests — deleted the 5 legacy/rec-only suites + 2 stale gold files; trimmed test_collection.py, test_base.py, test_doc_base.py to keep their non-legacy parts; replaced the _create_hash import in test_code_chunker.py with a local helper. Removed test/data/legacy_doc/ and test/data/rec/. Verification - No dangling code references remain (only string literals and the vendored _reference/chunker_repo scratch data, intentionally untouched). - from docling_core.types import DoclingDocument, Generic works; Record now correctly raises ImportError. - Full project suite: 496 passed. - generate_docs.py now emits only DoclingDocument.json and Generic.json. The full plan is saved at _plans/remove-legacy-doc-and-rec.md. Two notes worth flagging: - Breaking public API: docling_core.types.Record and the docling_core.utils.legacy conversion functions were public — downstream docling uses legacy_to_docling_document/docling_document_to_legacy. The branch name (dev/remove-legacy-document) suggests this is intended, but it'll need a coordinated bump downstream. - I left _reference/ and _plans/ alone (untracked scratch dirs). Nothing was committed — all changes are staged/working-tree only, per your edit-by-edit approval flow. Signed-off-by: Peter Staar <taa@zurich.ibm.com> * updated the checks.yaml Signed-off-by: Peter Staar <taa@zurich.ibm.com> * removed docling_core/types/gen/, docling_core/types/nlp, docling_core/types/legacy_doc, docling_core/types/rec Signed-off-by: Peter Staar <taa@zurich.ibm.com> * removed the minimal_document_schema_flat.json Signed-off-by: Peter Staar <taa@zurich.ibm.com> * removed docling_core/resources Signed-off-by: Peter Staar <taa@zurich.ibm.com> * removed the files and updated the imports according to Cesar's suggestion Signed-off-by: Peter Staar <taa@zurich.ibm.com> * fixed the ruff linter Signed-off-by: Peter Staar <taa@zurich.ibm.com> --------- Signed-off-by: Peter Staar <taa@zurich.ibm.com>
43 lines
1.2 KiB
Python
43 lines
1.2 KiB
Python
import pytest
|
|
from pydantic import ValidationError
|
|
|
|
from docling_core.types.doc import DocItemLabel, DoclingDocument, TrackSource
|
|
|
|
|
|
def test_track_source():
|
|
"""Test the class TrackSource."""
|
|
valid_track = TrackSource(
|
|
start_time=11.0,
|
|
end_time=12.0,
|
|
identifier="test",
|
|
voice="Mary",
|
|
)
|
|
|
|
assert valid_track
|
|
assert valid_track.start_time == 11.0
|
|
assert valid_track.end_time == 12.0
|
|
assert valid_track.identifier == "test"
|
|
assert valid_track.voice == "Mary"
|
|
|
|
with pytest.raises(ValidationError, match="end_time"):
|
|
TrackSource(start_time=11.0)
|
|
|
|
with pytest.raises(ValidationError, match="should be a valid string"):
|
|
TrackSource(
|
|
start_time=11.0,
|
|
end_time=12.0,
|
|
voice=["Mary"],
|
|
)
|
|
|
|
with pytest.raises(ValidationError, match="must be greater than start"):
|
|
TrackSource(
|
|
start_time=11.0,
|
|
end_time=11.0,
|
|
)
|
|
|
|
doc = DoclingDocument(name="Unknown")
|
|
item = doc.add_text(text="Hello world", label=DocItemLabel.TEXT, source=valid_track)
|
|
assert item.source
|
|
assert len(item.source) == 1
|
|
assert item.source[0] == valid_track
|