MCPcopy Create free account
hub / github.com/microsoft/SkillOpt / apply_patch_with_report

Function apply_patch_with_report

skillopt/optimizer/skill.py:165–186  ·  view source on GitHub ↗

Apply a patch and return a per-edit report for observability.

(
    skill: str,
    patch: PatchType | dict,
)

Source from the content-addressed store, hash-verified

163
164
165def apply_patch_with_report(
166 skill: str,
167 patch: PatchType | dict,
168) -> tuple[str, list[dict]]:
169 """Apply a patch and return a per-edit report for observability."""
170 edits = patch.edits if hasattr(patch, "edits") else patch.get("edits", [])
171 reports: list[dict] = []
172 for idx, edit in enumerate(edits, 1):
173 try:
174 skill, report = _apply_edit_with_report(skill, edit)
175 report["index"] = idx
176 except Exception as exc: # noqa: BLE001
177 report = {
178 "index": idx,
179 "op": "",
180 "target": "",
181 "content_preview": "",
182 "status": "error",
183 "error": str(exc),
184 }
185 reports.append(report)
186 return skill, reports
187
188
189def apply_patch(skill: str, patch: PatchType | dict) -> str:

Callers 2

trainMethod · 0.90
apply_patchFunction · 0.85

Calls 2

_apply_edit_with_reportFunction · 0.85
getMethod · 0.80

Tested by

no test coverage detected