Files
wehub-resource-sync 85742ab165
Deploy Documentation / deploy (push) Has been cancelled
CPU Test / Test (Utilities, legacy, Python 3.10) (push) Has been cancelled
CPU Test / Test (LLM proxy, stable, Python 3.11) (push) Has been cancelled
CPU Test / Test (Others, stable, Python 3.11) (push) Has been cancelled
CPU Test / Test (Store, stable, Python 3.11) (push) Has been cancelled
CPU Test / Test (Utilities, stable, Python 3.11) (push) Has been cancelled
CPU Test / Test (Weave, stable, Python 3.11) (push) Has been cancelled
CPU Test / Test (AgentOps, stable, Python 3.12) (push) Has been cancelled
CPU Test / Test (LLM proxy, stable, Python 3.12) (push) Has been cancelled
CPU Test / Test (Others, stable, Python 3.12) (push) Has been cancelled
CPU Test / Test (Weave, latest, Python 3.13) (push) Has been cancelled
Dashboard / Chromatic (push) Has been cancelled
CPU Test / Lint - fast (push) Has been cancelled
CPU Test / Lint - next (push) Has been cancelled
CPU Test / Lint - slow (push) Has been cancelled
CPU Test / Lint - JavaScript (push) Has been cancelled
CPU Test / Build documentation (push) Has been cancelled
CPU Test / Test (AgentOps, legacy, Python 3.10) (push) Has been cancelled
CPU Test / Test (LLM proxy, legacy, Python 3.10) (push) Has been cancelled
CPU Test / Test (Others, legacy, Python 3.10) (push) Has been cancelled
CPU Test / Test (Store, legacy, Python 3.10) (push) Has been cancelled
CPU Test / Test (Weave, legacy, Python 3.10) (push) Has been cancelled
CPU Test / Test (AgentOps, stable, Python 3.11) (push) Has been cancelled
CPU Test / Test (Store, stable, Python 3.12) (push) Has been cancelled
CPU Test / Test (Utilities, stable, Python 3.12) (push) Has been cancelled
CPU Test / Test (Weave, stable, Python 3.12) (push) Has been cancelled
CPU Test / Test (AgentOps, latest, Python 3.13) (push) Has been cancelled
CPU Test / Test (LLM proxy, latest, Python 3.13) (push) Has been cancelled
CPU Test / Test (Others, latest, Python 3.13) (push) Has been cancelled
CPU Test / Test (Store, latest, Python 3.13) (push) Has been cancelled
CPU Test / Test (Utilities, latest, Python 3.13) (push) Has been cancelled
CPU Test / Test (JavaScript) (push) Has been cancelled
chore: import upstream snapshot with attribution
2026-07-13 12:44:17 +08:00

54 lines
1.4 KiB
Python

# Copyright (c) Microsoft. All rights reserved.
"""Tests for Trainer.dev requirements."""
from __future__ import annotations
from typing import Any
import pytest
from agentlightning.algorithm import Algorithm, Baseline
from agentlightning.execution.base import ExecutionStrategy
from agentlightning.litagent import LitAgent
from agentlightning.trainer import Trainer
class DummyStrategy(ExecutionStrategy):
"""Execution strategy that only records invocation."""
def __init__(self) -> None:
self.called = False
def execute(self, algorithm_bundle, runner_bundle, store) -> None: # type: ignore[override]
self.called = True
class DummyAgent(LitAgent[Any]):
"""Minimal agent for exercising Trainer.dev."""
class SlowAlgorithm(Algorithm):
"""Algorithm that does not qualify as FastAlgorithm."""
def run(self, train_dataset=None, val_dataset=None): # type: ignore[override]
return None
def test_dev_requires_fast_algorithm() -> None:
trainer = Trainer(strategy=DummyStrategy(), algorithm=SlowAlgorithm())
agent = DummyAgent()
with pytest.raises(TypeError):
trainer.dev(agent)
def test_dev_allows_fast_algorithm() -> None:
strategy = DummyStrategy()
trainer = Trainer(strategy=strategy, algorithm=Baseline())
agent = DummyAgent()
trainer.dev(agent)
assert strategy.called is True