"""Shared pytest fixtures: a tiny offline config and a synthetic dataset.""" from __future__ import annotations import os import pytest from causal_difficulty.config import Config from causal_difficulty.data.synth_jobs import generate_jobs @pytest.fixture def tiny_cfg(tmp_path) -> Config: cfg = Config({ "seed": 7, "paths": { "data_dir": str(tmp_path / "data"), "outputs_dir": str(tmp_path / "outputs"), "cache_dir": str(tmp_path / "cache"), }, "dataset": { "n_jobs": 12, "twins_per_job": 3, "categories": ["web_dev", "ml", "design", "writing", "data"], "complexity_tiers": ["easy", "medium", "hard"], }, "encoder": { "backbone": "hashing", "openai_embed": {"model": "text-embedding-3-small"}, "hf_lora": {"model": "BAAI/bge-small-en-v1.5", "lora_r": 8, "lora_alpha": 16, "lora_dropout": 0.05}, }, "model": {"hidden_dim": 64, "complexity_dim": 16, "dropout": 0.0}, "train": { "representation": {"epochs": 3, "lr": 1e-3, "batch_size": 16, "triplet_margin": 0.3}, "calibration": {"epochs": 5, "lr": 1e-3, "batch_size": 16, "lambda_inv": 0.5, "huber_delta": 0.1}, }, "eval": {"fragile_threshold": 0.1, "holdout_frac": 0.3}, }) for p in cfg["paths"].values(): os.makedirs(p, exist_ok=True) return cfg @pytest.fixture def jobs(): return generate_jobs(12, seed=7)