hospital-ed / app.py
testingaccc's picture
Upload folder using huggingface_hub
0fe00d1 verified
Raw
History Blame Contribute Delete
1.54 kB
"""OpenEnv FastAPI application entry point.
This is the file the hackathon judges' OpenEnv client (and any other
EnvClient consumer) will talk to. It builds a FastAPI app via
:func:`openenv.core.create_app`, which wires up:
* ``/health`` β€” liveness check.
* ``/reset`` β€” start a new episode.
* ``/step`` β€” apply an action.
* ``/state`` β€” inspect current episode state.
* ``/schema`` β€” JSON schemas for action / observation / state.
* ``/metadata`` β€” environment metadata (name, description, version).
* WebSocket ``/ws`` β€” interactive session protocol.
* (Optional) ``/web`` β€” Gradio debug UI when ``ENABLE_WEB_INTERFACE=true``.
Run with::
uvicorn app:app --host 0.0.0.0 --port 8000
Or via the Docker default ``CMD``::
docker build -t hospital-env .
docker run --rm -p 8000:8000 hospital-env
Override the scenario per container by setting the
``HOSPITAL_SCENARIO`` env var (one of ``normal_day``, ``surge``,
``mass_casualty``, ``night_shift``, ``ventilator_crisis``)::
docker run --rm -p 8000:8000 -e HOSPITAL_SCENARIO=surge hospital-env
"""
from __future__ import annotations
from openenv.core import create_app
from hospital_env import (
HospitalAction,
HospitalObservation,
hospital_env_factory,
)
# The OpenEnv framework discovers the app via the ASGI standard
# ``app:app`` import path, so this name is required.
app = create_app(
env=hospital_env_factory,
action_cls=HospitalAction,
observation_cls=HospitalObservation,
env_name="hospital-resource-allocator",
)