Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions changelog.d/54.changed.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Scenario loading now supports yamlrocks 0.7 as well as 0.6.
5 changes: 3 additions & 2 deletions docs/decisions/0004-dependencies.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,9 @@ settings from the environment and the command line. Each dependency is a long-te
`msgspec.convert`, and runs with `msgspec.json`. Tagged unions let `Usage | NoUsage` and
`Verdict | Failed | NoVerdict` be written and read back without type checks in convy's code.
- **[yamlrocks](https://pypi.org/project/yamlrocks/)** for YAML. It implements YAML 1.2 (no `no` →
`False` surprise), is safe by default and passes the official YAML test suite. It is alpha, so it is
pinned to `>=0.6,<0.7` and called in one place.
`False` surprise), is safe by default and passes the official YAML test suite. Only the scenario
loader calls it. While it is alpha, [the dependency range](../../pyproject.toml) excludes untested
minor releases.
- **[pydantic-settings](https://docs.pydantic.dev/latest/concepts/pydantic_settings/)** for the
environment, `.env` and the command line. `SecretStr` keeps keys out of output.

Expand Down
3 changes: 2 additions & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ dependencies = [
"msgspec>=0.22.0",
"pydantic-settings>=2.15.0",
# Alpha: pinned below the next minor version, see docs/decisions/0004-dependencies.md.
"yamlrocks>=0.6.1,<0.7",
"yamlrocks>=0.6.1,<0.8",
]

[project.scripts]
Expand Down Expand Up @@ -64,6 +64,7 @@ dev = [

[tool.pytest.ini_options]
asyncio_mode = "auto"
asyncio_default_fixture_loop_scope = "function"
testpaths = ["tests"]
timeout = 30

Expand Down
6 changes: 3 additions & 3 deletions src/convy/agent.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@

import asyncio
import math
from collections.abc import AsyncIterator
from collections.abc import AsyncGenerator
from contextlib import AbstractAsyncContextManager, AsyncExitStack, asynccontextmanager
from datetime import datetime
from typing import Literal, Protocol
Expand Down Expand Up @@ -150,7 +150,7 @@ class TimeLimited(Struct, frozen=True):
seconds: float

@asynccontextmanager
async def conversation(self) -> AsyncIterator[Conversation]:
async def conversation(self) -> AsyncGenerator[Conversation, None]:
limit = asyncio.timeout(self.seconds)
try:
async with limit, self.agent.conversation() as conversation:
Expand All @@ -176,7 +176,7 @@ class QueuedAgent(Struct, frozen=True):
places: Places

@asynccontextmanager
async def conversation(self) -> AsyncIterator[Conversation]:
async def conversation(self) -> AsyncGenerator[Conversation, None]:
async with self.places, AsyncExitStack() as opened:
try:
conversation = await opened.enter_async_context(self.agent.conversation())
Expand Down
4 changes: 2 additions & 2 deletions src/convy/bench.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
import asyncio
import os
import sys
from collections.abc import Iterator
from collections.abc import Generator
from contextlib import contextmanager
from datetime import datetime
from importlib import metadata
Expand Down Expand Up @@ -234,7 +234,7 @@ def create(self) -> None:
self.write(Running())

@contextmanager
def held(self) -> Iterator[None]:
def held(self) -> Generator[None, None, None]:
"""Hold the run's folder for this process through `run.lock`, or raise `RunInUse`; a
file system without locks holds nothing. The system lets the lock go when the process
ends, however it ends, so the folder of a run whose process died can be held again."""
Expand Down
6 changes: 3 additions & 3 deletions src/convy/fakes.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
"""Simple working stand-ins for convy's interfaces, for tests: yours and convy's own."""

import asyncio
from collections.abc import AsyncIterator, Sequence
from collections.abc import AsyncGenerator, Sequence
from contextlib import asynccontextmanager

from msgspec import Struct
Expand Down Expand Up @@ -33,7 +33,7 @@ def __init__(self, *steps: Step, delay: float = 0):
self.open = 0

@asynccontextmanager
async def conversation(self) -> AsyncIterator[Conversation]:
async def conversation(self) -> AsyncGenerator[Conversation, None]:
self.opened += 1
self.open += 1
self.peak = max(self.peak, self.open)
Expand Down Expand Up @@ -68,7 +68,7 @@ class Echo(Struct, frozen=True):
"""An agent that answers with the user's message; its tokens are the message's length."""

@asynccontextmanager
async def conversation(self) -> AsyncIterator[Conversation]:
async def conversation(self) -> AsyncGenerator[Conversation, None]:
yield EchoConversation()


Expand Down
6 changes: 3 additions & 3 deletions src/convy/http.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
import json
import re
import ssl
from collections.abc import AsyncIterator, Mapping
from collections.abc import AsyncGenerator, Mapping
from contextlib import asynccontextmanager
from datetime import UTC, datetime
from email.utils import parsedate_to_datetime
Expand Down Expand Up @@ -66,7 +66,7 @@ class JsonEndpoint(Struct, frozen=True):
transport: httpx2.AsyncBaseTransport | None = None

@asynccontextmanager
async def connection(self) -> AsyncIterator["JsonConnection"]:
async def connection(self) -> AsyncGenerator["JsonConnection", None]:
"""One connection to the address, kept open for several requests."""
try:
verify = self.tls.context()
Expand Down Expand Up @@ -233,7 +233,7 @@ def __post_init__(self) -> None:
)

@asynccontextmanager
async def conversation(self) -> AsyncIterator[Conversation]:
async def conversation(self) -> AsyncGenerator[Conversation, None]:
async with self.endpoint.connection() as connection:
yield JsonConversation(self, str(uuid4()), connection)

Expand Down
4 changes: 2 additions & 2 deletions tests/test_agent.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import asyncio
import math
import re
from collections.abc import AsyncIterator
from collections.abc import AsyncGenerator
from contextlib import asynccontextmanager
from datetime import UTC, datetime

Expand Down Expand Up @@ -37,7 +37,7 @@ def __init__(self, opening: float, closing: float):
self.closing = closing

@asynccontextmanager
async def conversation(self) -> AsyncIterator[Conversation]:
async def conversation(self) -> AsyncGenerator[Conversation, None]:
await asyncio.sleep(self.opening)
try:
yield EchoConversation()
Expand Down
Loading
Loading