-
Notifications
You must be signed in to change notification settings - Fork 0
Implement FastAPI application with uv-based Docker setup and search endpoint #1
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
Co-authored-by: bio-boris <1258634+bio-boris@users.noreply.github.com>
Co-authored-by: bio-boris <1258634+bio-boris@users.noreply.github.com>
Co-authored-by: bio-boris <1258634+bio-boris@users.noreply.github.com>
Co-authored-by: bio-boris <1258634+bio-boris@users.noreply.github.com>
Co-authored-by: bio-boris <1258634+bio-boris@users.noreply.github.com>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull request overview
This PR implements a FastAPI application called TableScanner with Docker deployment using the uv package manager. It introduces a basic web service with two endpoints: a root health check endpoint and a search endpoint that accepts ID parameters.
Key Changes:
- Added FastAPI application structure with factory pattern (app/main.py) and modular routing (app/routes.py)
- Implemented Docker setup using uv-based Alpine image with uv for dependency management
- Created search endpoint accepting ID query parameters and returning JSON responses
Reviewed changes
Copilot reviewed 7 out of 8 changed files in this pull request and generated 12 comments.
Show a summary per file
| File | Description |
|---|---|
| pyproject.toml | Defines project metadata and dependencies (fastapi, uvicorn, minio) using modern Python packaging standards |
| Dockerfile | Creates containerized application using ghcr.io/astral-sh/uv:python3.13-alpine with uv sync for dependencies |
| docker-compose.yml | Configures service orchestration with port mapping, volume mounts, and health checks |
| app/main.py | Implements FastAPI factory pattern with application configuration and router inclusion |
| app/routes.py | Defines API endpoints including root service info and search functionality |
| app/init.py | Initializes app package with simple comment |
| README.md | Provides comprehensive documentation including setup, usage, API endpoints, and development instructions |
| .gitignore | Adds Python and uv-specific ignore patterns for development artifacts |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
|
|
||
|
|
||
| @router.get("/search") | ||
| def search(id: str = Query(..., description="ID to search for")): |
Copilot
AI
Dec 15, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The 'id' parameter lacks input validation. Consider adding validation for the format, length, or allowed characters of the ID to prevent potential issues with malformed inputs. FastAPI's Query parameter supports min_length, max_length, and regex patterns for validation.
| def search(id: str = Query(..., description="ID to search for")): | |
| def search( | |
| id: str = Query( | |
| ..., | |
| description="ID to search for", | |
| min_length=1, | |
| max_length=32, | |
| regex="^[a-zA-Z0-9_-]+$" | |
| ) | |
| ): |
| dependencies = [ | ||
| "fastapi>=0.124.4", | ||
| "uvicorn>=0.38.0", | ||
| #"KBUtilLib", # KBase internal library - version managed by KBase infrastructure |
Copilot
AI
Dec 15, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The PR description states dependencies should include KBUtilLib, but it's commented out in pyproject.toml. This creates an inconsistency between the documented dependencies and the actual configuration. Either uncomment this dependency with appropriate version constraints or update the documentation to reflect that it's intentionally excluded.
| #"KBUtilLib", # KBase internal library - version managed by KBase infrastructure | |
| "KBUtilLib", # KBase internal library - version managed by KBase infrastructure |
| version: '3.8' | ||
|
|
Copilot
AI
Dec 15, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The 'version' field in docker-compose.yml is deprecated and should be removed. Docker Compose v2 no longer requires or uses the version field, and its presence is now obsolete.
| version: '3.8' |
| RUN apk --no-cache add curl | ||
| WORKDIR /app | ||
| COPY app ./app | ||
| COPY pyproject.toml /app/pyproject.toml |
Copilot
AI
Dec 15, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Running 'uv sync' without copying a lock file (uv.lock) means dependencies will be resolved at build time, potentially leading to non-reproducible builds. Consider adding uv.lock to version control and copying it before running uv sync to ensure consistent dependency versions across builds.
| COPY pyproject.toml /app/pyproject.toml | |
| COPY pyproject.toml /app/pyproject.toml | |
| COPY uv.lock /app/uv.lock |
| 1. Install dependencies: | ||
| ```bash | ||
| pip install -r requirements.txt | ||
| ``` |
Copilot
AI
Dec 15, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The documentation references 'requirements.txt' for local development, but this file doesn't exist in the repository. The project uses pyproject.toml for dependency management. Update the installation command to use 'uv sync' or 'pip install .' instead.
| requires-python = ">=3.9" | ||
| dependencies = [ | ||
| "fastapi>=0.124.4", | ||
| "uvicorn>=0.38.0", |
Copilot
AI
Dec 15, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The minimum version constraint for uvicorn is set to 0.38.0, but this version does not exist. Uvicorn versions are currently in the 0.3x range (e.g., 0.30.x, 0.31.x). This will cause installation failures.
| "uvicorn>=0.38.0", | |
| "uvicorn>=0.30.0", |
|
|
||
|
|
||
| @router.get("/") | ||
| async def root(): |
Copilot
AI
Dec 15, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The root endpoint is defined as async but doesn't perform any asynchronous operations. For consistency with the search endpoint at line 23, which is not async, this should either be made synchronous or the search endpoint should be made async to maintain a consistent pattern.
| async def root(): | |
| def root(): |
| @router.get("/search") | ||
| def search(id: str = Query(..., description="ID to search for")): | ||
| """ | ||
| Search endpoint that takes an ID parameter. | ||
| Args: | ||
| id: The ID to search for (required) | ||
| Returns: | ||
| A dictionary with search results | ||
| """ | ||
| return { | ||
| "query_id": id, | ||
| "status": "success", | ||
| "message": f"Search completed for ID: {id}" | ||
| } |
Copilot
AI
Dec 15, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The search endpoint lacks test coverage. Consider adding tests to verify the endpoint correctly handles valid IDs, missing ID parameters, and different ID formats to ensure the API behaves as expected.
| ### Dependencies | ||
|
|
||
| The application requires: | ||
| - `fastapi` - Web framework | ||
| - `uvicorn[standard]` - ASGI server | ||
| - `minio` - MinIO client for object storage | ||
| - `KBUtilLib` - KBase utility library | ||
|
|
Copilot
AI
Dec 15, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The README documents that 'requirements.txt' manages dependencies, but the project uses pyproject.toml. This creates confusion about the actual dependency management approach. Update the documentation to reflect that pyproject.toml is the source of truth for dependencies.
| RUN apk --no-cache add bash curl | ||
|
|
||
| ENTRYPOINT ["sleep 1d"] | ||
| FROM ghcr.io/astral-sh/uv:python3.13-alpine |
Copilot
AI
Dec 15, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The Dockerfile uses Python 3.13, while pyproject.toml specifies requires-python >= 3.9. Consider aligning these to use a more widely-adopted Python version like 3.11 or 3.12, as Python 3.13 is relatively new and may have compatibility issues with some dependencies.
| FROM ghcr.io/astral-sh/uv:python3.13-alpine | |
| FROM ghcr.io/astral-sh/uv:python3.12-alpine |
Adds a FastAPI service with Docker deployment using uv package manager, implementing a search endpoint that accepts ID parameters.
Application Structure
create_app()inapp/main.pyinstantiates the FastAPI applicationapp/routes.pyusingAPIRouterGET /- Service health/infoGET /search?id=<id>- Search by IDDocker Setup
ghcr.io/astral-sh/uv:python3.14-alpineDependencies
Managed through both
requirements.txtandpyproject.toml:Original prompt
💬 We'd love your input! Share your thoughts on Copilot coding agent in our 2 minute survey.