Skip to content

Commit 52c5d14

Browse files
committed
Address fourth round of Copilot review feedback
- Use Field(default_factory=list) for Pydantic list defaults in features/experiments schemas - Fix visualization detection test: use spec=[] mock and expect TypeError for unknown types - Increase workspace port allocation scan limit from 200 to 1000
1 parent cf0d4e9 commit 52c5d14

4 files changed

Lines changed: 9 additions & 9 deletions

File tree

core/api_schemas/experiments.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ class ExperimentResponse(BaseModel):
4747
created_by: UUID
4848
created_at: datetime
4949
updated_at: datetime
50-
runs: List[ExperimentRunResponse] = []
50+
runs: List[ExperimentRunResponse] = Field(default_factory=list)
5151

5252
class Config:
5353
from_attributes = True

core/api_schemas/features.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ class FeatureGroupResponse(BaseModel):
4848
created_by: UUID
4949
created_at: datetime
5050
updated_at: datetime
51-
features: List[FeatureResponse] = []
51+
features: List[FeatureResponse] = Field(default_factory=list)
5252

5353
class Config:
5454
from_attributes = True

core/services/workspace_service.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -148,7 +148,7 @@ def _allocate_node_port(self) -> int:
148148
allocate an available nodeport from the workspace range
149149
'''
150150
used_ports = set()
151-
workspaces = self.repo.list_all(limit=200)
151+
workspaces = self.repo.list_all(limit=1000)
152152
for ws in workspaces:
153153
# reserve ports for all non-deleted workspaces to avoid conflicts
154154
# when a stopped workspace is restarted and needs its port back

sdk/tests/test_visualization.py

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -93,12 +93,12 @@ def test_detect_backend_networkx(self):
9393
result = VisualizationContext._detect_backend(figure)
9494
assert result == 'networkx'
9595

96-
def test_detect_backend_unknown_defaults_to_matplotlib(self):
97-
'''test that unknown backend defaults to matplotlib'''
98-
figure = MagicMock()
99-
figure.__class__.__module__ = 'custom.unknown.module'
100-
result = VisualizationContext._detect_backend(figure)
101-
assert result == 'matplotlib'
96+
def test_detect_backend_unknown_raises_type_error(self):
97+
'''test that unknown figure type raises TypeError'''
98+
figure = MagicMock(spec=[])
99+
figure.__class__ = type('UnknownFigure', (), {'__module__': 'custom.unknown.module'})
100+
with pytest.raises(TypeError, match="cannot detect backend"):
101+
VisualizationContext._detect_backend(figure)
102102

103103
# ─── Render with Explicit Backend ───────────────────────────────
104104

0 commit comments

Comments
 (0)