Skip to content

Commit 0c795c1

Browse files
Luboslav YordanovLuboslav Yordanov
authored andcommitted
Fix playright
1 parent 768a724 commit 0c795c1

File tree

1 file changed

+21
-0
lines changed

1 file changed

+21
-0
lines changed

examples/frontend/batch_speaker_app.py

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313
import os
1414
import re
1515
import unicodedata
16+
import subprocess
1617
from dataclasses import asdict, dataclass, field
1718
from pathlib import Path
1819
from typing import List, Optional
@@ -42,6 +43,26 @@
4243
pass
4344

4445

46+
def ensure_playwright_installed() -> None:
47+
"""Install Playwright browsers when running in ephemeral environments."""
48+
try:
49+
subprocess.run(
50+
["playwright", "install", "--with-deps", "chromium"],
51+
check=True,
52+
capture_output=True,
53+
)
54+
except FileNotFoundError:
55+
st.warning("Playwright CLI not found; please ensure Playwright is installed.", icon="⚠️")
56+
except subprocess.CalledProcessError as exc:
57+
# Playwright returns non-zero if browsers already exist; suppress noise.
58+
stderr = exc.stderr.decode("utf-8") if exc.stderr else ""
59+
if "already installed" not in stderr.lower():
60+
st.warning(f"Playwright install warning: {stderr}", icon="⚠️")
61+
62+
63+
ensure_playwright_installed()
64+
65+
4566
class Speaker(BaseModel):
4667
"""Schema for a single speaker entry."""
4768

0 commit comments

Comments
 (0)