Skip to content

Commit 6046e82

Browse files
radikenclaude
andcommitted
shadow: type muxer/discovery as Literal
Constrain muxer/discovery to their valid values with Literal instead of plain str, matching how nimlibp2p.py types them. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
1 parent 74ddf6b commit 6046e82

2 files changed

Lines changed: 6 additions & 6 deletions

File tree

src/deployments/experiments/libp2p/shadow_gossipsub.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
# Shadow GossipSub experiment: N nim libp2p peers + 1 publisher inside Shadow on a
22
# single k8s pod. See the "Using Shadow at DST" runbook in Notion.
33
import logging
4-
from typing import Optional
4+
from typing import Literal, Optional
55

66
from pydantic import BaseModel, ConfigDict, NonNegativeFloat, NonNegativeInt
77

@@ -31,8 +31,8 @@ class ExpConfig(BaseModel):
3131
message_size_bytes: NonNegativeInt = 1000
3232
delay_seconds: NonNegativeFloat = 2.0
3333
connect_to: NonNegativeInt = 2
34-
muxer: str = "yamux" # yamux | mplex | quic
35-
discovery: str = "static" # static (CONNECTTO dial) | kad-dht (bootstrap anchor)
34+
muxer: Literal["yamux", "mplex", "quic"] = "yamux"
35+
discovery: Literal["static", "kad-dht"] = "static" # CONNECTTO dial vs kad bootstrap
3636
start_sleep: NonNegativeInt = 60 # node STARTSLEEP before mesh formation
3737
# Timing (simulated seconds). Publisher starts after the mesh forms (~60s).
3838
publisher_start_s: NonNegativeInt = 90

src/deployments/shadow/builders.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# Builders for Shadow simulator runs: config values -> kubernetes-client objects
22
# and yaml dicts. Pure data, no I/O. See the "Using Shadow at DST" runbook.
3-
from typing import Optional
3+
from typing import Literal, Optional
44

55
from kubernetes.client import (
66
V1Capabilities,
@@ -48,8 +48,8 @@ def render_shadow_yaml(
4848
sim_stop_time_s: int,
4949
publisher_start_s: int,
5050
connect_to: int = 2,
51-
muxer: str = "yamux",
52-
discovery: str = "static",
51+
muxer: Literal["yamux", "mplex", "quic"] = "yamux",
52+
discovery: Literal["static", "kad-dht"] = "static",
5353
start_sleep: int = 60,
5454
metrics_interval_s: int = 15,
5555
seed: int = 1,

0 commit comments

Comments
 (0)