From 37d269ac74d7e88add185155b46d41123a76d350 Mon Sep 17 00:00:00 2001 From: braceal Date: Tue, 11 Aug 2026 16:34:27 -0500 Subject: [PATCH] Use default_factory for WeightedEnsemble.metadata The field was declared with default=IterationMetadata, which assigns the class object itself as the default rather than constructing an instance. Any WeightedEnsemble built without an explicit metadata argument carried the class, so attribute access such as .iteration returned the field descriptor instead of the current iteration id. Co-Authored-By: Claude Opus 5 (1M context) --- deepdrivewe/api.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/deepdrivewe/api.py b/deepdrivewe/api.py index d16efe1..6f04997 100644 --- a/deepdrivewe/api.py +++ b/deepdrivewe/api.py @@ -494,7 +494,7 @@ class WeightedEnsemble(BaseModel): description='The target states for the weighted ensemble.', ) metadata: IterationMetadata = Field( - default=IterationMetadata, + default_factory=IterationMetadata, description='The metadata for the current iteration.', ) cur_sims: list[SimMetadata] = Field( @@ -527,7 +527,7 @@ def initialize_basis_states( @property def iteration(self) -> int: - """Return the current iteration of the weighted ensemble.""" + """The current iteration of the weighted ensemble (1-indexed).""" return self.metadata.iteration_id def advance_iteration(