Spaces:
No application file
No application file
Sandeep Suresh commited on
Commit ·
0b9509b
1
Parent(s): d95de8e
feat: Add CI workflows with pre-submit validation and update pytest dependencies
Browse files- .github/workflows/pre-submit.yml +53 -0
- .github/workflows/pytest.yml +1 -1
- client.py +4 -1
- inference.py +4 -8
.github/workflows/pre-submit.yml
ADDED
|
@@ -0,0 +1,53 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
name: pre-submit CI
|
| 2 |
+
|
| 3 |
+
on:
|
| 4 |
+
push:
|
| 5 |
+
pull_request:
|
| 6 |
+
|
| 7 |
+
jobs:
|
| 8 |
+
pre-submit:
|
| 9 |
+
runs-on: ubuntu-latest
|
| 10 |
+
|
| 11 |
+
steps:
|
| 12 |
+
- name: Checkout repository
|
| 13 |
+
uses: actions/checkout@v4
|
| 14 |
+
|
| 15 |
+
- name: Set up Python
|
| 16 |
+
uses: actions/setup-python@v5
|
| 17 |
+
with:
|
| 18 |
+
python-version: "3.12"
|
| 19 |
+
|
| 20 |
+
- name: Set up uv
|
| 21 |
+
uses: astral-sh/setup-uv@v4
|
| 22 |
+
|
| 23 |
+
- name: Install dependencies
|
| 24 |
+
run: uv sync --extra dev
|
| 25 |
+
|
| 26 |
+
- name: Start server
|
| 27 |
+
run: |
|
| 28 |
+
uv run server > server.log 2>&1 &
|
| 29 |
+
echo "SERVER_PID=$!" >> "$GITHUB_ENV"
|
| 30 |
+
|
| 31 |
+
- name: Wait for server
|
| 32 |
+
run: |
|
| 33 |
+
for _ in {1..30}; do
|
| 34 |
+
if curl -fsS -X POST http://localhost:8000/reset -H "Content-Type: application/json" -d '{}' >/dev/null; then
|
| 35 |
+
exit 0
|
| 36 |
+
fi
|
| 37 |
+
sleep 2
|
| 38 |
+
done
|
| 39 |
+
echo "Server did not become ready in time"
|
| 40 |
+
cat server.log || true
|
| 41 |
+
exit 1
|
| 42 |
+
|
| 43 |
+
- name: Run pre-submission validator
|
| 44 |
+
run: |
|
| 45 |
+
chmod +x ./pre-submission.sh
|
| 46 |
+
uv run ./pre-submission.sh http://localhost:8000 .
|
| 47 |
+
|
| 48 |
+
- name: Stop server
|
| 49 |
+
if: always()
|
| 50 |
+
run: |
|
| 51 |
+
if [ -n "${SERVER_PID:-}" ]; then
|
| 52 |
+
kill "$SERVER_PID" || true
|
| 53 |
+
fi
|
.github/workflows/pytest.yml
CHANGED
|
@@ -22,7 +22,7 @@ jobs:
|
|
| 22 |
run: |
|
| 23 |
python -m pip install --upgrade pip
|
| 24 |
pip install -r requirements.txt
|
| 25 |
-
pip install pytest
|
| 26 |
|
| 27 |
- name: Run tests
|
| 28 |
run: pytest -q
|
|
|
|
| 22 |
run: |
|
| 23 |
python -m pip install --upgrade pip
|
| 24 |
pip install -r requirements.txt
|
| 25 |
+
pip install pytest pytest-asyncio
|
| 26 |
|
| 27 |
- name: Run tests
|
| 28 |
run: pytest -q
|
client.py
CHANGED
|
@@ -12,7 +12,10 @@ from openenv.core import EnvClient
|
|
| 12 |
from openenv.core.client_types import StepResult
|
| 13 |
from openenv.core.env_server.types import State
|
| 14 |
|
| 15 |
-
|
|
|
|
|
|
|
|
|
|
| 16 |
|
| 17 |
|
| 18 |
class CoEnv(
|
|
|
|
| 12 |
from openenv.core.client_types import StepResult
|
| 13 |
from openenv.core.env_server.types import State
|
| 14 |
|
| 15 |
+
try:
|
| 16 |
+
from .models import CoenvAction, CoenvObservation
|
| 17 |
+
except ImportError:
|
| 18 |
+
from models import CoenvAction, CoenvObservation
|
| 19 |
|
| 20 |
|
| 21 |
class CoEnv(
|
inference.py
CHANGED
|
@@ -50,29 +50,25 @@ from typing import List, Optional
|
|
| 50 |
from openai import OpenAI
|
| 51 |
from models import CoenvAction
|
| 52 |
from client import CoEnv
|
|
|
|
|
|
|
| 53 |
IMAGE_NAME = os.getenv("IMAGE_NAME")
|
| 54 |
API_KEY = os.getenv("HF_TOKEN") or os.getenv("API_KEY")
|
| 55 |
|
| 56 |
API_BASE_URL = os.getenv("API_BASE_URL") or "https://router.huggingface.co/v1"
|
| 57 |
MODEL_NAME = os.getenv("MODEL_NAME") or "Qwen/Qwen2.5-72B-Instruct"
|
| 58 |
-
|
| 59 |
-
BENCHMARK = os.getenv("MY_ENV_V4_BENCHMARK", "my_env_v4")
|
| 60 |
MAX_STEPS = 8
|
| 61 |
TEMPERATURE = 0.7
|
| 62 |
MAX_TOKENS = 150
|
| 63 |
SUCCESS_SCORE_THRESHOLD = 0.1 # normalized score in [0, 1]
|
| 64 |
|
| 65 |
-
# Max possible reward: each token contributes 0.1, across all steps
|
| 66 |
_MAX_REWARD_PER_STEP = MAX_TOKENS * 0.1
|
| 67 |
MAX_TOTAL_REWARD = MAX_STEPS * _MAX_REWARD_PER_STEP
|
| 68 |
|
| 69 |
SYSTEM_PROMPT = textwrap.dedent(
|
| 70 |
"""
|
| 71 |
-
You are interacting with
|
| 72 |
-
Each turn you must send a message. The environment will echo it back.
|
| 73 |
-
Reward is proportional to message length: reward = len(message) * 0.1
|
| 74 |
-
Your goal is to maximize total reward by sending meaningful, substantive messages.
|
| 75 |
-
Reply with exactly one message string — no quotes, no prefixes, just the message text.
|
| 76 |
"""
|
| 77 |
).strip()
|
| 78 |
|
|
|
|
| 50 |
from openai import OpenAI
|
| 51 |
from models import CoenvAction
|
| 52 |
from client import CoEnv
|
| 53 |
+
from dotenv import load_dotenv
|
| 54 |
+
load_dotenv()
|
| 55 |
IMAGE_NAME = os.getenv("IMAGE_NAME")
|
| 56 |
API_KEY = os.getenv("HF_TOKEN") or os.getenv("API_KEY")
|
| 57 |
|
| 58 |
API_BASE_URL = os.getenv("API_BASE_URL") or "https://router.huggingface.co/v1"
|
| 59 |
MODEL_NAME = os.getenv("MODEL_NAME") or "Qwen/Qwen2.5-72B-Instruct"
|
| 60 |
+
ENV_URL = os.getenv("ENV_URL") or "http://localhost:8000"
|
|
|
|
| 61 |
MAX_STEPS = 8
|
| 62 |
TEMPERATURE = 0.7
|
| 63 |
MAX_TOKENS = 150
|
| 64 |
SUCCESS_SCORE_THRESHOLD = 0.1 # normalized score in [0, 1]
|
| 65 |
|
|
|
|
| 66 |
_MAX_REWARD_PER_STEP = MAX_TOKENS * 0.1
|
| 67 |
MAX_TOTAL_REWARD = MAX_STEPS * _MAX_REWARD_PER_STEP
|
| 68 |
|
| 69 |
SYSTEM_PROMPT = textwrap.dedent(
|
| 70 |
"""
|
| 71 |
+
You are an agent interacting with an Kubernetes-like simulation environment.
|
|
|
|
|
|
|
|
|
|
|
|
|
| 72 |
"""
|
| 73 |
).strip()
|
| 74 |
|