fix: make enum serializable with human-readable value (#555)
Signed-off-by: Michele Dolfi <dol@zurich.ibm.com>
This commit is contained in:
parent
eb30c4f763
commit
a7df337654
@ -27,8 +27,10 @@ from docling.datamodel.base_models import (
|
|||||||
from docling.datamodel.document import ConversionResult
|
from docling.datamodel.document import ConversionResult
|
||||||
from docling.datamodel.pipeline_options import (
|
from docling.datamodel.pipeline_options import (
|
||||||
EasyOcrOptions,
|
EasyOcrOptions,
|
||||||
|
OcrEngine,
|
||||||
OcrMacOptions,
|
OcrMacOptions,
|
||||||
OcrOptions,
|
OcrOptions,
|
||||||
|
PdfBackend,
|
||||||
PdfPipelineOptions,
|
PdfPipelineOptions,
|
||||||
RapidOcrOptions,
|
RapidOcrOptions,
|
||||||
TableFormerMode,
|
TableFormerMode,
|
||||||
@ -68,22 +70,6 @@ def version_callback(value: bool):
|
|||||||
raise typer.Exit()
|
raise typer.Exit()
|
||||||
|
|
||||||
|
|
||||||
# Define an enum for the backend options
|
|
||||||
class PdfBackend(str, Enum):
|
|
||||||
PYPDFIUM2 = "pypdfium2"
|
|
||||||
DLPARSE_V1 = "dlparse_v1"
|
|
||||||
DLPARSE_V2 = "dlparse_v2"
|
|
||||||
|
|
||||||
|
|
||||||
# Define an enum for the ocr engines
|
|
||||||
class OcrEngine(str, Enum):
|
|
||||||
EASYOCR = "easyocr"
|
|
||||||
TESSERACT_CLI = "tesseract_cli"
|
|
||||||
TESSERACT = "tesseract"
|
|
||||||
OCRMAC = "ocrmac"
|
|
||||||
RAPIDOCR = "rapidocr"
|
|
||||||
|
|
||||||
|
|
||||||
def export_documents(
|
def export_documents(
|
||||||
conv_results: Iterable[ConversionResult],
|
conv_results: Iterable[ConversionResult],
|
||||||
output_dir: Path,
|
output_dir: Path,
|
||||||
|
@ -19,12 +19,12 @@ if TYPE_CHECKING:
|
|||||||
|
|
||||||
|
|
||||||
class ConversionStatus(str, Enum):
|
class ConversionStatus(str, Enum):
|
||||||
PENDING = auto()
|
PENDING = "pending"
|
||||||
STARTED = auto()
|
STARTED = "started"
|
||||||
FAILURE = auto()
|
FAILURE = "failure"
|
||||||
SUCCESS = auto()
|
SUCCESS = "success"
|
||||||
PARTIAL_SUCCESS = auto()
|
PARTIAL_SUCCESS = "partial_success"
|
||||||
SKIPPED = auto()
|
SKIPPED = "skipped"
|
||||||
|
|
||||||
|
|
||||||
class InputFormat(str, Enum):
|
class InputFormat(str, Enum):
|
||||||
@ -89,15 +89,15 @@ MimeTypeToFormat = {
|
|||||||
|
|
||||||
|
|
||||||
class DocInputType(str, Enum):
|
class DocInputType(str, Enum):
|
||||||
PATH = auto()
|
PATH = "path"
|
||||||
STREAM = auto()
|
STREAM = "stream"
|
||||||
|
|
||||||
|
|
||||||
class DoclingComponentType(str, Enum):
|
class DoclingComponentType(str, Enum):
|
||||||
DOCUMENT_BACKEND = auto()
|
DOCUMENT_BACKEND = "document_backend"
|
||||||
MODEL = auto()
|
MODEL = "model"
|
||||||
DOC_ASSEMBLER = auto()
|
DOC_ASSEMBLER = "doc_assembler"
|
||||||
USER_INPUT = auto()
|
USER_INPUT = "user_input"
|
||||||
|
|
||||||
|
|
||||||
class ErrorItem(BaseModel):
|
class ErrorItem(BaseModel):
|
||||||
|
@ -126,6 +126,26 @@ class OcrMacOptions(OcrOptions):
|
|||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
|
# Define an enum for the backend options
|
||||||
|
class PdfBackend(str, Enum):
|
||||||
|
"""Enum of valid PDF backends."""
|
||||||
|
|
||||||
|
PYPDFIUM2 = "pypdfium2"
|
||||||
|
DLPARSE_V1 = "dlparse_v1"
|
||||||
|
DLPARSE_V2 = "dlparse_v2"
|
||||||
|
|
||||||
|
|
||||||
|
# Define an enum for the ocr engines
|
||||||
|
class OcrEngine(str, Enum):
|
||||||
|
"""Enum of valid OCR engines."""
|
||||||
|
|
||||||
|
EASYOCR = "easyocr"
|
||||||
|
TESSERACT_CLI = "tesseract_cli"
|
||||||
|
TESSERACT = "tesseract"
|
||||||
|
OCRMAC = "ocrmac"
|
||||||
|
RAPIDOCR = "rapidocr"
|
||||||
|
|
||||||
|
|
||||||
class PipelineOptions(BaseModel):
|
class PipelineOptions(BaseModel):
|
||||||
"""Base pipeline options."""
|
"""Base pipeline options."""
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user