krishnachoudhary-hclguvi commited on
Reorganize project structure to match openenv-course multi-mode deployment guidelines
Browse files- Dockerfile +3 -11
- inference.py +1 -1
- openenv-course +1 -0
- pyproject.toml +7 -0
- server/__pycache__/environment.cpython-313.pyc +0 -0
- app.py → server/app.py +6 -4
- code_review_env.py → server/environment.py +2 -2
- uv.lock +0 -0
Dockerfile
CHANGED
|
@@ -1,29 +1,21 @@
|
|
| 1 |
-
# Use an official Python runtime as a parent image
|
| 2 |
FROM python:3.10-slim
|
| 3 |
|
| 4 |
-
# Set environment variables to avoid writing .pyc files and buffer stdout
|
| 5 |
ENV PYTHONDONTWRITEBYTECODE=1
|
| 6 |
ENV PYTHONUNBUFFERED=1
|
| 7 |
|
| 8 |
-
# Hugging Face Spaces requires running as a non-root user
|
| 9 |
RUN useradd -m -u 1000 user
|
| 10 |
USER user
|
| 11 |
|
| 12 |
-
# Set up the home directory and path
|
| 13 |
ENV HOME=/home/user \
|
| 14 |
PATH=/home/user/.local/bin:$PATH
|
| 15 |
|
| 16 |
-
# Set the working directory inside the container
|
| 17 |
WORKDIR $HOME/app
|
| 18 |
|
| 19 |
-
# Copy the current directory contents into the container and set ownership
|
| 20 |
COPY --chown=user:user . $HOME/app
|
| 21 |
|
| 22 |
-
|
| 23 |
-
RUN
|
| 24 |
|
| 25 |
-
# Expose port 7860 (Hugging Face Spaces default)
|
| 26 |
EXPOSE 7860
|
| 27 |
|
| 28 |
-
|
| 29 |
-
CMD ["uvicorn", "app:app", "--host", "0.0.0.0", "--port", "7860"]
|
|
|
|
|
|
|
| 1 |
FROM python:3.10-slim
|
| 2 |
|
|
|
|
| 3 |
ENV PYTHONDONTWRITEBYTECODE=1
|
| 4 |
ENV PYTHONUNBUFFERED=1
|
| 5 |
|
|
|
|
| 6 |
RUN useradd -m -u 1000 user
|
| 7 |
USER user
|
| 8 |
|
|
|
|
| 9 |
ENV HOME=/home/user \
|
| 10 |
PATH=/home/user/.local/bin:$PATH
|
| 11 |
|
|
|
|
| 12 |
WORKDIR $HOME/app
|
| 13 |
|
|
|
|
| 14 |
COPY --chown=user:user . $HOME/app
|
| 15 |
|
| 16 |
+
RUN pip install --no-cache-dir -r requirements.txt uv
|
| 17 |
+
RUN uv sync --no-install-project
|
| 18 |
|
|
|
|
| 19 |
EXPOSE 7860
|
| 20 |
|
| 21 |
+
CMD ["python", "server/app.py"]
|
|
|
inference.py
CHANGED
|
@@ -2,7 +2,7 @@ import os
|
|
| 2 |
import sys
|
| 3 |
import traceback
|
| 4 |
from openai import OpenAI
|
| 5 |
-
from
|
| 6 |
|
| 7 |
# -------------------------------------------------------------------
|
| 8 |
# Configuration & Environment Variables
|
|
|
|
| 2 |
import sys
|
| 3 |
import traceback
|
| 4 |
from openai import OpenAI
|
| 5 |
+
from server.environment import CodeReviewEnv
|
| 6 |
|
| 7 |
# -------------------------------------------------------------------
|
| 8 |
# Configuration & Environment Variables
|
openenv-course
ADDED
|
@@ -0,0 +1 @@
|
|
|
|
|
|
|
| 1 |
+
Subproject commit 5a1e6f26e8780f7e5793b7d8ceff212b2381e1c6
|
pyproject.toml
ADDED
|
@@ -0,0 +1,7 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
[project]
|
| 2 |
+
name = "openenv-code-review"
|
| 3 |
+
version = "1.0.0"
|
| 4 |
+
requires-python = ">=3.10"
|
| 5 |
+
dependencies = ["openenv-core>=0.2.0"]
|
| 6 |
+
[project.scripts]
|
| 7 |
+
server = "server.app:main"
|
server/__pycache__/environment.cpython-313.pyc
ADDED
|
Binary file (6.14 kB). View file
|
|
|
app.py → server/app.py
RENAMED
|
@@ -1,7 +1,6 @@
|
|
| 1 |
from fastapi import FastAPI, HTTPException
|
| 2 |
from pydantic import BaseModel
|
| 3 |
-
from
|
| 4 |
-
from code_review_env import CodeReviewEnv
|
| 5 |
|
| 6 |
app = FastAPI(title="OpenEnv Code Review Space")
|
| 7 |
|
|
@@ -50,6 +49,9 @@ def state():
|
|
| 50 |
"correct_comments": _env.correct_comments
|
| 51 |
}
|
| 52 |
|
| 53 |
-
|
| 54 |
import uvicorn
|
| 55 |
-
uvicorn.run("app:app", host="0.0.0.0", port=7860)
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
from fastapi import FastAPI, HTTPException
|
| 2 |
from pydantic import BaseModel
|
| 3 |
+
from server.environment import CodeReviewEnv
|
|
|
|
| 4 |
|
| 5 |
app = FastAPI(title="OpenEnv Code Review Space")
|
| 6 |
|
|
|
|
| 49 |
"correct_comments": _env.correct_comments
|
| 50 |
}
|
| 51 |
|
| 52 |
+
def main():
|
| 53 |
import uvicorn
|
| 54 |
+
uvicorn.run("server.app:app", host="0.0.0.0", port=7860)
|
| 55 |
+
|
| 56 |
+
if __name__ == "__main__":
|
| 57 |
+
main()
|
code_review_env.py → server/environment.py
RENAMED
|
@@ -59,7 +59,7 @@ class CodeReviewEnv:
|
|
| 59 |
enumerated_lines = [f"{i+1} | {line}" for i, line in enumerate(buggy_code_raw.split('\n'))]
|
| 60 |
buggy_code = '\n'.join(enumerated_lines)
|
| 61 |
|
| 62 |
-
observation = f
|
| 63 |
|
| 64 |
{buggy_code}
|
| 65 |
|
|
@@ -67,7 +67,7 @@ Available actions:
|
|
| 67 |
1. COMMENT <line_number> <issue_description>
|
| 68 |
2. APPROVE
|
| 69 |
3. REQUEST_CHANGES
|
| 70 |
-
|
| 71 |
return observation
|
| 72 |
|
| 73 |
def step(self, action):
|
|
|
|
| 59 |
enumerated_lines = [f"{i+1} | {line}" for i, line in enumerate(buggy_code_raw.split('\n'))]
|
| 60 |
buggy_code = '\n'.join(enumerated_lines)
|
| 61 |
|
| 62 |
+
observation = f"""You are a strict code reviewer. Please review the following code identifying any bugs. Note that line numbers are provided on the left.
|
| 63 |
|
| 64 |
{buggy_code}
|
| 65 |
|
|
|
|
| 67 |
1. COMMENT <line_number> <issue_description>
|
| 68 |
2. APPROVE
|
| 69 |
3. REQUEST_CHANGES
|
| 70 |
+
"""
|
| 71 |
return observation
|
| 72 |
|
| 73 |
def step(self, action):
|
uv.lock
ADDED
|
The diff for this file is too large to render.
See raw diff
|
|
|