"""FastAPI application for the Hospital ED OpenEnv environment. This is the entry point the OpenEnv framework, the judges' test client, and ``openenv validate`` all look for. It must satisfy: * File path ``server/app.py`` (checked by ``openenv validate``). * A module-level FastAPI instance named ``app``. * A module-level ``def main(...)`` function that runs the server. * An ``if __name__ == "__main__": main()`` block. The app itself is built via :func:`openenv.core.create_app` wrapping :class:`hospital_env.openenv_env.HospitalOpenEnv`, which subclasses :class:`openenv.core.Environment`. """ from __future__ import annotations import argparse from openenv.core import create_app from hospital_env.openenv_env import HospitalOpenEnv from hospital_env.openenv_types import HospitalAction, HospitalObservation # Create the FastAPI app. Passing the class directly (instead of a # factory) lets create_app() instantiate a fresh env per session. app = create_app( env=HospitalOpenEnv, action_cls=HospitalAction, observation_cls=HospitalObservation, env_name="hospital_ed", max_concurrent_envs=1, ) def main(host: str = "0.0.0.0", port: int = 8000) -> None: """Run the FastAPI server with uvicorn. This is the entry point referenced by ``[project.scripts] server`` in ``pyproject.toml`` and invoked by ``uv run server``. Args: host: Host address to bind to. port: Port number to listen on. """ import uvicorn uvicorn.run(app, host=host, port=port) if __name__ == "__main__": parser = argparse.ArgumentParser(description="Hospital ED OpenEnv server") parser.add_argument("--host", default="0.0.0.0") parser.add_argument("--port", type=int, default=8000) args = parser.parse_args() main(host=args.host, port=args.port)