22
33import logging
44from datetime import timedelta
5- from functools import lru_cache
65from typing import Any
76
87import orjson
@@ -175,23 +174,21 @@ def _call_seer(
175174 return SummarizeIssueResponse .validate (response .json ())
176175
177176
178- @lru_cache (maxsize = 1 )
179- def create_fixability_connection_pool ():
180- return connection_from_url (
181- settings .SEER_SEVERITY_URL ,
182- timeout = settings .SEER_FIXABILITY_TIMEOUT ,
183- )
177+ fixability_connection_pool = connection_from_url (
178+ settings .SEER_SEVERITY_URL ,
179+ timeout = settings .SEER_FIXABILITY_TIMEOUT ,
180+ )
184181
185182
186- def _generate_fixability_score_via_conn_pool (group : Group ):
183+ def _generate_fixability_score (group : Group ):
187184 payload = {
188185 "group_id" : group .id ,
189186 "organization_slug" : group .organization .slug ,
190187 "organization_id" : group .organization .id ,
191188 "project_id" : group .project .id ,
192189 }
193190 response = make_signed_seer_api_request (
194- create_fixability_connection_pool () ,
191+ fixability_connection_pool ,
195192 "/v1/automation/summarize/fixability" ,
196193 body = orjson .dumps (payload , option = orjson .OPT_NON_STR_KEYS ),
197194 timeout = settings .SEER_FIXABILITY_TIMEOUT ,
@@ -202,33 +199,6 @@ def _generate_fixability_score_via_conn_pool(group: Group):
202199 return SummarizeIssueResponse .validate (response_data )
203200
204201
205- def _generate_fixability_score (group : Group ):
206- path = "/v1/automation/summarize/fixability"
207- body = orjson .dumps (
208- {
209- "group_id" : group .id ,
210- "organization_slug" : group .organization .slug ,
211- "organization_id" : group .organization .id ,
212- "project_id" : group .project .id ,
213- },
214- option = orjson .OPT_NON_STR_KEYS ,
215- )
216-
217- response = requests .post (
218- f"{ settings .SEER_SEVERITY_URL } { path } " ,
219- data = body ,
220- headers = {
221- "content-type" : "application/json;charset=utf-8" ,
222- ** sign_with_seer_secret (body ),
223- },
224- timeout = settings .SEER_FIXABILITY_TIMEOUT ,
225- )
226-
227- response .raise_for_status ()
228-
229- return SummarizeIssueResponse .validate (response .json ())
230-
231-
232202def _get_trace_connected_issues (event : GroupEvent ) -> list [Group ]:
233203 try :
234204 trace_id = event .trace_id
@@ -324,10 +294,7 @@ def _run_automation(
324294 )
325295
326296 with sentry_sdk .start_span (op = "ai_summary.generate_fixability_score" ):
327- if group .organization .id == 1 : # TODO(kddubey): rm temp guard
328- issue_summary = _generate_fixability_score_via_conn_pool (group )
329- else :
330- issue_summary = _generate_fixability_score (group )
297+ issue_summary = _generate_fixability_score (group )
331298
332299 if not issue_summary .scores :
333300 raise ValueError ("Issue summary scores is None or empty." )
0 commit comments