Skip to content

Commit 15102a9

Browse files
fix(models): type extended_attributes as list[AttributeSpec] in ScenarioSpec
extended_attributes was typed as list[Any], so pydantic deserialized them as raw dicts from YAML. This caused sampling_order merge to silently skip all extended attributes (hasattr(dict, "name") is False). Typing the field as list[AttributeSpec] ensures pydantic auto-converts dicts on load. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
1 parent 9789eec commit 15102a9

2 files changed

Lines changed: 4 additions & 2 deletions

File tree

extropy/cli/commands/sample.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -132,7 +132,7 @@ def sample_command(
132132
# Compute merged sampling order
133133
merged_sampling_order = list(pop_spec.sampling_order)
134134
for attr in extended_attrs:
135-
if hasattr(attr, "name") and attr.name not in merged_sampling_order:
135+
if attr.name not in merged_sampling_order:
136136
merged_sampling_order.append(attr.name)
137137

138138
# Create merged spec for sampling

extropy/core/models/scenario.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,8 @@
2222
import yaml
2323
from pydantic import BaseModel, Field
2424

25+
from .population import AttributeSpec
26+
2527
if TYPE_CHECKING:
2628
pass
2729

@@ -354,7 +356,7 @@ class ScenarioSpec(BaseModel):
354356
description="Scenario-specific edge weights for conversation priority and peer ordering",
355357
)
356358
# Extended attributes from scenario (new CLI flow)
357-
extended_attributes: list[Any] | None = Field(
359+
extended_attributes: list[AttributeSpec] | None = Field(
358360
default=None,
359361
description="Scenario-specific attributes that extend the base population",
360362
)

0 commit comments

Comments
 (0)