t-bug-catcher 0.5.10__tar.gz → 0.6.1__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (26) hide show
  1. {t_bug_catcher-0.5.10 → t_bug_catcher-0.6.1}/PKG-INFO +1 -1
  2. {t_bug_catcher-0.5.10 → t_bug_catcher-0.6.1}/setup.cfg +1 -1
  3. {t_bug_catcher-0.5.10 → t_bug_catcher-0.6.1}/setup.py +1 -1
  4. {t_bug_catcher-0.5.10 → t_bug_catcher-0.6.1}/t_bug_catcher/__init__.py +1 -1
  5. {t_bug_catcher-0.5.10 → t_bug_catcher-0.6.1}/t_bug_catcher/bug_catcher.py +3 -0
  6. {t_bug_catcher-0.5.10 → t_bug_catcher-0.6.1}/t_bug_catcher/jira.py +32 -24
  7. {t_bug_catcher-0.5.10 → t_bug_catcher-0.6.1}/t_bug_catcher/utils/common.py +14 -0
  8. {t_bug_catcher-0.5.10 → t_bug_catcher-0.6.1}/t_bug_catcher.egg-info/PKG-INFO +1 -1
  9. {t_bug_catcher-0.5.10 → t_bug_catcher-0.6.1}/MANIFEST.in +0 -0
  10. {t_bug_catcher-0.5.10 → t_bug_catcher-0.6.1}/README.rst +0 -0
  11. {t_bug_catcher-0.5.10 → t_bug_catcher-0.6.1}/pyproject.toml +0 -0
  12. {t_bug_catcher-0.5.10 → t_bug_catcher-0.6.1}/requirements.txt +0 -0
  13. {t_bug_catcher-0.5.10 → t_bug_catcher-0.6.1}/t_bug_catcher/bug_snag.py +0 -0
  14. {t_bug_catcher-0.5.10 → t_bug_catcher-0.6.1}/t_bug_catcher/config.py +0 -0
  15. {t_bug_catcher-0.5.10 → t_bug_catcher-0.6.1}/t_bug_catcher/exceptions.py +0 -0
  16. {t_bug_catcher-0.5.10 → t_bug_catcher-0.6.1}/t_bug_catcher/resources/whispers_config.yml +0 -0
  17. {t_bug_catcher-0.5.10 → t_bug_catcher-0.6.1}/t_bug_catcher/stack_saver.py +0 -0
  18. {t_bug_catcher-0.5.10 → t_bug_catcher-0.6.1}/t_bug_catcher/utils/__init__.py +0 -0
  19. {t_bug_catcher-0.5.10 → t_bug_catcher-0.6.1}/t_bug_catcher/utils/logger.py +0 -0
  20. {t_bug_catcher-0.5.10 → t_bug_catcher-0.6.1}/t_bug_catcher/workitems.py +0 -0
  21. {t_bug_catcher-0.5.10 → t_bug_catcher-0.6.1}/t_bug_catcher.egg-info/SOURCES.txt +0 -0
  22. {t_bug_catcher-0.5.10 → t_bug_catcher-0.6.1}/t_bug_catcher.egg-info/dependency_links.txt +0 -0
  23. {t_bug_catcher-0.5.10 → t_bug_catcher-0.6.1}/t_bug_catcher.egg-info/not-zip-safe +0 -0
  24. {t_bug_catcher-0.5.10 → t_bug_catcher-0.6.1}/t_bug_catcher.egg-info/requires.txt +0 -0
  25. {t_bug_catcher-0.5.10 → t_bug_catcher-0.6.1}/t_bug_catcher.egg-info/top_level.txt +0 -0
  26. {t_bug_catcher-0.5.10 → t_bug_catcher-0.6.1}/tests/test_t_bug_catcher.py +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: t_bug_catcher
3
- Version: 0.5.10
3
+ Version: 0.6.1
4
4
  Summary: Bug catcher
5
5
  Home-page: https://www.thoughtful.ai/
6
6
  Author: Thoughtful
@@ -1,5 +1,5 @@
1
1
  [bumpversion]
2
- current_version = 0.5.10
2
+ current_version = 0.6.1
3
3
  commit = True
4
4
  tag = False
5
5
 
@@ -26,7 +26,7 @@ setup(
26
26
  packages=find_packages(include=["t_bug_catcher", "t_bug_catcher.*"]),
27
27
  test_suite="tests",
28
28
  url="https://www.thoughtful.ai/",
29
- version="0.5.10",
29
+ version="0.6.1",
30
30
  zip_safe=False,
31
31
  install_requires=install_requirements,
32
32
  include_package_data=True,
@@ -3,7 +3,7 @@
3
3
  __author__ = """Thoughtful"""
4
4
  __email__ = "support@thoughtful.ai"
5
5
  # fmt: off
6
- __version__ = '0.5.10'
6
+ __version__ = '0.6.1'
7
7
  # fmt: on
8
8
 
9
9
  from .bug_catcher import (
@@ -110,6 +110,7 @@ class BugCatcher:
110
110
  metadata: Optional[dict] = None,
111
111
  attachments: Optional[List] = None,
112
112
  assignee: Optional[str] = None,
113
+ team: Optional[str] = None,
113
114
  ):
114
115
  """Reports an error to the Jira project.
115
116
 
@@ -119,6 +120,7 @@ class BugCatcher:
119
120
  metadata (dict, optional): The metadata to be added to the Jira issue. Defaults to None.
120
121
  attachments (List, optional): The attachments to be added to the Jira issue. Defaults to None.
121
122
  assignee (str, optional): The assignee to be added to the Jira issue. Defaults to None.
123
+ team (str, optional): The team to be assigned to the Jira issue. Defaults to None.
122
124
 
123
125
  Returns:
124
126
  None
@@ -175,6 +177,7 @@ class BugCatcher:
175
177
  self.__jira.report_error(
176
178
  exception=exception,
177
179
  assignee=assignee,
180
+ team=team,
178
181
  attachments=attachments,
179
182
  stack_trace=stack_trace,
180
183
  additional_info=description,
@@ -21,7 +21,7 @@ from retry import retry
21
21
  from .config import CONFIG
22
22
  from .exceptions import BadRequestError
23
23
  from .utils import logger
24
- from .utils.common import Encoder, get_frames, retrieve_build_info
24
+ from .utils.common import Encoder, get_frames, remove_holotree_id, retrieve_build_info
25
25
  from .workitems import variables
26
26
 
27
27
 
@@ -216,6 +216,7 @@ class Jira:
216
216
  assignee: Optional[str] = None,
217
217
  labels: Optional[list] = None,
218
218
  priority: Optional[str] = None,
219
+ team: Optional[str] = None,
219
220
  ) -> str:
220
221
  """Generates the issue body payload for creating a new issue.
221
222
 
@@ -226,6 +227,7 @@ class Jira:
226
227
  issue_type (str): The type of the issue.
227
228
  labels (list, optional): The labels of the issue. Defaults to None.
228
229
  priority (str, optional): The priority of the issue. Defaults to None.
230
+ team (str, optional): The team to be assigned to the Jira issue. Defaults to None.
229
231
 
230
232
  Returns:
231
233
  The JSON payload for creating a new issue.
@@ -246,6 +248,8 @@ class Jira:
246
248
  fields["fields"]["customfield_10077"] = [CONFIG.ADMIN_CODE]
247
249
  if priority:
248
250
  fields["fields"]["priority"] = {"id": priority}
251
+ if team:
252
+ fields["fields"]["customfield_10001"] = team
249
253
  payload = json.dumps(fields)
250
254
  return payload
251
255
 
@@ -1146,6 +1150,7 @@ class Jira:
1146
1150
  attachments: Optional[List] = None,
1147
1151
  labels: Optional[list] = None,
1148
1152
  priority: Optional[str] = None,
1153
+ team: Optional[str] = None,
1149
1154
  ) -> requests.Response:
1150
1155
  """Create a new ticket.
1151
1156
 
@@ -1156,6 +1161,7 @@ class Jira:
1156
1161
  attachments (List, optional): The list of attachments. Defaults to None.
1157
1162
  labels (List, optional): The list of labels. Defaults to None.
1158
1163
  priority (str, optional): The priority of the ticket. Defaults to None.
1164
+ team (str, optional): The team to be assigned to the Jira issue. Defaults to None.
1159
1165
 
1160
1166
  Returns:
1161
1167
  The response from creating the ticket.
@@ -1177,26 +1183,26 @@ class Jira:
1177
1183
  or self._issue_types.get("epic")
1178
1184
  )
1179
1185
 
1180
- issue = self.__generate_issue_body(
1181
- summary=summary[:255].split("\n")[0],
1182
- description=description,
1183
- assignee=assignee_id,
1184
- issue_type=issue_type,
1185
- project_key=project_key,
1186
- labels=labels,
1187
- priority=priority,
1188
- )
1186
+ issue_body = {
1187
+ "summary": summary[:255].split("\n")[0],
1188
+ "description": description,
1189
+ "assignee": assignee_id,
1190
+ "issue_type": issue_type,
1191
+ "project_key": project_key,
1192
+ "labels": labels,
1193
+ "priority": priority,
1194
+ "team": team,
1195
+ }
1196
+
1197
+ issue = self.__generate_issue_body(**issue_body)
1198
+
1189
1199
  response = self.post_ticket(issue=issue)
1190
1200
 
1191
- if response.json().get("errors", {}).get("labels"):
1192
- issue = self.__generate_issue_body(
1193
- summary=summary[:255].split("\n")[0],
1194
- description=description,
1195
- assignee=assignee_id,
1196
- issue_type=issue_type,
1197
- project_key=project_key,
1198
- priority=priority,
1199
- )
1201
+ errors = response.json().get("errors", {})
1202
+
1203
+ if errors:
1204
+ issue_body = {key: value for key, value in issue_body.items() if key not in errors}
1205
+ issue = self.__generate_issue_body(**issue_body)
1200
1206
  response = self.post_ticket(issue=issue)
1201
1207
 
1202
1208
  if response.status_code != 201:
@@ -1271,6 +1277,7 @@ class Jira:
1271
1277
  self,
1272
1278
  exception: Optional[Exception] = None,
1273
1279
  assignee: Optional[str] = None,
1280
+ team: Optional[str] = None,
1274
1281
  attachments: Union[List, str, Path, None] = None,
1275
1282
  stack_trace: Optional[str] = None,
1276
1283
  metadata: Optional[dict] = None,
@@ -1281,6 +1288,7 @@ class Jira:
1281
1288
  Args:
1282
1289
  exception (Exception, optional): The exception to be added to the Jira issue.
1283
1290
  assignee (str, optional): The assignee to be added to the Jira issue.
1291
+ team (str, optional): The team to be assigned to the Jira issue. Defaults to None.
1284
1292
  attachments (List, optional): List of attachments to be added to the Jira issue.
1285
1293
  stack_trace (str, optional): Stack trace to be added to the Jira issue.
1286
1294
  metadata (dict, optional): Metadata to be added to the Jira issue.
@@ -1349,7 +1357,7 @@ class Jira:
1349
1357
  metadata=metadata,
1350
1358
  )
1351
1359
 
1352
- priority = CONFIG.TICKET_PRIORITIES.HIGH if CONFIG.STAGE and CONFIG.STAGE.lower() == "hypercare" else None
1360
+ priority = CONFIG.TICKET_PRIORITIES.HIGH
1353
1361
 
1354
1362
  response = self.__create_new_ticket(
1355
1363
  summary=summary,
@@ -1358,6 +1366,7 @@ class Jira:
1358
1366
  attachments=attachments,
1359
1367
  labels=["bug_catcher"],
1360
1368
  priority=priority,
1369
+ team=team,
1361
1370
  )
1362
1371
  if stack_trace and os.path.exists(stack_trace):
1363
1372
  os.remove(stack_trace)
@@ -1412,9 +1421,7 @@ class Jira:
1412
1421
  error_id=error_id,
1413
1422
  )
1414
1423
 
1415
- priority = (
1416
- CONFIG.TICKET_PRIORITIES.HIGHEST if CONFIG.STAGE and CONFIG.STAGE.lower() == "hypercare" else None
1417
- )
1424
+ priority = CONFIG.TICKET_PRIORITIES.HIGHEST
1418
1425
 
1419
1426
  response = self.__create_new_ticket(
1420
1427
  summary=summary,
@@ -1638,7 +1645,8 @@ class Jira:
1638
1645
  exception_chain = "-".join([f"{frame.name}" for frame in frames])
1639
1646
  rel_path = os.path.relpath(frames[-1].filename, os.getcwd())
1640
1647
  path = Path(os.path.splitext(rel_path)[0]).as_posix()
1641
- error_id = f"{path}-{exception_chain}-{frames[-1].line}-" f"{exc_type.__module__}-{exc_type.__name__}"
1648
+ path = remove_holotree_id(path)
1649
+ error_id = f"{path}-{exception_chain}-{frames[-1].line}-{exc_type.__module__}-{exc_type.__name__}"
1642
1650
  return hashlib.md5(error_id.encode()).hexdigest()
1643
1651
 
1644
1652
  @staticmethod
@@ -1,6 +1,7 @@
1
1
  import copy
2
2
  import json
3
3
  import os
4
+ import re
4
5
  import traceback
5
6
  import urllib
6
7
  from datetime import date, datetime
@@ -101,6 +102,19 @@ def strip_path(path: str):
101
102
  return path.replace(os.getcwd(), "").strip(os.sep)
102
103
 
103
104
 
105
+ def remove_holotree_id(path: str) -> str:
106
+ """A function to remove the value after 'holotree' from the path.
107
+
108
+ Args:
109
+ path (str): The path from which to remove the value after 'holotree'.
110
+
111
+ Returns:
112
+ str: The modified path.
113
+ """
114
+ pattern = r"(holotree\/)[^\/]+\/"
115
+ return re.sub(pattern, r"\1", path)
116
+
117
+
104
118
  def retrieve_build_info():
105
119
  """Logs build information."""
106
120
  if not os.path.exists(CONFIG.BUILD_INFO_FILE):
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: t_bug_catcher
3
- Version: 0.5.10
3
+ Version: 0.6.1
4
4
  Summary: Bug catcher
5
5
  Home-page: https://www.thoughtful.ai/
6
6
  Author: Thoughtful
File without changes