Spaces:
Sleeping
Sleeping
Upload 18 files
#3
by aryanpatel - opened
- Dockerfile +1 -1
- README.md +1 -1
- app.py +49 -0
- dataset.csv +0 -0
- openenv.yaml +1 -1
- pre_submission_validate.py +1 -1
- pyproject.toml +2 -2
Dockerfile
CHANGED
|
@@ -13,4 +13,4 @@ COPY . /app
|
|
| 13 |
|
| 14 |
EXPOSE 8000
|
| 15 |
|
| 16 |
-
CMD ["uvicorn", "
|
|
|
|
| 13 |
|
| 14 |
EXPOSE 8000
|
| 15 |
|
| 16 |
+
CMD ["uvicorn", "app:app", "--host", "0.0.0.0", "--port", "8000"]
|
README.md
CHANGED
|
@@ -83,7 +83,7 @@ pip install -r requirements.txt
|
|
| 83 |
Run server locally:
|
| 84 |
|
| 85 |
```bash
|
| 86 |
-
uvicorn
|
| 87 |
```
|
| 88 |
|
| 89 |
Run baseline inference:
|
|
|
|
| 83 |
Run server locally:
|
| 84 |
|
| 85 |
```bash
|
| 86 |
+
uvicorn app:app --host 0.0.0.0 --port 8000
|
| 87 |
```
|
| 88 |
|
| 89 |
Run baseline inference:
|
app.py
ADDED
|
@@ -0,0 +1,49 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
from __future__ import annotations
|
| 2 |
+
|
| 3 |
+
from importlib.util import module_from_spec, spec_from_file_location
|
| 4 |
+
from pathlib import Path
|
| 5 |
+
|
| 6 |
+
from openenv.core.env_server.http_server import create_app
|
| 7 |
+
|
| 8 |
+
from models import SupportAction, SupportObservation
|
| 9 |
+
|
| 10 |
+
|
| 11 |
+
def _load_environment_class():
|
| 12 |
+
try:
|
| 13 |
+
from server.customer_support_environment import CustomerSupportEnvironment
|
| 14 |
+
|
| 15 |
+
return CustomerSupportEnvironment
|
| 16 |
+
except ModuleNotFoundError:
|
| 17 |
+
# Fallback for runtimes where package-style imports are not resolved.
|
| 18 |
+
env_file = Path(__file__).resolve().parent / "server" / "customer_support_environment.py"
|
| 19 |
+
if not env_file.exists():
|
| 20 |
+
raise
|
| 21 |
+
|
| 22 |
+
spec = spec_from_file_location("customer_support_environment", env_file)
|
| 23 |
+
if spec is None or spec.loader is None:
|
| 24 |
+
raise RuntimeError("Unable to load customer_support_environment module")
|
| 25 |
+
|
| 26 |
+
module = module_from_spec(spec)
|
| 27 |
+
spec.loader.exec_module(module)
|
| 28 |
+
return module.CustomerSupportEnvironment
|
| 29 |
+
|
| 30 |
+
|
| 31 |
+
CustomerSupportEnvironment = _load_environment_class()
|
| 32 |
+
|
| 33 |
+
app = create_app(
|
| 34 |
+
CustomerSupportEnvironment,
|
| 35 |
+
SupportAction,
|
| 36 |
+
SupportObservation,
|
| 37 |
+
env_name="customer_support_benchmark",
|
| 38 |
+
max_concurrent_envs=2,
|
| 39 |
+
)
|
| 40 |
+
|
| 41 |
+
|
| 42 |
+
def main(host: str = "0.0.0.0", port: int = 8000) -> None:
|
| 43 |
+
import uvicorn
|
| 44 |
+
|
| 45 |
+
uvicorn.run(app, host=host, port=port)
|
| 46 |
+
|
| 47 |
+
|
| 48 |
+
if __name__ == "__main__":
|
| 49 |
+
main()
|
dataset.csv
CHANGED
|
The diff for this file is too large to render.
See raw diff
|
|
|
openenv.yaml
CHANGED
|
@@ -2,5 +2,5 @@ spec_version: 1
|
|
| 2 |
name: customer_support_benchmark
|
| 3 |
type: space
|
| 4 |
runtime: fastapi
|
| 5 |
-
app:
|
| 6 |
port: 8000
|
|
|
|
| 2 |
name: customer_support_benchmark
|
| 3 |
type: space
|
| 4 |
runtime: fastapi
|
| 5 |
+
app: app:app
|
| 6 |
port: 8000
|
pre_submission_validate.py
CHANGED
|
@@ -59,7 +59,7 @@ def _check_openenv_validate() -> bool:
|
|
| 59 |
|
| 60 |
def _check_reset_ping(port: int = 8000) -> bool:
|
| 61 |
python_bin = sys.executable
|
| 62 |
-
cmd = [python_bin, "-m", "uvicorn", "
|
| 63 |
proc = subprocess.Popen(
|
| 64 |
cmd,
|
| 65 |
cwd=str(ROOT),
|
|
|
|
| 59 |
|
| 60 |
def _check_reset_ping(port: int = 8000) -> bool:
|
| 61 |
python_bin = sys.executable
|
| 62 |
+
cmd = [python_bin, "-m", "uvicorn", "app:app", "--host", "127.0.0.1", "--port", str(port)]
|
| 63 |
proc = subprocess.Popen(
|
| 64 |
cmd,
|
| 65 |
cwd=str(ROOT),
|
pyproject.toml
CHANGED
|
@@ -17,10 +17,10 @@ dependencies = [
|
|
| 17 |
]
|
| 18 |
|
| 19 |
[project.scripts]
|
| 20 |
-
server = "
|
| 21 |
|
| 22 |
[tool.setuptools]
|
| 23 |
-
py-modules = ["models", "tasks", "data_loader", "kb", "client", "inference"]
|
| 24 |
|
| 25 |
[tool.setuptools.packages.find]
|
| 26 |
include = ["server", "server.*"]
|
|
|
|
| 17 |
]
|
| 18 |
|
| 19 |
[project.scripts]
|
| 20 |
+
server = "app:main"
|
| 21 |
|
| 22 |
[tool.setuptools]
|
| 23 |
+
py-modules = ["app", "models", "tasks", "data_loader", "kb", "client", "inference"]
|
| 24 |
|
| 25 |
[tool.setuptools.packages.find]
|
| 26 |
include = ["server", "server.*"]
|