MCPcopy Index your code
hub / github.com/microsoft/Webwright / run_one

Function run_one

src/webwright/run/cli.py:31–134  ·  view source on GitHub ↗
(
    *,
    task: str | None = None,
    task_id: str | None = None,
    start_url: str | None = None,
    config_spec: list[str] | None = None,
    output_dir: Path | None = None,
    resolved_output_dir: Path | None = None,
    debug: bool = False,
    snapshot_config: bool = True,
)

Source from the content-addressed store, hash-verified

29
30
31def run_one(
32 *,
33 task: str | None = None,
34 task_id: str | None = None,
35 start_url: str | None = None,
36 config_spec: list[str] | None = None,
37 output_dir: Path | None = None,
38 resolved_output_dir: Path | None = None,
39 debug: bool = False,
40 snapshot_config: bool = True,
41) -> Any:
42 config_spec = config_spec or DEFAULT_CONFIGS
43 configs = [get_config_from_spec(spec) for spec in config_spec]
44 config = recursive_merge(*configs)
45
46 run_config = config.get("run", {})
47 resolved_task_id = task_id or run_config.get("task_id")
48 resolved_task = task or run_config.get("task")
49 resolved_start_url = start_url or run_config.get("start_url")
50
51 if not resolved_task:
52 raise ValueError("A task is required. Use --task.")
53
54 resolved_output_dir = resolved_output_dir or _timestamped_output_dir(
55 output_dir or config.get("environment", {}).get("output_dir") or "outputs",
56 resolved_task_id,
57 )
58 if snapshot_config:
59 snapshot_config_specs(config_spec, resolved_output_dir, merged_config=config)
60
61 config = recursive_merge(
62 config,
63 {
64 "run": {
65 "task": resolved_task,
66 "task_id": resolved_task_id or UNSET,
67 "start_url": resolved_start_url or UNSET,
68 },
69 "environment": {
70 "output_dir": str(resolved_output_dir),
71 "start_url": resolved_start_url or UNSET,
72 "headless": False if debug else UNSET,
73 "devtools": True if debug else UNSET,
74 "keep_open_on_exit": True if debug else UNSET,
75 "prompt_before_close": True if debug else UNSET,
76 "slow_mo_ms": 250 if debug else UNSET,
77 },
78 "model": {
79 "error_log_path": str(resolved_output_dir / "runtime_errors.jsonl"),
80 },
81 "agent": {
82 "output_path": str(resolved_output_dir / "trajectory.json"),
83 },
84 },
85 )
86
87 model = get_model(config.get("model", {}))
88 env = get_environment(config.get("environment", {}))

Callers 1

mainFunction · 0.85

Calls 10

get_config_from_specFunction · 0.90
recursive_mergeFunction · 0.90
snapshot_config_specsFunction · 0.90
get_modelFunction · 0.90
get_environmentFunction · 0.90
get_agentFunction · 0.90
_timestamped_output_dirFunction · 0.85
prepareMethod · 0.45
runMethod · 0.45
closeMethod · 0.45

Tested by

no test coverage detected