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

Function test

webarena/run.py:221–394  ·  view source on GitHub ↗
(
    args: argparse.Namespace,
    agent: Agent | PromptAgent | TeacherForcingAgent,
    config_file_list: list[str],
)

Source from the content-addressed store, hash-verified

219
220
221def test(
222 args: argparse.Namespace,
223 agent: Agent | PromptAgent | TeacherForcingAgent,
224 config_file_list: list[str],
225) -> None:
226 scores = []
227 max_steps = args.max_steps
228
229 early_stop_thresholds = {
230 "parsing_failure": args.parsing_failure_th,
231 "repeating_action": args.repeating_action_failure_th,
232 }
233
234 env = ScriptBrowserEnv(
235 headless=not args.render,
236 slow_mo=args.slow_mo,
237 observation_type=args.observation_type,
238 current_viewport_only=args.current_viewport_only,
239 viewport_size={
240 "width": args.viewport_width,
241 "height": args.viewport_height,
242 },
243 save_trace_enabled=args.save_trace_enabled,
244 sleep_after_execution=args.sleep_after_execution,
245 )
246
247 for config_file in tqdm(config_file_list):
248 try:
249 # if True:
250 # render_helper = RenderHelper(
251 # config_file, args.result_dir, args.action_set_tag
252 # )
253
254 # get intent
255 with open(config_file) as f:
256 _c = json.load(f)
257 intent = _c["intent"]
258 task_id = _c["task_id"]
259 # automatically login
260 if _c["storage_state"]:
261 cookie_file_name = os.path.basename(_c["storage_state"])
262 comb = get_site_comb_from_filepath(cookie_file_name)
263 temp_dir = tempfile.mkdtemp()
264 # subprocess to renew the cookie
265 subprocess.run(
266 [
267 "python",
268 "browser_env/auto_login.py",
269 "--auth_folder",
270 temp_dir,
271 "--site_list",
272 *comb,
273 ]
274 )
275 _c["storage_state"] = f"{temp_dir}/{cookie_file_name}"
276 assert os.path.exists(_c["storage_state"])
277 # update the config file
278 config_file = f"{temp_dir}/{os.path.basename(config_file)}"

Callers 1

run.pyFile · 0.85

Calls 13

resetMethod · 0.95
stepMethod · 0.95
get_page_clientMethod · 0.95
closeMethod · 0.95
ScriptBrowserEnvClass · 0.90
create_stop_actionFunction · 0.90
get_action_descriptionFunction · 0.90
evaluator_routerFunction · 0.90
early_stopFunction · 0.85
resetMethod · 0.45
constructMethod · 0.45

Tested by

no test coverage detected