MCPcopy Create free account
hub / github.com/THUDM/AgentTuning / reset

Method reset

eval_heldout/webarena/browser_env/envs.py:192–228  ·  view source on GitHub ↗

Reset the environment. :param options: options for the environment. The current supported options are: - "storage_state": the storage state of the browser. It is a file path to a json file.

(
        self,
        *,
        seed: int | None = None,
        options: dict[str, str] | None = None,
    )

Source from the content-addressed store, hash-verified

190
191 @beartype
192 def reset(
193 self,
194 *,
195 seed: int | None = None,
196 options: dict[str, str] | None = None,
197 ) -> tuple[dict[str, Observation], dict[str, Any]]:
198 """
199 Reset the environment.
200 :param options: options for the environment. The current supported options are:
201 - "storage_state": the storage state of the browser. It is a file path to a json file.
202 """
203 super().reset(seed=seed, options=options)
204 if self.reset_finished:
205 self.context_manager.__exit__()
206
207 if options is not None and "config_file" in options:
208 config_file = Path(options["config_file"])
209 if config_file.exists():
210 self.setup(config_file=config_file)
211 else:
212 raise ValueError(f"Config file {config_file} does not exist.")
213 else:
214 self.setup()
215 self.reset_finished = True
216
217 if self.sleep_after_execution > 0:
218 time.sleep(self.sleep_after_execution)
219
220 observation = self._get_obs()
221 observation_metadata = self._get_obs_metadata()
222 info = {
223 "page": DetachedPage(self.page.url, ""),
224 "fail_error": "",
225 "observation_metadata": observation_metadata,
226 }
227
228 return (observation, info)
229
230 @beartype
231 def save_trace(self, trace_path: str | Path) -> None:

Callers 1

testFunction · 0.95

Calls 6

setupMethod · 0.95
_get_obsMethod · 0.95
_get_obs_metadataMethod · 0.95
DetachedPageClass · 0.85
PathClass · 0.50
__exit__Method · 0.45

Tested by

no test coverage detected