Skip to content

Custom Configuration Files w/ Gymnasium API #606

@umutucak

Description

@umutucak

I've gone through the documentation and the source code to the best of my ability but I'm struggling to use configuration files (.cfgs) with the gymnasium API. I build my environment as per the documentation:

env = gym.make("VizdoomBasic-v0", frame_skip=4)

^ This works and builds the default Basic environment. However; when I change the configuration and try to load my own .cfg I can't pass it as an argument:

env = gym.make("basic.cfg", frame_skip=4)

I get the following error:

---------------------------------------------------------------------------
NameNotFound                              Traceback (most recent call last)
Cell In[3], [line 1](vscode-notebook-cell:?execution_count=3&line=1)
----> [1](vscode-notebook-cell:?execution_count=3&line=1) env = gym.make("basic.cfg", frame_skip=4)
      [2](vscode-notebook-cell:?execution_count=3&line=2) env.action_space.n

File [~/Documents/introDL-vizdoom/.venv/lib/python3.9/site-packages/gymnasium/envs/registration.py:689](https://file+.vscode-resource.vscode-cdn.net/Users/ucak/Documents/introDL-vizdoom/~/Documents/introDL-vizdoom/.venv/lib/python3.9/site-packages/gymnasium/envs/registration.py:689), in make(id, max_episode_steps, disable_env_checker, **kwargs)
    [686](https://file+.vscode-resource.vscode-cdn.net/Users/ucak/Documents/introDL-vizdoom/~/Documents/introDL-vizdoom/.venv/lib/python3.9/site-packages/gymnasium/envs/registration.py:686)     assert isinstance(id, str)
    [688](https://file+.vscode-resource.vscode-cdn.net/Users/ucak/Documents/introDL-vizdoom/~/Documents/introDL-vizdoom/.venv/lib/python3.9/site-packages/gymnasium/envs/registration.py:688)     # The environment name can include an unloaded module in "module:env_name" style
--> [689](https://file+.vscode-resource.vscode-cdn.net/Users/ucak/Documents/introDL-vizdoom/~/Documents/introDL-vizdoom/.venv/lib/python3.9/site-packages/gymnasium/envs/registration.py:689)     env_spec = _find_spec(id)
    [691](https://file+.vscode-resource.vscode-cdn.net/Users/ucak/Documents/introDL-vizdoom/~/Documents/introDL-vizdoom/.venv/lib/python3.9/site-packages/gymnasium/envs/registration.py:691) assert isinstance(env_spec, EnvSpec)
    [693](https://file+.vscode-resource.vscode-cdn.net/Users/ucak/Documents/introDL-vizdoom/~/Documents/introDL-vizdoom/.venv/lib/python3.9/site-packages/gymnasium/envs/registration.py:693) # Update the env spec kwargs with the `make` kwargs

File [~/Documents/introDL-vizdoom/.venv/lib/python3.9/site-packages/gymnasium/envs/registration.py:533](https://file+.vscode-resource.vscode-cdn.net/Users/ucak/Documents/introDL-vizdoom/~/Documents/introDL-vizdoom/.venv/lib/python3.9/site-packages/gymnasium/envs/registration.py:533), in _find_spec(env_id)
    [527](https://file+.vscode-resource.vscode-cdn.net/Users/ucak/Documents/introDL-vizdoom/~/Documents/introDL-vizdoom/.venv/lib/python3.9/site-packages/gymnasium/envs/registration.py:527)     logger.warn(
    [528](https://file+.vscode-resource.vscode-cdn.net/Users/ucak/Documents/introDL-vizdoom/~/Documents/introDL-vizdoom/.venv/lib/python3.9/site-packages/gymnasium/envs/registration.py:528)         f"Using the latest versioned environment `{new_env_id}` "
    [529](https://file+.vscode-resource.vscode-cdn.net/Users/ucak/Documents/introDL-vizdoom/~/Documents/introDL-vizdoom/.venv/lib/python3.9/site-packages/gymnasium/envs/registration.py:529)         f"instead of the unversioned environment `{env_name}`."
    [530](https://file+.vscode-resource.vscode-cdn.net/Users/ucak/Documents/introDL-vizdoom/~/Documents/introDL-vizdoom/.venv/lib/python3.9/site-packages/gymnasium/envs/registration.py:530)     )
    [532](https://file+.vscode-resource.vscode-cdn.net/Users/ucak/Documents/introDL-vizdoom/~/Documents/introDL-vizdoom/.venv/lib/python3.9/site-packages/gymnasium/envs/registration.py:532) if env_spec is None:
--> [533](https://file+.vscode-resource.vscode-cdn.net/Users/ucak/Documents/introDL-vizdoom/~/Documents/introDL-vizdoom/.venv/lib/python3.9/site-packages/gymnasium/envs/registration.py:533)     _check_version_exists(ns, name, version)
    [534](https://file+.vscode-resource.vscode-cdn.net/Users/ucak/Documents/introDL-vizdoom/~/Documents/introDL-vizdoom/.venv/lib/python3.9/site-packages/gymnasium/envs/registration.py:534)     raise error.Error(
    [535](https://file+.vscode-resource.vscode-cdn.net/Users/ucak/Documents/introDL-vizdoom/~/Documents/introDL-vizdoom/.venv/lib/python3.9/site-packages/gymnasium/envs/registration.py:535)         f"No registered env with id: {env_name}. Did you register it, or import the package that registers it? Use `gymnasium.pprint_registry()` to see all of the registered environments."
    [536](https://file+.vscode-resource.vscode-cdn.net/Users/ucak/Documents/introDL-vizdoom/~/Documents/introDL-vizdoom/.venv/lib/python3.9/site-packages/gymnasium/envs/registration.py:536)     )
    [538](https://file+.vscode-resource.vscode-cdn.net/Users/ucak/Documents/introDL-vizdoom/~/Documents/introDL-vizdoom/.venv/lib/python3.9/site-packages/gymnasium/envs/registration.py:538) return env_spec
...
--> [376](https://file+.vscode-resource.vscode-cdn.net/Users/ucak/Documents/introDL-vizdoom/~/Documents/introDL-vizdoom/.venv/lib/python3.9/site-packages/gymnasium/envs/registration.py:376) raise error.NameNotFound(
    [377](https://file+.vscode-resource.vscode-cdn.net/Users/ucak/Documents/introDL-vizdoom/~/Documents/introDL-vizdoom/.venv/lib/python3.9/site-packages/gymnasium/envs/registration.py:377)     f"Environment `{name}` doesn't exist{namespace_msg}.{suggestion_msg}"
    [378](https://file+.vscode-resource.vscode-cdn.net/Users/ucak/Documents/introDL-vizdoom/~/Documents/introDL-vizdoom/.venv/lib/python3.9/site-packages/gymnasium/envs/registration.py:378) )

NameNotFound: Environment `basic.cfg` doesn't exist.

Even though the documentation here for gymnasium environment creation says:

Parameters:
        level (str) – The path to the config file to load. Most settings should be set by this config file.

How can I load custom configuration files while using the gymnasium wrapper?

Thanks!

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions