1111from contextlib import contextmanager
1212from pathlib import Path
1313from textwrap import dedent
14+ from time import sleep
1415from typing import TYPE_CHECKING , Any , Literal
1516
1617import jsonschema
2526
2627
2728@contextmanager
28- def browser_context () -> Generator [any , None , None ]:
29+ def _browser_context () -> Generator [Any , None , None ]:
2930 with sync_playwright () as p :
3031 browser = p .chromium .launch (headless = True )
3132 try :
@@ -37,12 +38,14 @@ def browser_context() -> Generator[any, None, None]:
3738def _check_url_exists (url : str , browser ) -> None :
3839 page = browser .new_page ()
3940 try :
40- response = page .goto (url , timeout = 10000 )
41+ response = page .request . head (url , timeout = 10000 )
4142 if response is None or response .status != 200 :
4243 raise ValueError (f"URL { url } is not reachable (status: { response .status if response else 'unknown' } )" )
4344 finally :
4445 page .close ()
4546
47+ sleep (5 )
48+
4649
4750def _check_image (img_path : Path ) -> None :
4851 """Check that the image exists and that it is either SVG or fits into the 512x512 bounding box."""
@@ -69,7 +72,7 @@ def validate_tutorials(schema_file: Path, tutorials_dir: Path) -> Generator[dict
6972 known_links = set ()
7073 known_primary_to_orders : dict [str , set [int ]] = {}
7174
72- with browser_context () as browser :
75+ with _browser_context () as browser :
7376 for tmp_meta_file in tutorials_dir .rglob ("meta.yaml" ):
7477 tutorial_id = tmp_meta_file .parent .name
7578 with tmp_meta_file .open () as f :
0 commit comments