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
23 changes: 19 additions & 4 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ jobs:
runs-on: ubuntu-latest
strategy: &strategy
matrix:
python-version: ["3.11", "3.12", "3.13"]
python-version: ["3.10", "3.11", "3.12", "3.13"]
steps:
- uses: actions/checkout@v4
- uses: astral-sh/setup-uv@v5
Expand All @@ -33,10 +33,20 @@ jobs:
enable-cache: true

- name: Install project dependencies
run: uv sync --locked --all-extras --all-packages
run: |
if [ "${{ matrix.python-version }}" = "3.10" ]; then
uv sync --locked --all-extras
else
uv sync --locked --all-extras --all-packages
fi

- name: Type check
run: uv run pyright
run: |
if [ "${{ matrix.python-version }}" = "3.10" ]; then
uv run pyright fishjam
else
uv run pyright
fi

test:
runs-on: ubuntu-latest
Expand All @@ -50,7 +60,12 @@ jobs:
enable-cache: true

- name: Install project dependencies
run: uv sync --locked --all-extras --all-packages
run: |
if [ "${{ matrix.python-version }}" = "3.10" ]; then
uv sync --locked --all-extras
else
uv sync --locked --all-extras --all-packages
fi

- name: Initialize Localtunnel
id: tunnel
Expand Down
2 changes: 1 addition & 1 deletion examples/multimodal/pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ name = "multimodal"
version = "0.1.0"
description = "Fishjam multimodal demo with Gemini Live API"
readme = "README.md"
requires-python = ">=3.11"
requires-python = ">=3.10"
dependencies = [
"fastapi[standard]==0.116.0",
"fishjam-server-sdk",
Expand Down
2 changes: 1 addition & 1 deletion examples/poet_chat/pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ name = "poet_chat"
version = "0.1.0"
description = "Fishjam voice agent example"
readme = "README.md"
requires-python = ">=3.11"
requires-python = ">=3.10"
dependencies = ["fishjam-server-sdk", "openai-agents[voice]>=0.2.11"]

[tool.uv.sources]
Expand Down
2 changes: 1 addition & 1 deletion examples/selective_subscription/pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ name = "selective-subscription-demo"
version = "0.1.0"
description = "Selective subscription demo using Fishjam Python SDK"
readme = "README.md"
requires-python = ">=3.11"
requires-python = ">=3.10"
dependencies = [
"starlette>=0.35.0",
"uvicorn>=0.25.0",
Expand Down
2 changes: 1 addition & 1 deletion examples/transcription/pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ name = "transcription"
version = "0.1.0"
description = "Fishjam transcription demo"
readme = "README.md"
requires-python = ">=3.11"
requires-python = ">=3.10"
dependencies = [
"fastapi[standard]==0.116.0",
"fishjam-server-sdk",
Expand Down
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ name = "fishjam-server-sdk"
version = "0.26.0"
description = "Python server SDK for the Fishjam"
authors = [{ name = "Fishjam Team", email = "contact@fishjam.io" }]
requires-python = ">=3.11"
requires-python = ">=3.10"
readme = "README.md"
license = "Apache-2.0"
dependencies = [
Expand Down
5 changes: 2 additions & 3 deletions tests/agent/test_agent.py
Original file line number Diff line number Diff line change
Expand Up @@ -54,9 +54,8 @@ def _(notification: AllowedNotification):
yield notifier

task.cancel()
with suppress(asyncio.TimeoutError):
async with asyncio.timeout(0):
await task
with suppress(asyncio.CancelledError):
await task


class TestAgentApi:
Expand Down
60 changes: 36 additions & 24 deletions tests/test_notifier.py
Original file line number Diff line number Diff line change
Expand Up @@ -80,16 +80,17 @@ async def test_valid_credentials(self):
def handle_notitifcation(_notification):
pass

async with asyncio.TaskGroup() as tg:
notifier_task = tg.create_task(notifier.connect())
notifier_task = asyncio.ensure_future(notifier.connect())
try:
await notifier.wait_ready()

assert (
notifier._websocket
and notifier._websocket.state == websockets.State.OPEN
)

finally:
notifier_task.cancel()
await asyncio.gather(notifier_task, return_exceptions=True)


@pytest.fixture
Expand All @@ -114,10 +115,11 @@ async def test_room_created_deleted(
):
event_checks = [ServerMessageRoomCreated, ServerMessageRoomDeleted]

async with asyncio.TaskGroup() as tg:
assert_task = tg.create_task(assert_events(notifier, event_checks.copy()))

notifier_task = tg.create_task(notifier.connect())
assert_task = asyncio.ensure_future(
assert_events(notifier, event_checks.copy())
)
notifier_task = asyncio.ensure_future(notifier.connect())
try:
await notifier.wait_ready()

options = RoomOptions(webhook_url=WEBHOOK_URL)
Expand All @@ -126,8 +128,10 @@ async def test_room_created_deleted(
room_api.delete_room(room.id)

await assert_task

finally:
assert_task.cancel()
notifier_task.cancel()
await asyncio.gather(assert_task, notifier_task, return_exceptions=True)

self.assert_webhook_events(event_checks, event_queue, room.id)

Expand All @@ -144,28 +148,32 @@ async def test_peer_connected_disconnected(
ServerMessageRoomDeleted,
]

async with asyncio.TaskGroup() as tg:
assert_task = tg.create_task(assert_events(notifier, event_checks.copy()))

notifier_task = tg.create_task(notifier.connect())
assert_task = asyncio.ensure_future(
assert_events(notifier, event_checks.copy())
)
notifier_task = asyncio.ensure_future(notifier.connect())
tasks = [assert_task, notifier_task]
try:
await notifier.wait_ready()

options = RoomOptions(webhook_url=WEBHOOK_URL)
room = room_api.create_room(options=options)

peer, token = room_api.create_peer(room.id)
peer_socket = PeerSocket(fishjam_url=FISHJAM_ID)
peer_socket_task = tg.create_task(peer_socket.connect(token))
peer_socket_task = asyncio.ensure_future(peer_socket.connect(token))
tasks.append(peer_socket_task)

await peer_socket.wait_ready()

room_api.delete_peer(room.id, peer.id)
room_api.delete_room(room.id)

await assert_task

notifier_task.cancel()
peer_socket_task.cancel()
finally:
for task in tasks:
task.cancel()
await asyncio.gather(*tasks, return_exceptions=True)

self.assert_webhook_events(event_checks, event_queue, room.id)

Expand All @@ -181,27 +189,31 @@ async def test_peer_connected_room_deleted(
ServerMessageRoomDeleted,
]

async with asyncio.TaskGroup() as tg:
assert_task = tg.create_task(assert_events(notifier, event_checks.copy()))

notifier_task = tg.create_task(notifier.connect())
assert_task = asyncio.ensure_future(
assert_events(notifier, event_checks.copy())
)
notifier_task = asyncio.ensure_future(notifier.connect())
tasks = [assert_task, notifier_task]
try:
await notifier.wait_ready()

options = RoomOptions(webhook_url=WEBHOOK_URL)
room = room_api.create_room(options=options)
_peer, token = room_api.create_peer(room.id)

peer_socket = PeerSocket(fishjam_url=FISHJAM_ID)
peer_socket_task = tg.create_task(peer_socket.connect(token))
peer_socket_task = asyncio.ensure_future(peer_socket.connect(token))
tasks.append(peer_socket_task)

await peer_socket.wait_ready()

room_api.delete_room(room.id)

await assert_task

notifier_task.cancel()
peer_socket_task.cancel()
finally:
for task in tasks:
task.cancel()
await asyncio.gather(*tasks, return_exceptions=True)

self.assert_webhook_events(event_checks, event_queue, room.id)

Expand Down
Loading
Loading