sync: pull latest from main (model_server.py, captain LLM toggle in ui.py, 0.6B configs, SUBMISSION + RUNTIME_DURABILITY docs)
e70c305 verified | try: | |
| from openenv.core.env_server.http_server import create_app | |
| except Exception as e: | |
| raise ImportError( | |
| "openenv-core is required. Install with: pip install 'openenv-core[core]>=0.2.2'" | |
| ) from e | |
| try: | |
| from models import CricketAction, CricketObservation | |
| from server.cricket_environment import CricketEnvironment | |
| from server.custom_routes import install_custom_routes | |
| from server.ui import build_ui | |
| except (ImportError, ModuleNotFoundError): | |
| import sys | |
| import os | |
| sys.path.append(os.path.abspath(os.path.join(os.path.dirname(__file__), ".."))) | |
| from models import CricketAction, CricketObservation | |
| from server.cricket_environment import CricketEnvironment | |
| from server.custom_routes import install_custom_routes | |
| from server.ui import build_ui | |
| def build_app(): | |
| app = create_app( | |
| CricketEnvironment, | |
| CricketAction, | |
| CricketObservation, | |
| env_name="cricket_captain", | |
| max_concurrent_envs=4, | |
| gradio_builder=build_ui, | |
| ) | |
| install_custom_routes(app) | |
| return app | |
| # Exported for `openenv.yaml` (`server.app:app`). Uses current env vars. | |
| app = build_app() | |
| def main(host: str = "0.0.0.0", port: int = 8000): | |
| import argparse | |
| import uvicorn | |
| parser = argparse.ArgumentParser(description="CricketCaptain OpenEnv Server") | |
| parser.add_argument("--host", default=host) | |
| parser.add_argument("--port", type=int, default=port) | |
| parser.add_argument("--config", default=None, help="YAML config path (sets server defaults).") | |
| args = parser.parse_args() | |
| if args.config: | |
| try: | |
| from config_yaml import load_config, apply_server_config_to_env | |
| except ImportError: | |
| from cricket_captain.config_yaml import load_config, apply_server_config_to_env | |
| apply_server_config_to_env(load_config(args.config)) | |
| uvicorn.run(build_app(), host=args.host, port=args.port) | |
| if __name__ == "__main__": | |
| main() | |