Files
reasoning-gym/tools/server/tests/test_registry.py
Andreas Köpf c69bc5d4e6 Basic curriculum (#198)
* feat: Add optional curriculum support to dataset registration and creation
* docs: Add docstrings to create_curriculum() and register_dataset()
* feat: Add curriculum configuration classes for CurriculumExperiment
* feat: Add weight parameter to CurriculumAttributeConfig and use in DatasetSpec
* refactor: Simplify CurriculumAttributeConfig with "*" attribute level support
* test: Add unit tests for CurriculumExperiment class
* feat: Add from_yaml() method to CurriculumExperimentConfig with unit test
2025-03-07 11:22:12 +01:00

45 lines
1.4 KiB
Python

"""Tests for experiment registry."""
import pytest
from reasoning_gym.arithmetic.chain_sum import ChainSumConfig
from reasoning_gym.coaching.registry import ExperimentRegistry
from reasoning_gym.composite import CompositeConfig, CompositeDataset, DatasetSpec
def test_singleton():
"""Test that ExperimentRegistry is a singleton."""
registry1 = ExperimentRegistry()
registry2 = ExperimentRegistry()
assert registry1 is registry2
def test_experiment_management():
"""Test basic experiment management operations."""
registry = ExperimentRegistry()
# Clear any existing experiments
for name in registry.list_experiments():
registry.remove_experiment(name)
# Test registration with chain_sum dataset
chain_sum_spec = DatasetSpec(name="chain_sum", weight=1.0, config=vars(ChainSumConfig(size=10, seed=42)))
config = CompositeConfig(size=10, seed=42, datasets=[chain_sum_spec])
registry.register_experiment("test_exp", config)
# Test listing
assert "test_exp" in registry.list_experiments()
# Test retrieval
exp = registry.get_experiment("test_exp")
assert exp is not None
assert exp.name == "test_exp"
assert isinstance(exp.composite, CompositeDataset)
assert exp.config == config
# Test removal
assert registry.remove_experiment("test_exp")
assert "test_exp" not in registry.list_experiments()
assert not registry.remove_experiment("nonexistent")