Spaces:
Configuration error
Configuration error
Michele Dolfi
commited on
fix: add warning when using incompatible parameters (#99)
Browse files- docling_serve/__main__.py +31 -6
docling_serve/__main__.py
CHANGED
@@ -74,11 +74,37 @@ def callback(
|
|
74 |
def _run(
|
75 |
*,
|
76 |
command: str,
|
|
|
|
|
|
|
77 |
) -> None:
|
78 |
server_type = "development" if command == "dev" else "production"
|
79 |
|
80 |
console.print(f"Starting {server_type} server 🚀")
|
81 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
82 |
url = f"http://{uvicorn_settings.host}:{uvicorn_settings.port}"
|
83 |
url_docs = f"{url}/docs"
|
84 |
url_ui = f"{url}/ui"
|
@@ -99,6 +125,7 @@ def _run(
|
|
99 |
console.print("")
|
100 |
console.print("Logs:")
|
101 |
|
|
|
102 |
uvicorn.run(
|
103 |
app="docling_serve.app:create_app",
|
104 |
factory=True,
|
@@ -187,11 +214,10 @@ def dev(
|
|
187 |
uvicorn_settings.root_path = root_path
|
188 |
uvicorn_settings.proxy_headers = proxy_headers
|
189 |
|
190 |
-
docling_serve_settings.artifacts_path = artifacts_path
|
191 |
-
docling_serve_settings.enable_ui = enable_ui
|
192 |
-
|
193 |
_run(
|
194 |
command="dev",
|
|
|
|
|
195 |
)
|
196 |
|
197 |
|
@@ -282,11 +308,10 @@ def run(
|
|
282 |
uvicorn_settings.root_path = root_path
|
283 |
uvicorn_settings.proxy_headers = proxy_headers
|
284 |
|
285 |
-
docling_serve_settings.artifacts_path = artifacts_path
|
286 |
-
docling_serve_settings.enable_ui = enable_ui
|
287 |
-
|
288 |
_run(
|
289 |
command="run",
|
|
|
|
|
290 |
)
|
291 |
|
292 |
|
|
|
74 |
def _run(
|
75 |
*,
|
76 |
command: str,
|
77 |
+
# Docling serve parameters
|
78 |
+
artifacts_path: Path | None,
|
79 |
+
enable_ui: bool,
|
80 |
) -> None:
|
81 |
server_type = "development" if command == "dev" else "production"
|
82 |
|
83 |
console.print(f"Starting {server_type} server 🚀")
|
84 |
|
85 |
+
run_subprocess = (
|
86 |
+
uvicorn_settings.workers is not None and uvicorn_settings.workers > 1
|
87 |
+
) or uvicorn_settings.reload
|
88 |
+
|
89 |
+
if run_subprocess and docling_serve_settings.artifacts_path != artifacts_path:
|
90 |
+
err_console.print(
|
91 |
+
"\n[yellow]:warning: The server will run with reload or multiple workers. \n"
|
92 |
+
"The argument [bold]--artifacts-path[/bold] will be ignored, please set the value \n"
|
93 |
+
"using the environment variable [bold]DOCLING_SERVE_ARTIFACTS_PATH[/bold].[/yellow]"
|
94 |
+
)
|
95 |
+
|
96 |
+
if run_subprocess and docling_serve_settings.enable_ui != enable_ui:
|
97 |
+
err_console.print(
|
98 |
+
"\n[yellow]:warning: The server will run with reload or multiple workers. \n"
|
99 |
+
"The argument [bold]--enable-ui[/bold] will be ignored, please set the value \n"
|
100 |
+
"using the environment variable [bold]DOCLING_SERVE_ENABLE_UI[/bold].[/yellow]"
|
101 |
+
)
|
102 |
+
|
103 |
+
# Propagate the settings to the app settings
|
104 |
+
docling_serve_settings.artifacts_path = artifacts_path
|
105 |
+
docling_serve_settings.enable_ui = enable_ui
|
106 |
+
|
107 |
+
# Print documentation
|
108 |
url = f"http://{uvicorn_settings.host}:{uvicorn_settings.port}"
|
109 |
url_docs = f"{url}/docs"
|
110 |
url_ui = f"{url}/ui"
|
|
|
125 |
console.print("")
|
126 |
console.print("Logs:")
|
127 |
|
128 |
+
# Launch the server
|
129 |
uvicorn.run(
|
130 |
app="docling_serve.app:create_app",
|
131 |
factory=True,
|
|
|
214 |
uvicorn_settings.root_path = root_path
|
215 |
uvicorn_settings.proxy_headers = proxy_headers
|
216 |
|
|
|
|
|
|
|
217 |
_run(
|
218 |
command="dev",
|
219 |
+
artifacts_path=artifacts_path,
|
220 |
+
enable_ui=enable_ui,
|
221 |
)
|
222 |
|
223 |
|
|
|
308 |
uvicorn_settings.root_path = root_path
|
309 |
uvicorn_settings.proxy_headers = proxy_headers
|
310 |
|
|
|
|
|
|
|
311 |
_run(
|
312 |
command="run",
|
313 |
+
artifacts_path=artifacts_path,
|
314 |
+
enable_ui=enable_ui,
|
315 |
)
|
316 |
|
317 |
|