import os
import shutil
import subprocess
from pathlib import Path

import pytest


@pytest.fixture(scope="session", autouse=True)
def download_cache():
    os.system('scripts/download_full.sh')
    yield
    shutil.rmtree('.cache', ignore_errors=True)


@pytest.fixture(scope='session')
def docker_image_name() -> str:
    return Path(__file__).parents[1].stem.lower()


@pytest.fixture(scope='session')
def build_docker_image(docker_image_name: str) -> str:
    subprocess.run(['docker', 'build', '-t', docker_image_name, '.'], check=True)
    return docker_image_name


@pytest.fixture(scope='session')
def build_docker_image_gpu(docker_image_name: str) -> str:
    image_name = f'{docker_image_name}:gpu'
    subprocess.run(
        ['docker', 'build', '-t', image_name, '-f', 'Dockerfile.gpu', '.'], check=True
    )
    return image_name

import os
import shutil

import pytest

@pytest.fixture(scope="session", autouse=True)
def download_cache():
    os.system('scripts/download_full.sh')
    yield
    shutil.rmtree('.cache', ignore_errors=True)