Gitrew / server /app.py
at0day's picture
Update server/app.py
e1f3172 verified
Raw History Blame Contribute Delete
2.12 kB
try:
from openenv.core.env_server.http_server import create_app
except Exception as e: # pragma: no cover
raise ImportError(
"openenv is required for the web interface. Install dependencies with '\n uv sync\n'"
) from e
try:
from ..models import GitCommitReviewerAction, GitCommitReviewerObservation
from .git_commit_reviewer_environment import GitCommitReviewerEnvironment
except (ImportError, ValueError):
try:
from models import GitCommitReviewerAction, GitCommitReviewerObservation
from server.git_commit_reviewer_environment import GitCommitReviewerEnvironment
except ImportError:
import sys
import os
sys.path.append(os.getcwd())
from models import GitCommitReviewerAction, GitCommitReviewerObservation
from server.git_commit_reviewer_environment import GitCommitReviewerEnvironment
# Create the app with web interface and README integration
app = create_app(
GitCommitReviewerEnvironment,
GitCommitReviewerAction,
GitCommitReviewerObservation,
env_name="git_commit_reviewer",
max_concurrent_envs=10, # increased to allow automated sequential runs
)
@app.get("/")
async def root():
return {
"message": "Git Commit Reviewer Environment is running!",
"status": "healthy",
"docs": "/docs"
}
@app.get("/health")
async def health():
return {"status": "ok"}
def main(host: str = "0.0.0.0", port: int = 7860):
"""
Entry point for direct execution via uv run or python -m.
This function enables running the server without Docker:
uv run --project . server
uv run --project . server --port 7861
python -m git_commit_reviewer.server.app
Args:
host: Host address to bind to (default: "0.0.0.0")
port: Port number to listen on (default: 7860)
For production deployments, consider using uvicorn directly with
multiple workers:
uvicorn git_commit_reviewer.server.app:app --workers 4
"""
import uvicorn
uvicorn.run(app, host=host, port=port)
if __name__ == '__main__':
main()