Modernize tutorial for async EnvClient API#897
Open
vedthebear wants to merge 1 commit into
Open
Conversation
The tutorial referenced the removed HTTP-based `HTTPEnvClient` and a synchronous HTTP POST/GET transport. Update everything to the current API so the tutorial matches how OpenEnv works today. - Client: `HTTPEnvClient[Act, Obs]` -> async `EnvClient[Act, Obs, State]` with all three hooks (`_step_payload`, `_parse_result`, `_parse_state`). - Transport: HTTP POST/GET wording -> WebSocket (client speaks the OpenEnv protocol over a persistent WebSocket session). - Server: `create_fastapi_app(instance)` -> `create_app(EnvClass, Action, Observation, env_name=...)`. - Models: dataclasses -> Pydantic models that only add fields on top of the Observation/State bases. - Imports: `from core.*` / `core.types` -> `openenv.core.*` / `openenv.core.client_types`. - Notebook uses top-level `await` (Jupyter) with a note on `asyncio.run` / `.sync()`; unsloth_2048 and the TextArena training doc use the synchronous `.sync()` wrapper since GRPOTrainer calls the rollout function synchronously. - Cleared stale notebook outputs (including a broken sync traceback).
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
The
tutorial/content had drifted from the current OpenEnv API — it referenced the removedHTTPEnvClientand a synchronous HTTP POST/GET client. This PR updates the tutorial (notebook + markdown) to match how OpenEnv actually works today.HTTPEnvClient[Act, Obs]-> asyncEnvClient[Act, Obs, State]with all three hooks (_step_payload,_parse_result,_parse_state).env.reset()->await env.reset()in the notebook (Jupyter top-level await), with a note onasyncio.run(...)and the.sync()wrapper. Docs/notebooks that run inside synchronous training loops (unsloth_2048,04-training,03-scaling) use the.sync()wrapper since GRPOTrainer calls the rollout function synchronously.02-deployment.mdis left intact — those endpoints do exist in simulation mode.)create_fastapi_app(instance)->create_app(EnvClass, Action, Observation, env_name=...)(factory + type contracts).Observation/Statebases; field reflection switched fromdataclasses.fields()to.model_fields.from core.*/core.types->openenv.core.*/openenv.core.client_types.Test plan
OpenEnv_Tutorial.ipynbandunsloth_2048.ipynbare valid JSON.OpenEnv_Tutorial.ipynbruns top-to-bottom vianbconvert --executeagainst a live OpenSpiel server — 0 error outputs, real Catch episode + 50-episode policy showdown complete.EnvClient.resetis a coroutine and.sync()exists.HTTPEnvClient,http_env_client,create_fastapi_app,core.types)..md/.ipynbchanged — no Python sources touched.Made with Cursor