```from flytekit import ImageSpec, Resources, task...
# flyte-deployment
t
Copy code
from flytekit import ImageSpec, Resources, task, workflow
from playwright.sync_api import sync_playwright

install_commands = [
    "apt-get update",
    "apt-get install -y libnss3 libnspr4 libatk1.0-0 libatk-bridge2.0-0 libcups2 libdrm2 libxcomposite1 libxdamage1 libxfixes3 libxrandr2 libgbm1 libxkbcommon0 libpango-1.0-0 libcairo2 libasound2 libatspi2.0-0",
    "python -m pip install --upgrade pip",
    "python -m pip install playwright==1.50.0",
    "python -m playwright install chromium",
]

image_spec = ImageSpec(
    name="playwright-flyte",
    base_image="<http://ghcr.io/flyteorg/flytekit:py3.10-1.15.0|ghcr.io/flyteorg/flytekit:py3.10-1.15.0>",
    packages=["playwright==1.50.0"],
    registry="localhost:30000",
    commands=install_commands
)

@task(container_image=image_spec)
def test_google_title() -> str:
    
    with sync_playwright() as playwright:
        browser = playwright.chromium.launch(headless=True)
        page = browser.new_page()
        
        # Google ana sayfasına git
        page.goto("<https://www.google.com>")
        
        # Sayfa başlığını al
        title = page.title()
        
        # Tarayıcıyı kapat
        browser.close()
        
        return title

@workflow
def browser_test_wf() -> str:
    return test_google_title()

if __name__ == "__main__":
    print(browser_test_wf())
I want to try run above code. But i am getting below error at kubernetes logs. I didn't solve problem . Please help me
Copy code
Traceback (most recent call last):
  File "/opt/micromamba/envs/runtime/bin/pyflyte-fast-execute", line 4, in <module>
    from flytekit.bin.entrypoint import fast_execute_task_cmd
  File "/opt/micromamba/envs/runtime/lib/python3.10/site-packages/flytekit/__init__.py", line 222, in <module>
    from flytekit.core.array_node_map_task import map_task
  File "/opt/micromamba/envs/runtime/lib/python3.10/site-packages/flytekit/core/array_node_map_task.py", line 15, in <module>
    from flytekit.core.array_node import array_node
  File "/opt/micromamba/envs/runtime/lib/python3.10/site-packages/flytekit/core/array_node.py", line 6, in <module>
    from flytekit.core import interface as flyte_interface
  File "/opt/micromamba/envs/runtime/lib/python3.10/site-packages/flytekit/core/interface.py", line 25, in <module>
    from flytekit.core import context_manager
  File "/opt/micromamba/envs/runtime/lib/python3.10/site-packages/flytekit/core/context_manager.py", line 32, in <module>
    from flytekit.core.data_persistence import FileAccessProvider, default_local_file_access_provider
  File "/opt/micromamba/envs/runtime/lib/python3.10/site-packages/flytekit/core/data_persistence.py", line 671, in <module>
    data_config=DataConfig.auto(),
  File "/opt/micromamba/envs/runtime/lib/python3.10/site-packages/flytekit/configuration/__init__.py", line 657, in auto
    config_file = get_config_file(config_file)
  File "/opt/micromamba/envs/runtime/lib/python3.10/site-packages/flytekit/configuration/file.py", line 259, in get_config_file
    if current_location_config.exists():
  File "/opt/micromamba/envs/runtime/lib/python3.10/pathlib.py", line 1290, in exists
    self.stat()
  File "/opt/micromamba/envs/runtime/lib/python3.10/pathlib.py", line 1097, in stat
    return self._accessor.stat(self, follow_symlinks=follow_symlinks)
PermissionError: [Errno 13] Permission denied: 'flytekit.config'
s
instead of running apt commands (which usually require sudo permissions), add all pip related packages to the ImageSpec(packages=...) field, and all apt packages you want to install to the ImageSpec(apt_packages=...) field you don't need to run any update/upgrade commands, this should be done in the background by defacto
python -m playwright install chromium
may be the only command you need to leave in the install commands because it requires running the playright python package to install chromium, which I don't think you can do from ImageSpec(packages=...) field
t
Thank you so much. It works 🤗