This commit is contained in:
Jade Choghari
2025-12-08 12:21:41 +01:00
parent 0a10d377b5
commit a811945336
2 changed files with 0 additions and 69 deletions
-14
View File
@@ -1,14 +0,0 @@
# Copyright 2024 The HuggingFace Inc. team. All rights reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
-55
View File
@@ -1,55 +0,0 @@
# env.py - Upload this to your Hub repository
# Example: huggingface.co/your-username/test-kwargs-env
import gymnasium as gym
from gymnasium.vector import SyncVectorEnv
def make_env(
n_envs=1,
use_async_envs=False,
config_path=None,
config_overrides=None,
**kwargs,
):
"""
Create vectorized CartPole environments with configurable options.
Args:
n_envs: Number of parallel environments
use_async_envs: Whether to use AsyncVectorEnv or SyncVectorEnv
config_path: Optional path to a config file (for demonstration)
config_overrides: Optional dict of config overrides
**kwargs: Additional configuration options
Returns:
dict mapping suite name to task environments
"""
# Merge all config sources for demonstration
config = {}
if config_overrides:
config.update(config_overrides)
config.update(kwargs)
# Store config in a way the test can verify
# In a real env, you'd use these to configure the simulation
stored_config = {
"config_path": config_path,
"config_overrides": config_overrides,
"extra_kwargs": kwargs,
}
def _mk():
env = gym.make("CartPole-v1")
# Attach config to env for test verification
env.hub_config = stored_config
return env
Vec = gym.vector.AsyncVectorEnv if use_async_envs else SyncVectorEnv
vec_env = Vec([_mk for _ in range(n_envs)])
# Also attach to vector env for easy access in tests
vec_env.hub_config = stored_config
return {"cartpole_suite": {0: vec_env}}