sotopia-lab / sotopia

Sotopia: an Open-ended Social Learning Environment (ICLR 2024 spotlight)
https://docs.sotopia.world
MIT License
166 stars 21 forks source link

Fix: add check for JsonModel #211

Closed yufansong closed 1 month ago

yufansong commented 1 month ago

When I try python examples/minimalist_demo.py will meet error. The key reason should be forget the config value in redis. Add some check for better error prompt.

The following is the error bug

    https://beartype.readthedocs.io/en/latest/api_roar/#pep-585-deprecations
  warn(
Traceback (most recent call last):
  File "/home/yufansong/sotopia/examples/minimalist_demo.py", line 27, in <module>
    asyncio.run(
  File "/home/yufansong/miniconda3/envs/bridge/lib/python3.11/asyncio/runners.py", line 190, in run
    return runner.run(main)
           ^^^^^^^^^^^^^^^^
  File "/home/yufansong/miniconda3/envs/bridge/lib/python3.11/asyncio/runners.py", line 118, in run
    return self._loop.run_until_complete(task)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/yufansong/miniconda3/envs/bridge/lib/python3.11/asyncio/base_events.py", line 654, in run_until_complete
    return future.result()
           ^^^^^^^^^^^^^^^
  File "<@beartype(sotopia.server.run_async_server) at 0x7fc7c76bb740>", line 260, in run_async_server
  File "/home/yufansong/miniconda3/envs/bridge/lib/python3.11/site-packages/sotopia/server.py", line 294, in run_async_server
    episode_futures = [
                      ^
  File "/home/yufansong/miniconda3/envs/bridge/lib/python3.11/site-packages/sotopia/server.py", line 294, in <listcomp>
    episode_futures = [
                      ^
  File "/home/yufansong/miniconda3/envs/bridge/lib/python3.11/site-packages/sotopia/samplers/uniform_sampler.py", line 56, in sample
    env_profile = random.choice(self.env_candidates)
                  ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/yufansong/miniconda3/envs/bridge/lib/python3.11/random.py", line 373, in choice
    raise IndexError('Cannot choose from an empty sequence')
IndexError: Cannot choose from an empty sequence

Closes #

📑 Description

✅ Checks

ℹ Additional Information

codecov[bot] commented 1 month ago

Codecov Report

Attention: Patch coverage is 66.66667% with 4 lines in your changes missing coverage. Please review.

Project coverage is 71.49%. Comparing base (2a51167) to head (aec1d2b). Report is 1 commits behind head on main.

Files with missing lines Patch % Lines
sotopia/samplers/uniform_sampler.py 57.14% 3 Missing :warning:
sotopia/samplers/constraint_based_sampler.py 80.00% 1 Missing :warning:
@@            Coverage Diff             @@
##             main     #211      +/-   ##
==========================================
- Coverage   71.53%   71.49%   -0.04%     
==========================================
  Files          55       55              
  Lines        2863     2863              
==========================================
- Hits         2048     2047       -1     
- Misses        815      816       +1     
Files with missing lines Coverage Δ
sotopia/samplers/constraint_based_sampler.py 90.90% <80.00%> (ø)
sotopia/samplers/uniform_sampler.py 84.84% <57.14%> (ø)

... and 1 file with indirect coverage changes