Skip to content

Commit bd1a5eb

Browse files
Kamesh Akellacursoragent
authored andcommitted
style(langgraph): satisfy summarizer ruff format check
Format the ci_failure_summarizer files that were still failing the PR #272 lint workflow while keeping the earlier lint, type-check, and CodeQL fixes intact. Co-authored-by: Cursor <cursoragent@cursor.com>
1 parent 41a8092 commit bd1a5eb

9 files changed

Lines changed: 56 additions & 47 deletions

File tree

agents/langgraph/templates/ci_failure_summarizer/src/ci_failure_summarizer/config.py

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,9 +6,7 @@
66
from os import getenv
77

88
QG4_WORKFLOW_FILE = "agent-deployment-test.yaml"
9-
CI_DASHBOARD_URL = (
10-
"https://red-hat-data-services.github.io/agentic-starter-kits/"
11-
)
9+
CI_DASHBOARD_URL = "https://red-hat-data-services.github.io/agentic-starter-kits/"
1210

1311

1412
@dataclass(frozen=True)

agents/langgraph/templates/ci_failure_summarizer/src/ci_failure_summarizer/failure_evidence.py

Lines changed: 16 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -129,7 +129,9 @@ def build_evidence_signature(
129129
fallback_excerpt: str | None = None,
130130
) -> str | None:
131131
payload_parts = markers or ([fallback_excerpt] if fallback_excerpt else [])
132-
normalized = [part.strip().lower() for part in payload_parts if part and part.strip()]
132+
normalized = [
133+
part.strip().lower() for part in payload_parts if part and part.strip()
134+
]
133135
if not normalized:
134136
return None
135137
return sha256("|".join(normalized).encode("utf-8")).hexdigest()[:16]
@@ -170,7 +172,9 @@ def evidence_from_metadata(metadata: dict[str, Any] | None) -> FailureEvidence |
170172
excerpt = str(metadata.get("evidence_excerpt") or "").strip()
171173
markers = tuple(
172174
marker
173-
for marker in (str(value).strip() for value in metadata.get("evidence_markers") or [])
175+
for marker in (
176+
str(value).strip() for value in metadata.get("evidence_markers") or []
177+
)
174178
if marker
175179
)
176180
signature = metadata.get("evidence_signature")
@@ -184,7 +188,9 @@ def evidence_from_metadata(metadata: dict[str, Any] | None) -> FailureEvidence |
184188
source=source,
185189
excerpt=excerpt,
186190
markers=markers,
187-
signature=str(signature) if signature else build_evidence_signature(list(markers), fallback_excerpt=excerpt),
191+
signature=str(signature)
192+
if signature
193+
else build_evidence_signature(list(markers), fallback_excerpt=excerpt),
188194
run_id=run_id,
189195
)
190196

@@ -199,9 +205,13 @@ def merge_failure_evidence(
199205
return primary
200206
excerpt = primary.excerpt or fallback.excerpt
201207
markers = primary.markers or fallback.markers
202-
signature = primary.signature or fallback.signature or build_evidence_signature(
203-
list(markers),
204-
fallback_excerpt=excerpt,
208+
signature = (
209+
primary.signature
210+
or fallback.signature
211+
or build_evidence_signature(
212+
list(markers),
213+
fallback_excerpt=excerpt,
214+
)
205215
)
206216
return FailureEvidence(
207217
source=primary.source or fallback.source,

agents/langgraph/templates/ci_failure_summarizer/src/ci_failure_summarizer/github_client.py

Lines changed: 3 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -44,9 +44,7 @@ def _classify_api_error(response: requests.Response, *, operation: str) -> str:
4444
detail = message or "resource not found"
4545
return f"GitHub {detail} while {operation}"
4646
if message:
47-
return (
48-
f"GitHub API error ({response.status_code}) while {operation}: {message}"
49-
)
47+
return f"GitHub API error ({response.status_code}) while {operation}: {message}"
5048
return f"GitHub API request failed ({response.status_code}) while {operation}"
5149

5250

@@ -126,9 +124,7 @@ def _request(
126124
) -> requests.Response:
127125
url = f"{API_ROOT}{path}"
128126
try:
129-
response = self._session.request(
130-
method, url, params=params, timeout=30
131-
)
127+
response = self._session.request(method, url, params=params, timeout=30)
132128
except requests.RequestException as exc:
133129
raise RuntimeError(
134130
f"GitHub API network error while {method} {path}: {type(exc).__name__}"
@@ -236,9 +232,7 @@ def is_failed_job(job: WorkflowJob) -> bool:
236232
@staticmethod
237233
def failed_step_name(job: WorkflowJob) -> str | None:
238234
failed_steps = [
239-
step.name
240-
for step in job.steps
241-
if step.conclusion in FAILED_CONCLUSIONS
235+
step.name for step in job.steps if step.conclusion in FAILED_CONCLUSIONS
242236
]
243237
if failed_steps:
244238
return failed_steps[-1]

agents/langgraph/templates/ci_failure_summarizer/src/ci_failure_summarizer/summary_composer.py

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -25,10 +25,7 @@ def compose_summary(
2525
incidents: list[Incident],
2626
) -> str:
2727
if not failures:
28-
return (
29-
f"No failed jobs found for workflow run #{run.id} "
30-
f"({run.html_url})."
31-
)
28+
return f"No failed jobs found for workflow run #{run.id} ({run.html_url})."
3229
incident_by_fp = {incident.fingerprint: incident for incident in incidents}
3330
lines = [
3431
f"*CI Triage Summary* — {run.name}",
@@ -82,13 +79,18 @@ def _classify_failure(
8279
excerpt = evidence.excerpt if evidence else ""
8380
haystack = "\n".join(markers + ([excerpt] if excerpt else []))
8481
evidence_line = select_best_error_marker(markers) or (
85-
_first_meaningful_line(excerpt) or "No deterministic evidence markers extracted."
82+
_first_meaningful_line(excerpt)
83+
or "No deterministic evidence markers extracted."
8684
)
8785
source = _source_label(failure, evidence)
8886

8987
route_match = _ROUTE_NOT_FOUND_RE.search(haystack)
9088
if route_match:
91-
route_name = route_match.group("route") or route_match.group("route2") or failure.job_name
89+
route_name = (
90+
route_match.group("route")
91+
or route_match.group("route2")
92+
or failure.job_name
93+
)
9294
return {
9395
"cause": "The pre-deployed agent route was missing, so the integration test could not resolve the expected endpoint.",
9496
"evidence": f"{source}: {evidence_line}",

agents/langgraph/templates/ci_failure_summarizer/tests/integration/conftest.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,7 @@ def _write_env_file(agent_dir, container_image):
6464
"Set them in the CI workflow or export locally."
6565
)
6666
env_path = agent_dir / ".env"
67+
6768
def shell_assign(name: str, value: str) -> str:
6869
return f"{name}={shlex.quote(value)}"
6970

agents/langgraph/templates/ci_failure_summarizer/tests/test_github_client.py

Lines changed: 5 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -145,9 +145,7 @@ def test_fetch_job_logs_degrades_on_403():
145145
response = MagicMock()
146146
response.status_code = 403
147147
response.headers = {}
148-
response.json.return_value = {
149-
"message": "Must have admin rights to Repository."
150-
}
148+
response.json.return_value = {"message": "Must have admin rights to Repository."}
151149
client._request = MagicMock(return_value=response) # type: ignore[method-assign]
152150

153151
result = client.fetch_job_logs(222)
@@ -165,9 +163,7 @@ def test_fetch_job_logs_reports_rate_limit_on_403():
165163
"X-RateLimit-Remaining": "0",
166164
"Retry-After": "42",
167165
}
168-
response.json.return_value = {
169-
"message": "API rate limit exceeded for user"
170-
}
166+
response.json.return_value = {"message": "API rate limit exceeded for user"}
171167
client._request = MagicMock(return_value=response) # type: ignore[method-assign]
172168

173169
result = client.fetch_job_logs(222)
@@ -200,14 +196,14 @@ def test_fetch_job_logs_prefers_failed_step_section_over_cleanup_tail():
200196
response.text = "\n".join(
201197
[
202198
"2026-07-20T04:19:20.4451275Z ##[group]Run oc login \\",
203-
'2026-07-20T04:19:20.4451819Z oc login --token=\"$OC_TOKEN\"',
199+
'2026-07-20T04:19:20.4451819Z oc login --token="$OC_TOKEN"',
204200
"2026-07-20T04:19:20.4452455Z oc login --namespace=ci-testing",
205201
"2026-07-20T04:19:20.4535385Z env:",
206202
"2026-07-20T04:19:20.4535806Z API_KEY: not_needed",
207203
"2026-07-20T04:19:20.4536805Z MODEL_ID: qwen2-5-7b-instruct",
208204
"2026-07-20T04:19:24.5216230Z > raise RouteNotFoundError(agent_name, stderr=result.stderr.strip())",
209205
"2026-07-20T04:19:24.5217171Z E integration.utils.RouteNotFoundError: No route found for langflow-simple-tool-calling-agent",
210-
'2026-07-20T04:19:24.5217971Z E oc stderr: Error from server (NotFound): routes.route.openshift.io \"langflow-simple-tool-calling-agent\" not found',
206+
'2026-07-20T04:19:24.5217971Z E oc stderr: Error from server (NotFound): routes.route.openshift.io "langflow-simple-tool-calling-agent" not found',
211207
"2026-07-20T04:19:24.5225846Z tests/integration/conftest.py:33: Failed",
212208
"2026-07-20T04:19:24.5655062Z ##[error]Process completed with exit code 2.",
213209
"2026-07-20T04:19:24.5725669Z ##[group]Run actions/upload-artifact@v4",
@@ -232,7 +228,7 @@ def test_fetch_job_logs_prefers_failed_step_section_over_cleanup_tail():
232228
def test_select_best_error_marker_prefers_specific_route_not_found_marker():
233229
wrapper = "E Failed: Pre-deployed agent route not found"
234230
route_marker = (
235-
'E oc stderr: Error from server (NotFound): routes.route.openshift.io '
231+
"E oc stderr: Error from server (NotFound): routes.route.openshift.io "
236232
'"langflow-simple-tool-calling-agent" not found'
237233
)
238234

agents/langgraph/templates/ci_failure_summarizer/tests/test_grouping.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -25,10 +25,7 @@
2525
def _load_fixture() -> tuple[WorkflowRun, list[WorkflowJob]]:
2626
payload = json.loads((FIXTURES / "github_failure_run.json").read_text())
2727
run = WorkflowRun.from_api(payload["workflow_runs"][0])
28-
jobs = [
29-
WorkflowJob.from_api(job)
30-
for job in payload["jobs"][str(run.id)]["jobs"]
31-
]
28+
jobs = [WorkflowJob.from_api(job) for job in payload["jobs"][str(run.id)]["jobs"]]
3229
return run, jobs
3330

3431

@@ -37,7 +34,10 @@ def test_extract_qg_label_from_workflow_name():
3734

3835

3936
def test_infer_failure_area_for_health_check():
40-
assert infer_failure_area("test-agent (langgraph-react-agent)", "Health check") == "health-check"
37+
assert (
38+
infer_failure_area("test-agent (langgraph-react-agent)", "Health check")
39+
== "health-check"
40+
)
4141

4242

4343
def test_build_fingerprint_is_stable():

agents/langgraph/templates/ci_failure_summarizer/tests/test_incident_store.py

Lines changed: 13 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -192,18 +192,23 @@ def fake_connection():
192192

193193
failure = _sample_failure()
194194
failure = FailureRecord(
195-
**{**failure.__dict__, "evidence": FailureEvidence(
196-
source="github_job_log",
197-
excerpt="ERROR: health check failed",
198-
markers=("ERROR: health check failed",),
199-
signature="sig-123",
200-
run_id=123456789,
201-
)}
195+
**{
196+
**failure.__dict__,
197+
"evidence": FailureEvidence(
198+
source="github_job_log",
199+
excerpt="ERROR: health check failed",
200+
markers=("ERROR: health check failed",),
201+
signature="sig-123",
202+
run_id=123456789,
203+
),
204+
}
202205
)
203206

204207
with patch.object(store, "_connection", fake_connection):
205208
store.upsert_failures([failure])
206209

207210
execute_kwargs = mock_conn.execute.call_args.args[1]
208-
assert '"evidence_excerpt": "ERROR: health check failed"' in execute_kwargs["metadata"]
211+
assert (
212+
'"evidence_excerpt": "ERROR: health check failed"' in execute_kwargs["metadata"]
213+
)
209214
assert '"evidence_signature": "sig-123"' in execute_kwargs["metadata"]

agents/langgraph/templates/ci_failure_summarizer/tests/test_summary_composer.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -237,5 +237,8 @@ def test_compose_fallback_summary_renders_missing_env_var_recommendation():
237237
assert "`CONTAINER_IMAGE`" in summary
238238
assert "`CONTAINER_IMAGE_CREW`" in summary
239239
assert "`CONTAINER_IMAGE_LANGGRAPH`" in summary
240-
assert "ERROR: Set CONTAINER_IMAGE or both CONTAINER_IMAGE_CREW and CONTAINER_IMAGE_LANGGRAPH in .env" in summary
240+
assert (
241+
"ERROR: Set CONTAINER_IMAGE or both CONTAINER_IMAGE_CREW and CONTAINER_IMAGE_LANGGRAPH in .env"
242+
in summary
243+
)
241244
assert 'pytest.fail(f"Deployment failed: {exc}")' not in summary

0 commit comments

Comments
 (0)