fix: add warning when using incompatible parameters (#99)

Signed-off-by: Michele Dolfi <dol@zurich.ibm.com>
This commit is contained in:
Michele Dolfi
2025-03-16 09:03:22 +01:00
committed by GitHub
parent c76daac70c
commit a212547d28

View File

@@ -74,11 +74,37 @@ def callback(
def _run(
*,
command: str,
# Docling serve parameters
artifacts_path: Path | None,
enable_ui: bool,
) -> None:
server_type = "development" if command == "dev" else "production"
console.print(f"Starting {server_type} server 🚀")
run_subprocess = (
uvicorn_settings.workers is not None and uvicorn_settings.workers > 1
) or uvicorn_settings.reload
if run_subprocess and docling_serve_settings.artifacts_path != artifacts_path:
err_console.print(
"\n[yellow]:warning: The server will run with reload or multiple workers. \n"
"The argument [bold]--artifacts-path[/bold] will be ignored, please set the value \n"
"using the environment variable [bold]DOCLING_SERVE_ARTIFACTS_PATH[/bold].[/yellow]"
)
if run_subprocess and docling_serve_settings.enable_ui != enable_ui:
err_console.print(
"\n[yellow]:warning: The server will run with reload or multiple workers. \n"
"The argument [bold]--enable-ui[/bold] will be ignored, please set the value \n"
"using the environment variable [bold]DOCLING_SERVE_ENABLE_UI[/bold].[/yellow]"
)
# Propagate the settings to the app settings
docling_serve_settings.artifacts_path = artifacts_path
docling_serve_settings.enable_ui = enable_ui
# Print documentation
url = f"http://{uvicorn_settings.host}:{uvicorn_settings.port}"
url_docs = f"{url}/docs"
url_ui = f"{url}/ui"
@@ -99,6 +125,7 @@ def _run(
console.print("")
console.print("Logs:")
# Launch the server
uvicorn.run(
app="docling_serve.app:create_app",
factory=True,
@@ -187,11 +214,10 @@ def dev(
uvicorn_settings.root_path = root_path
uvicorn_settings.proxy_headers = proxy_headers
docling_serve_settings.artifacts_path = artifacts_path
docling_serve_settings.enable_ui = enable_ui
_run(
command="dev",
artifacts_path=artifacts_path,
enable_ui=enable_ui,
)
@@ -282,11 +308,10 @@ def run(
uvicorn_settings.root_path = root_path
uvicorn_settings.proxy_headers = proxy_headers
docling_serve_settings.artifacts_path = artifacts_path
docling_serve_settings.enable_ui = enable_ui
_run(
command="run",
artifacts_path=artifacts_path,
enable_ui=enable_ui,
)