Skip to content

Commit 4762c2d

Browse files
authored
SWEEnv.from_dict() (#278)
* fix controlling the n_parallel_agents and the concurrent env operations * fix controlling the n_parallel_agents and the concurrent env operations * fix controlling the n_parallel_agents and the concurrent env operations * applied pre-commit, fixed unused-import * Added ThreadPoolExecutor in excute_tasks(); if not hasattr(self, "executor") * renaming max_workers to max_env_workers * Fixing SWEEnv.from_dict
1 parent 40c886c commit 4762c2d

File tree

1 file changed

+16
-2
lines changed

1 file changed

+16
-2
lines changed

rllm/environments/swe/swe.py

Lines changed: 16 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -164,11 +164,25 @@ def from_dict(extra_info: dict | str) -> "SWEEnv":
164164
"""Create an environment instance from JSON configuration.
165165
166166
Args:
167-
extra_info: Dictionary containing configuration parameters
167+
extra_info: Dictionary containing configuration parameters.
168+
The entire dict will be used as 'entry', and any keys
169+
matching __init__ parameters will be extracted and passed.
168170
169171
Returns:
170172
Initialized SWEEnv instance
171173
"""
174+
import inspect
175+
172176
if isinstance(extra_info, str):
173177
extra_info = json.loads(extra_info)
174-
return SWEEnv(entry=extra_info)
178+
179+
sig = inspect.signature(SWEEnv.__init__)
180+
init_params = {}
181+
for param_name, param in sig.parameters.items():
182+
if param_name == "self":
183+
continue
184+
if param_name in extra_info:
185+
init_params[param_name] = extra_info[param_name]
186+
# else if param has default value, use the default value
187+
init_params["entry"] = extra_info
188+
return SWEEnv(**init_params)

0 commit comments

Comments
 (0)