Skip to content

Conversation

@tbarbugli
Copy link
Member

@tbarbugli tbarbugli commented Nov 11, 2025

Summary by CodeRabbit

  • New Features

    • Added RTC fields: participant "source", unified_session_id, and audio bitrate/profile entries.
    • Introduced an async RPC client surface and converted RPC calls to async signatures.
  • Chores

    • Simplified provisioning scripts and pinned generator install; updated dependency handling to include twirp and removed a dev git dep.
    • Removed legacy embedded async client implementation and corresponding tests.
  • Breaking/Compatibility

    • Protobuf runtime/version and descriptor layouts changed — regenerate bindings where applicable.

@tbarbugli tbarbugli changed the title attempt number 1 to make python deps work Fix stupid python dep problems Nov 11, 2025
@coderabbitai
Copy link

coderabbitai bot commented Nov 11, 2025

Walkthrough

Replaced the embedded async Twirp client with a new AsyncTwirpClient inside the generated signal_twirp module and converted signal RPC client methods to async; removed the embedded client file and its tests; regenerated protobuf artifacts (version header and descriptor offsets) with added enums/messages/fields; updated build scripts, workflow, and dependencies.

Changes

Cohort / File(s) Change Summary
CI workflow
​.github/workflows/release.yml
Removed two uv commands that removed/re-added the twirp dev dependency in the "Sync environment & install dev extras" step.
Build script
generate_webrtc.sh
Always verify Go and ensure GOPATH/bin on PATH; install protoc-gen-twirpy from a pinned commit (removed conditional "latest" install logic).
Protobuf runtime & descriptors
getstream/video/rtc/pb/.../signal_rpc/signal_pb2.py, getstream/video/rtc/pb/.../models/models_pb2.py, getstream/video/rtc/pb/.../event/events_pb2.py
Regenerated protos: runtime version header changed (6.31.1 → 5.28.2) and DESCRIPTOR serialized bytes/serialized_start/_end offsets adjusted.
Protobuf stubs / API additions
getstream/video/rtc/pb/.../event/events_pb2.pyi, getstream/video/rtc/pb/.../models/models_pb2.pyi
Added fields (e.g., JoinRequest.unified_session_id, JoinRequest.source), new enums/wrappers (ParticipantSource, AudioBitrateProfile), new AudioBitrate message, constants, constructor signatures, and ClearField/HasField updates.
Twirp async client — new implementation
getstream/video/rtc/pb/stream/video/sfu/signal_rpc/signal_twirp.py
Introduced AsyncTwirpClient using asyncio + aiohttp; converted AsyncSignalServerClient methods to async def delegating to await self._make_request(...); added error mapping to Twirp exceptions and URL/session handling improvements.
Twirp async client — removed embed
getstream/video/rtc/twirp_async_client_embed.py
Deleted previously embedded AsyncTwirpClient implementation (file removed).
Twirp client wrapper import cleanup
getstream/video/rtc/twirp_client_wrapper.py
Removed _async_available import and the import-time preflight ImportError guard for aiohttp.
Project dependencies
pyproject.toml
Added runtime dependency twirp; removed dev git-based twirp @ git+https://github.com/tbarbugli/twirpy@main from dev dependency group.
Tests removed
tests/test_twirp_client_wrapper.py
Removed async tests covering the SignalClient wrapper (file deleted).

Sequence Diagram(s)

sequenceDiagram
  autonumber
  actor Client
  participant SignalClient as AsyncSignalServerClient
  participant TwirpClient as AsyncTwirpClient
  participant HTTP as aiohttp.Session

  Client->>SignalClient: await Method(ctx, request)
  SignalClient->>TwirpClient: await _make_request(url, ctx, request, response_obj, session)
  TwirpClient->>HTTP: POST protobuf bytes (Content-Type: application/protobuf)
  activate HTTP
  alt 200 OK
    HTTP-->>TwirpClient: protobuf bytes
    TwirpClient-->>SignalClient: parsed response object
    SignalClient-->>Client: return response
  else Error / timeout
    HTTP-->>TwirpClient: error body / timeout
    TwirpClient-->>SignalClient: raise Twirp exception (mapped code/metadata)
    SignalClient-->>Client: exception propagated
  end
  deactivate HTTP
Loading

Estimated code review effort

🎯 4 (Complex) | ⏱️ ~45 minutes

  • Files/areas needing extra attention:
    • Regenerated protobuf descriptor changes and added enums/messages (models_pb2.py / .pyi, events_pb2.pyi) — verify schema intent, field numbers, and compatibility.
    • New AsyncTwirpClient and async conversions in signal_twirp.py — check session lifecycle, timeouts, error-to-Twirp mappings, and URL construction.
    • Removal of embedded client file and tests — ensure no remaining references and restore/adjust tests for new implementation.
    • Dependency and CI changes (generate_webrtc.sh, workflow, pyproject.toml) — confirm installation/pinning behavior for tooling.

Possibly related PRs

Poem

🐇 I hopped through fields of proto bytes and dew,
Swapped embeds for async, pinned a tool or two.
Enums sprouted leaves, new fields took flight,
CI trimmed its steps, and tests hopped out of sight.
A tiny rabbit cheers the tidy, springtime view.

Pre-merge checks and finishing touches

❌ Failed checks (1 warning)
Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 6.67% which is insufficient. The required threshold is 80.00%. You can run @coderabbitai generate docstrings to improve docstring coverage.
✅ Passed checks (2 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly and specifically describes the main change: migrating to use a forked twirp codegen library instead of the previous approach. This reflects the core change across multiple files.
✨ Finishing touches
  • 📝 Generate docstrings
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch unfudge-python-dep-hell

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@tbarbugli tbarbugli changed the title Fix stupid python dep problems Simplify twirp dependency management Nov 11, 2025
@tbarbugli tbarbugli changed the title Simplify twirp dependency management Use forked twirp codegen lib Nov 11, 2025
Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

📜 Review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

Disabled knowledge base sources:

  • Linear integration is disabled by default for public repositories

You can enable these sources in your CodeRabbit configuration.

📥 Commits

Reviewing files that changed from the base of the PR and between d0979b5 and 54c67d1.

⛔ Files ignored due to path filters (1)
  • uv.lock is excluded by !**/*.lock
📒 Files selected for processing (10)
  • generate_webrtc.sh (1 hunks)
  • getstream/video/rtc/pb/stream/video/sfu/event/events_pb2.py (4 hunks)
  • getstream/video/rtc/pb/stream/video/sfu/event/events_pb2.pyi (5 hunks)
  • getstream/video/rtc/pb/stream/video/sfu/models/models_pb2.py (4 hunks)
  • getstream/video/rtc/pb/stream/video/sfu/models/models_pb2.pyi (10 hunks)
  • getstream/video/rtc/pb/stream/video/sfu/signal_rpc/signal_pb2.py (2 hunks)
  • getstream/video/rtc/pb/stream/video/sfu/signal_rpc/signal_twirp.py (3 hunks)
  • getstream/video/rtc/twirp_async_client_embed.py (0 hunks)
  • getstream/video/rtc/twirp_client_wrapper.py (0 hunks)
  • pyproject.toml (1 hunks)
💤 Files with no reviewable changes (2)
  • getstream/video/rtc/twirp_async_client_embed.py
  • getstream/video/rtc/twirp_client_wrapper.py
✅ Files skipped from review due to trivial changes (1)
  • getstream/video/rtc/pb/stream/video/sfu/signal_rpc/signal_pb2.py
🧰 Additional context used
🧬 Code graph analysis (2)
getstream/video/rtc/pb/stream/video/sfu/event/events_pb2.pyi (1)
getstream/video/rtc/pb/stream/video/sfu/models/models_pb2.pyi (1)
  • ParticipantSource (136-139)
getstream/video/rtc/pb/stream/video/sfu/models/models_pb2.pyi (1)
getstream/video/rtc/pb/stream/video/sfu/event/events_pb2.pyi (16)
  • ClearField (239-291)
  • ClearField (347-352)
  • ClearField (395-397)
  • ClearField (420-425)
  • ClearField (443-448)
  • ClearField (463-465)
  • ClearField (504-516)
  • ClearField (543-548)
  • ClearField (580-585)
  • ClearField (619-631)
  • ClearField (668-682)
  • ClearField (787-817)
  • ClearField (868-886)
  • ClearField (923-933)
  • ClearField (969-981)
  • ClearField (1005-1010)
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (4)
  • GitHub Check: Tests (3.12)
  • GitHub Check: Tests (3.11)
  • GitHub Check: Tests (3.10)
  • GitHub Check: Tests (3.13)

Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

♻️ Duplicate comments (1)
getstream/video/rtc/pb/stream/video/sfu/signal_rpc/signal_twirp.py (1)

253-255: Fix aiohttp context manager usage (already flagged).

This issue has already been identified in a previous review: session.post() returns an async context manager, not a coroutine. Using async with await session.post(...) will cause a runtime error because ClientResponse doesn't implement __aenter__.

Apply this diff to fix:

-            async with await session.post(
-                url=full_url, data=request.SerializeToString(), **kwargs
-            ) as resp:
+            async with session.post(
+                url=full_url, data=request.SerializeToString(), **kwargs
+            ) as resp:
🧹 Nitpick comments (1)
generate_webrtc.sh (1)

58-59: Clarify intent of unconditional go install on every run.

The script now installs protoc-gen-twirpy unconditionally every time it runs. For local development, this could be slow; for CI, this is acceptable but worth documenting.

Consider adding a comment explaining this is intentional to ensure the pinned commit is always used, or add an optional --skip-install flag if regeneration is frequent during development.

📜 Review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

Disabled knowledge base sources:

  • Linear integration is disabled by default for public repositories

You can enable these sources in your CodeRabbit configuration.

📥 Commits

Reviewing files that changed from the base of the PR and between 73e8a9c and 20b8f1b.

📒 Files selected for processing (2)
  • generate_webrtc.sh (1 hunks)
  • getstream/video/rtc/pb/stream/video/sfu/signal_rpc/signal_twirp.py (3 hunks)
🔇 Additional comments (5)
getstream/video/rtc/pb/stream/video/sfu/signal_rpc/signal_twirp.py (4)

5-19: LGTM! Imports are appropriate for async Twirp client.

The new imports (asyncio, aiohttp, json, Optional, twirp exceptions/errors, urljoin) are all necessary for the AsyncTwirpClient implementation and properly support async HTTP operations, error handling, and URL construction.


221-228: LGTM! Initialization handles URL normalization correctly.

The constructor properly normalizes the address by ensuring it ends with a slash, which is necessary for urljoin to work correctly when combining with relative paths.


230-249: LGTM! Request setup and URL construction are well-implemented.

The method correctly:

  • Merges headers from context and kwargs
  • Sets the appropriate protobuf Content-Type
  • Handles optional session parameter with proper tracking
  • Constructs full URLs using urljoin with correct slash normalization

285-408: LGTM! AsyncSignalServerClient methods are correctly implemented.

All RPC methods are properly converted to async and consistently delegate to await self._make_request() with correct parameter forwarding. The implementation follows a uniform pattern across all nine methods (SetPublisher, SendAnswer, IceTrickle, UpdateSubscriptions, UpdateMuteStates, IceRestart, SendStats, StartNoiseCancellation, StopNoiseCancellation).

generate_webrtc.sh (1)

52-56: Original PATH check at lines 52-56 is correct and necessary; review comment is incorrect.

The verification shows:

  1. PATH check is necessary: You must have GOPATH/bin (or GOBIN) in PATH to run installed commands. The pre-validation approach prevents wasted work.

  2. No fragility in grep logic: Testing PATH matching edge cases (trailing slashes, substring positions) confirms the grep logic works correctly without false positives or false negatives.

  3. Original approach is superior: Validating the environment BEFORE go install (line 59) is better than checking tool availability after installation. If the PATH check fails, the script exits early; the suggested reactive check would only catch failures after go install has already run.

The script correctly validates that $(go env GOPATH)/bin is in PATH before proceeding with go install, aligning with Go best practices.

Likely an incorrect or invalid review comment.

@tbarbugli tbarbugli merged commit 62b1538 into main Nov 11, 2025
5 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants