refiners/tests/conftest.py

52 lines
1.3 KiB
Python
Raw Permalink Normal View History

2023-08-04 13:28:41 +00:00
import os
from pathlib import Path
import torch
2023-08-04 13:28:41 +00:00
from pytest import fixture
PARENT_PATH = Path(__file__).parent
2024-04-03 09:54:39 +00:00
collect_ignore = ["weights", "repos", "datasets"]
collect_ignore_glob = ["*_ref"]
2023-08-04 13:28:41 +00:00
@fixture(scope="session")
def test_device() -> torch.device:
test_device = os.getenv("REFINERS_TEST_DEVICE")
if not test_device:
return torch.device("cuda:0" if torch.cuda.is_available() else "cpu")
return torch.device(test_device)
@fixture(scope="session")
def test_weights_path() -> Path:
from_env = os.getenv("REFINERS_TEST_WEIGHTS_DIR")
return Path(from_env) if from_env else PARENT_PATH / "weights"
2024-04-03 09:54:39 +00:00
@fixture(scope="session")
def test_datasets_path() -> Path:
from_env = os.getenv("REFINERS_TEST_DATASETS_DIR")
return Path(from_env) if from_env else PARENT_PATH / "datasets"
@fixture(scope="session")
def test_repos_path() -> Path:
from_env = os.getenv("REFINERS_TEST_REPOS_DIR")
return Path(from_env) if from_env else PARENT_PATH / "repos"
2023-08-04 13:28:41 +00:00
@fixture(scope="session")
def test_e2e_path() -> Path:
return PARENT_PATH / "e2e"
2023-08-29 15:53:39 +00:00
@fixture(scope="session")
def test_textual_inversion_path() -> Path:
return PARENT_PATH / "foundationals" / "clip" / "test_concepts_ref"
@fixture(scope="session")
def test_sam_path() -> Path:
return PARENT_PATH / "foundationals" / "segment_anything"