Skip to content

Commit

Permalink
Fix warning in quickstart.py (#823)
Browse files Browse the repository at this point in the history
* Fix warning in quickstart.py caused by not properly setting the render mode in the evaluation environment.

* Add workaround for pygame under MacOS

* Fix typo in .circleci/config.yml

Co-authored-by: Adam Gleave <[email protected]>

---------

Co-authored-by: Adam Gleave <[email protected]>
  • Loading branch information
ernestum and AdamGleave committed Dec 12, 2023
1 parent 24a6384 commit ab45b47
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 2 deletions.
4 changes: 4 additions & 0 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -365,6 +365,10 @@ jobs:
TESTFILES=$(circleci tests glob "tests/**/test*.py" | circleci tests split --split-by=timings)
echo "This shard testing: ${TESTFILES}"
pytest -n auto --junitxml=/tmp/test-reports/junit.xml -vv $TESTFILES
environment:
# This is needed in newer versions of pygame. See
# https://github.com/pygame/pygame/issues/3835#issuecomment-1703717368
SDL_VIDEODRIVER: dummy

- save-pytest-cache
- store-test-output-unix
Expand Down
12 changes: 10 additions & 2 deletions examples/quickstart.py
Original file line number Diff line number Diff line change
Expand Up @@ -71,9 +71,16 @@ def sample_expert_transitions():
rng=rng,
)

evaluation_env = make_vec_env(
"seals:seals/CartPole-v0",
rng=rng,
env_make_kwargs={"render_mode": "human"}, # for rendering
)

print("Evaluating the untrained policy.")
reward, _ = evaluate_policy(
bc_trainer.policy, # type: ignore[arg-type]
env,
evaluation_env,
n_eval_episodes=3,
render=True, # comment out to speed up
)
Expand All @@ -82,9 +89,10 @@ def sample_expert_transitions():
print("Training a policy using Behavior Cloning")
bc_trainer.train(n_epochs=1)

print("Evaluating the trained policy.")
reward, _ = evaluate_policy(
bc_trainer.policy, # type: ignore[arg-type]
env,
evaluation_env,
n_eval_episodes=3,
render=True, # comment out to speed up
)
Expand Down

0 comments on commit ab45b47

Please sign in to comment.