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>
46 lines
1.5 KiB
Python
46 lines
1.5 KiB
Python
"""Models and methods to define a package model."""
|
|
|
|
import importlib.metadata
|
|
import re
|
|
from typing import Annotated
|
|
|
|
from pydantic import BaseModel, StrictStr, StringConstraints
|
|
|
|
from docling_core.types.base import VERSION_PATTERN
|
|
|
|
|
|
class Package(BaseModel, extra="forbid"):
|
|
"""Representation of a software package.
|
|
|
|
The version needs to comply with Semantic Versioning 2.0.0.
|
|
"""
|
|
|
|
name: StrictStr = "docling-core"
|
|
version: Annotated[str, StringConstraints(strict=True, pattern=VERSION_PATTERN)] = importlib.metadata.version(
|
|
"docling-core"
|
|
)
|
|
|
|
def __hash__(self):
|
|
"""Return the hash value for this S3Path object."""
|
|
return hash((type(self),) + tuple(self.__dict__.values()))
|
|
|
|
def get_major(self):
|
|
"""Get the major version of this package."""
|
|
return re.match(VERSION_PATTERN, self.version)["major"]
|
|
|
|
def get_minor(self):
|
|
"""Get the major version of this package."""
|
|
return re.match(VERSION_PATTERN, self.version)["minor"]
|
|
|
|
def get_patch(self):
|
|
"""Get the major version of this package."""
|
|
return re.match(VERSION_PATTERN, self.version)["patch"]
|
|
|
|
def get_pre_release(self):
|
|
"""Get the pre-release version of this package."""
|
|
return re.match(VERSION_PATTERN, self.version)["prerelease"]
|
|
|
|
def get_build_metadata(self):
|
|
"""Get the build metadata version of this package."""
|
|
return re.match(VERSION_PATTERN, self.version)["buildmetadata"]
|