Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 20 additions & 0 deletions photomap/backend/launch.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
"""Lightweight console-script launcher for ``start_photomap``.

Importing :mod:`photomap.backend.photomap_server` pulls in FastAPI, the routers
and (transitively) CLIP/torch, which can take 10-30s. Because the console-script
entry point has to import its target module before calling it, a banner printed
inside ``photomap_server.main`` only appears after that whole import finishes,
leaving the terminal silent during startup.

This module deliberately imports nothing heavy at module scope so the banner is
printed immediately, then defers the expensive import until inside ``main``.
"""

import sys


def main() -> None:
print("PhotoMapAI server initializing…", file=sys.stderr, flush=True)
from photomap.backend.photomap_server import main as _serve

_serve()
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ search_images = "photomap.backend.imagetool:main"
search_text = "photomap.backend.imagetool:main"
find_duplicate_images = "photomap.backend.imagetool:main"
rebuild_cluster_labels = "photomap.backend.imagetool:main"
start_photomap = "photomap.backend.photomap_server:main"
start_photomap = "photomap.backend.launch:main"

[tool.ruff]
# Set line length to match the project's style
Expand Down
Loading