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

Method reset

webarena/browser_env/envs.py:187–226  ·  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

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

Callers 3

testFunction · 0.95
get_observationFunction · 0.95
test_auth_cookieFunction · 0.95

Calls 5

setupMethod · 0.95
modify_pageMethod · 0.95
_get_obsMethod · 0.95
_get_obs_metadataMethod · 0.95
DetachedPageClass · 0.85

Tested by 1

test_auth_cookieFunction · 0.76