Spaces:
Configuration error
Configuration error
Eugene
commited on
feat: display version in fastapi docs (#78)
Browse filesSigned-off-by: Eugene <[email protected]>
- docling_serve/__main__.py +2 -5
- docling_serve/app.py +9 -3
- uv.lock +1 -1
docling_serve/__main__.py
CHANGED
@@ -1,4 +1,4 @@
|
|
1 |
-
import importlib
|
2 |
import logging
|
3 |
import platform
|
4 |
import sys
|
@@ -51,9 +51,7 @@ def version_callback(value: bool) -> None:
|
|
51 |
def callback(
|
52 |
version: Annotated[
|
53 |
Union[bool, None],
|
54 |
-
typer.Option(
|
55 |
-
"--version", help="Show the version and exit.", callback=version_callback
|
56 |
-
),
|
57 |
] = None,
|
58 |
verbose: Annotated[
|
59 |
int,
|
@@ -298,5 +296,4 @@ def main() -> None:
|
|
298 |
|
299 |
# Launch the CLI when calling python -m docling_serve
|
300 |
if __name__ == "__main__":
|
301 |
-
|
302 |
main()
|
|
|
1 |
+
import importlib.metadata
|
2 |
import logging
|
3 |
import platform
|
4 |
import sys
|
|
|
51 |
def callback(
|
52 |
version: Annotated[
|
53 |
Union[bool, None],
|
54 |
+
typer.Option(help="Show the version and exit.", callback=version_callback),
|
|
|
|
|
55 |
] = None,
|
56 |
verbose: Annotated[
|
57 |
int,
|
|
|
296 |
|
297 |
# Launch the CLI when calling python -m docling_serve
|
298 |
if __name__ == "__main__":
|
|
|
299 |
main()
|
docling_serve/app.py
CHANGED
@@ -1,3 +1,4 @@
|
|
|
|
1 |
import logging
|
2 |
import tempfile
|
3 |
from contextlib import asynccontextmanager
|
@@ -60,7 +61,6 @@ _log = logging.getLogger(__name__)
|
|
60 |
# Context manager to initialize and clean up the lifespan of the FastAPI app
|
61 |
@asynccontextmanager
|
62 |
async def lifespan(app: FastAPI):
|
63 |
-
|
64 |
# Converter with default options
|
65 |
pdf_format_option, options_hash = get_pdf_pipeline_opts(ConvertDocumentsOptions())
|
66 |
converters[options_hash] = DocumentConverter(
|
@@ -85,9 +85,17 @@ async def lifespan(app: FastAPI):
|
|
85 |
|
86 |
|
87 |
def create_app():
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
88 |
app = FastAPI(
|
89 |
title="Docling Serve",
|
90 |
lifespan=lifespan,
|
|
|
91 |
)
|
92 |
|
93 |
origins = ["*"]
|
@@ -104,7 +112,6 @@ def create_app():
|
|
104 |
|
105 |
# Mount the Gradio app
|
106 |
if docling_serve_settings.enable_ui:
|
107 |
-
|
108 |
try:
|
109 |
import gradio as gr
|
110 |
|
@@ -207,7 +214,6 @@ def create_app():
|
|
207 |
ConvertDocumentsOptions, FormDepends(ConvertDocumentsOptions)
|
208 |
],
|
209 |
):
|
210 |
-
|
211 |
_log.info(f"Received {len(files)} files for processing.")
|
212 |
|
213 |
# Load the uploaded files to Docling DocumentStream
|
|
|
1 |
+
import importlib.metadata
|
2 |
import logging
|
3 |
import tempfile
|
4 |
from contextlib import asynccontextmanager
|
|
|
61 |
# Context manager to initialize and clean up the lifespan of the FastAPI app
|
62 |
@asynccontextmanager
|
63 |
async def lifespan(app: FastAPI):
|
|
|
64 |
# Converter with default options
|
65 |
pdf_format_option, options_hash = get_pdf_pipeline_opts(ConvertDocumentsOptions())
|
66 |
converters[options_hash] = DocumentConverter(
|
|
|
85 |
|
86 |
|
87 |
def create_app():
|
88 |
+
try:
|
89 |
+
version = importlib.metadata.version("docling_serve")
|
90 |
+
except importlib.metadata.PackageNotFoundError:
|
91 |
+
_log.warning("Unable to get docling_serve version, falling back to 0.0.0")
|
92 |
+
|
93 |
+
version = "0.0.0"
|
94 |
+
|
95 |
app = FastAPI(
|
96 |
title="Docling Serve",
|
97 |
lifespan=lifespan,
|
98 |
+
version=version,
|
99 |
)
|
100 |
|
101 |
origins = ["*"]
|
|
|
112 |
|
113 |
# Mount the Gradio app
|
114 |
if docling_serve_settings.enable_ui:
|
|
|
115 |
try:
|
116 |
import gradio as gr
|
117 |
|
|
|
214 |
ConvertDocumentsOptions, FormDepends(ConvertDocumentsOptions)
|
215 |
],
|
216 |
):
|
|
|
217 |
_log.info(f"Received {len(files)} files for processing.")
|
218 |
|
219 |
# Load the uploaded files to Docling DocumentStream
|
uv.lock
CHANGED
@@ -535,7 +535,7 @@ wheels = [
|
|
535 |
|
536 |
[[package]]
|
537 |
name = "docling-serve"
|
538 |
-
version = "0.
|
539 |
source = { editable = "." }
|
540 |
dependencies = [
|
541 |
{ name = "docling" },
|
|
|
535 |
|
536 |
[[package]]
|
537 |
name = "docling-serve"
|
538 |
+
version = "0.4.0"
|
539 |
source = { editable = "." }
|
540 |
dependencies = [
|
541 |
{ name = "docling" },
|