Skip to content

Commit 5939a30

Browse files
committed
use playwright as default convertor
1 parent ae0e83b commit 5939a30

File tree

7 files changed

+408
-72
lines changed

7 files changed

+408
-72
lines changed

.github/workflows/python-package.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -106,7 +106,7 @@ jobs:
106106
- name: Install dependencies
107107
run: |
108108
python -m pip install --upgrade pip wheel
109-
pip install pytest pytest-asyncio matplotlib selenium jupyter pandoc playwright
109+
pip install pytest pytest-asyncio matplotlib jupyter pandoc playwright selenium
110110
pip install . --upgrade
111111
- name: mac nbconvert patch fix # this is a tmp fix, related to https://github.com/jupyter/nbconvert/issues/1773
112112
if: ${{ startsWith(matrix.os, 'macos') }}

dataframe_image/_browser_pdf.py

Lines changed: 21 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
import socket
88
from pathlib import Path
99
from subprocess import Popen
10-
from tempfile import mkstemp
10+
from tempfile import TemporaryDirectory, mkstemp
1111

1212
import aiohttp
1313
from nbconvert.exporters import HTMLExporter
@@ -86,32 +86,33 @@ async def main(file_name, p, debug_port):
8686

8787

8888
def get_launch_args():
89-
# temp_dir = TemporaryDirectory()
90-
temp_dir_name = os.path.abspath(".")
91-
args = [
92-
"--headless",
93-
"--enable-logging",
94-
"--disable-gpu",
95-
"--run-all-compositor-stages-before-draw",
96-
"--remote-allow-origins=*",
97-
"--enable-features=NetworkService",
98-
f"--crash-dumps-dir={temp_dir_name}",
99-
"about:blank",
100-
]
101-
if (
102-
os.environ.get("NO_SANDBOX", False)
103-
or platform.system().lower() != "windows"
104-
and os.geteuid() == 0
105-
):
106-
args.append("--no-sandbox")
107-
return args
89+
with TemporaryDirectory() as temp_dir:
90+
temp_dir_name = os.path.abspath(".")
91+
args = [
92+
"--headless",
93+
"--enable-logging",
94+
"--disable-gpu",
95+
"--run-all-compositor-stages-before-draw",
96+
"--enable-features=NetworkService",
97+
f"--crash-dumps-dir={temp_dir_name}",
98+
f"--user-data-dir={temp_dir}",
99+
"about:blank",
100+
]
101+
if (
102+
os.environ.get("NO_SANDBOX", False)
103+
or platform.system().lower() != "windows"
104+
and os.geteuid() == 0
105+
):
106+
args.append("--no-sandbox")
107+
return args
108108

109109

110110
# deprecated
111111
def launch_chrome(debug_port):
112112
chrome_path = get_chrome_path()
113113
args = [chrome_path] + get_launch_args() + [f"--remote-debugging-port={debug_port}"]
114114
p = Popen(args=args)
115+
logging.debug(f"Chrome process started with PID: {p.pid}")
115116
return p
116117

117118

dataframe_image/_pandas_accessor.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,7 @@ def prepare_converter(
7373
max_cols=None,
7474
table_conversion: Literal[
7575
"chrome", "matplotlib", "html2image", "playwright", "selenium"
76-
] = "chrome",
76+
] = "playwright",
7777
chrome_path=None,
7878
dpi=None,
7979
use_mathjax=False,
@@ -187,7 +187,7 @@ def export(
187187
max_cols=None,
188188
table_conversion: Literal[
189189
"chrome", "matplotlib", "html2image", "playwright", "selenium"
190-
] = "chrome",
190+
] = "playwright",
191191
chrome_path=None,
192192
dpi=None,
193193
use_mathjax=False,
@@ -234,7 +234,7 @@ async def export_async(
234234
max_cols=None,
235235
table_conversion: Literal[
236236
"chrome", "matplotlib", "html2image", "playwright_async", "selenium"
237-
] = "chrome",
237+
] = "playwright_async",
238238
chrome_path=None,
239239
dpi=None,
240240
use_mathjax=False,

dataframe_image/_version.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
__version__ = "0.2.5.dev8+g18a693c.d20241008"
1+
__version__ = "0.2.7.dev9+gae0e83b.d20250129"

0 commit comments

Comments
 (0)