Is there a way to run a script when building a Gradio space?

I have a Gradio space that needs the Playwright Python library. I have the library installed using the requirements file. However, I couldn’t figure out how to “playwright install” as required. The app through the follow error message without the additional step.

playwright._impl._api_types.Error: Executable doesn’t exist at /home/user/.cache/ms-playwright/chromium-1080/chrome-linux/chrome
╔════════════════════════════════════════════════════════════╗
║ Looks like Playwright was just installed or updated. ║
║ Please run the following command to download new browsers: ║
║ ║
║ playwright install ║
║ ║
║ <3 Playwright Team ║
╚════════════════════════════════════════════════════════════╝

Thanks,

hi @shulik7 ,

You can use this Gradio Docker SDK and run commands during build time

Another option

import subprocess

subprocess.run(["playwright", "install"])