Skip to content

Commit bdc8c71

Browse files
Merge pull request #76 from heyalexchoi/fix-propose-key-error
Skip components that are not present in reflective dataset instead of raising KeyError failure
2 parents 29c75fc + 09842d0 commit bdc8c71

File tree

1 file changed

+7
-0
lines changed

1 file changed

+7
-0
lines changed

src/gepa/proposer/reflective_mutation/reflective_mutation.py

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -70,6 +70,13 @@ def propose_new_texts(
7070
raise ValueError("reflection_lm must be provided when adapter.propose_new_texts is None.")
7171
new_texts: dict[str, str] = {}
7272
for name in components_to_update:
73+
# Gracefully handle cases where a selected component has no data in reflective_dataset
74+
if name not in reflective_dataset or not reflective_dataset.get(name):
75+
self.logger.log(
76+
f"Component '{name}' is not in reflective dataset. Skipping."
77+
)
78+
continue
79+
7380
base_instruction = candidate[name]
7481
dataset_with_feedback = reflective_dataset[name]
7582
new_texts[name] = InstructionProposalSignature.run(

0 commit comments

Comments
 (0)