logdetective 2.2.0__py3-none-any.whl → 2.3.0__py3-none-any.whl

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.
@@ -26,6 +26,9 @@ class Extractor:
26
26
  self.skip_snippets = skip_snippets
27
27
  self.max_snippet_len = max_snippet_len
28
28
 
29
+ if self.verbose:
30
+ LOG.setLevel(logging.DEBUG)
31
+
29
32
  def __call__(self, log: str) -> list[Tuple[int, str]]:
30
33
  raise NotImplementedError
31
34
 
@@ -11,9 +11,13 @@ import gitlab.v4
11
11
  import gitlab.v4.objects
12
12
  import jinja2
13
13
  import aiohttp
14
+ import backoff
14
15
 
15
16
  from logdetective.server.config import SERVER_CONFIG, LOG
16
- from logdetective.server.exceptions import LogsTooLargeError
17
+ from logdetective.server.exceptions import (
18
+ LogsTooLargeError,
19
+ LogDetectiveConnectionError,
20
+ )
17
21
  from logdetective.server.llm import perform_staged_analysis
18
22
  from logdetective.server.metric import add_new_metrics, update_metrics
19
23
  from logdetective.server.models import (
@@ -29,6 +33,7 @@ from logdetective.server.database.models import (
29
33
  GitlabMergeRequestJobs,
30
34
  )
31
35
  from logdetective.server.compressors import RemoteLogCompressor
36
+ from logdetective.server.utils import connection_error_giveup
32
37
 
33
38
  MR_REGEX = re.compile(r"refs/merge-requests/(\d+)/.*$")
34
39
  FAILURE_LOG_REGEX = re.compile(r"(\w*\.log)")
@@ -91,8 +96,8 @@ async def process_gitlab_job_event(
91
96
  log_url, preprocessed_log = await retrieve_and_preprocess_koji_logs(
92
97
  gitlab_cfg, job
93
98
  )
94
- except LogsTooLargeError:
95
- LOG.error("Could not retrieve logs. Too large.")
99
+ except (LogsTooLargeError, LogDetectiveConnectionError) as ex:
100
+ LOG.error("Could not retrieve logs due to %s", ex)
96
101
  raise
97
102
 
98
103
  # Submit log to Log Detective and await the results.
@@ -151,6 +156,9 @@ def is_eligible_package(project_name: str):
151
156
  return True
152
157
 
153
158
 
159
+ @backoff.on_exception(
160
+ backoff.expo, ConnectionResetError, max_time=60, on_giveup=connection_error_giveup
161
+ )
154
162
  async def retrieve_and_preprocess_koji_logs(
155
163
  gitlab_cfg: GitLabInstanceConfig,
156
164
  job: gitlab.v4.objects.ProjectJob,
@@ -256,8 +264,7 @@ async def retrieve_and_preprocess_koji_logs(
256
264
  LOG.debug("Failed architecture: %s", failed_arch)
257
265
 
258
266
  log_path = failed_arches[failed_arch].as_posix()
259
-
260
- log_url = f"{gitlab_cfg.api_path}/projects/{job.project_id}/jobs/{job.id}/artifacts/{log_path}" # pylint: disable=line-too-long
267
+ log_url = f"{gitlab_cfg.url}/{gitlab_cfg.api_path}/projects/{job.project_id}/jobs/{job.id}/artifacts/{log_path}" # pylint: disable=line-too-long
261
268
  LOG.debug("Returning contents of %s%s", gitlab_cfg.url, log_url)
262
269
 
263
270
  # Return the log as a file-like object with .read() function
@@ -307,6 +307,7 @@ class GitLabInstanceConfig(BaseModel): # pylint: disable=too-many-instance-attr
307
307
 
308
308
  name: str = None
309
309
  url: str = None
310
+ # Path to API of the gitlab instance, assuming `url` as prefix.
310
311
  api_path: str = None
311
312
  api_token: str = None
312
313
 
@@ -106,35 +106,35 @@ async def get_http_session(request: Request) -> aiohttp.ClientSession:
106
106
  return request.app.http
107
107
 
108
108
 
109
- def requires_token_when_set(authentication: Annotated[str | None, Header()] = None):
109
+ def requires_token_when_set(authorization: Annotated[str | None, Header()] = None):
110
110
  """
111
- FastAPI Depend function that expects a header named Authentication
111
+ FastAPI Depend function that expects a header named Authorization
112
112
 
113
113
  If LOGDETECTIVE_TOKEN env var is set, validate the client-supplied token
114
114
  otherwise ignore it
115
115
  """
116
116
  if not API_TOKEN:
117
- LOG.info("LOGDETECTIVE_TOKEN env var not set, authentication disabled")
117
+ LOG.info("LOGDETECTIVE_TOKEN env var not set, authorization disabled")
118
118
  # no token required, means local dev environment
119
119
  return
120
- if authentication:
120
+ if authorization:
121
121
  try:
122
- token = authentication.split(" ", 1)[1]
122
+ token = authorization.split(" ", 1)[1]
123
123
  except (ValueError, IndexError) as ex:
124
124
  LOG.warning(
125
- "Authentication header has invalid structure '%s', it should be 'Bearer TOKEN'",
126
- authentication,
125
+ "Authorization header has invalid structure '%s', it should be 'Bearer TOKEN'",
126
+ authorization,
127
127
  )
128
128
  # eat the exception and raise 401 below
129
129
  raise HTTPException(
130
130
  status_code=401,
131
- detail=f"Invalid authentication, HEADER '{authentication}' not valid.",
131
+ detail=f"Invalid authorization, HEADER '{authorization}' not valid.",
132
132
  ) from ex
133
133
  if token == API_TOKEN:
134
134
  return
135
135
  LOG.info("Provided token '%s' does not match expected value.", token)
136
136
  raise HTTPException(status_code=401, detail=f"Token '{token}' not valid.")
137
- LOG.error("No authentication header provided but LOGDETECTIVE_TOKEN env var is set")
137
+ LOG.error("No authorization header provided but LOGDETECTIVE_TOKEN env var is set")
138
138
  raise HTTPException(status_code=401, detail="No token provided.")
139
139
 
140
140
 
@@ -1,8 +1,9 @@
1
- Metadata-Version: 2.3
1
+ Metadata-Version: 2.4
2
2
  Name: logdetective
3
- Version: 2.2.0
3
+ Version: 2.3.0
4
4
  Summary: Log using LLM AI to search for build/test failures and provide ideas for fixing these.
5
5
  License: Apache-2.0
6
+ License-File: LICENSE
6
7
  Author: Jiri Podivin
7
8
  Author-email: jpodivin@gmail.com
8
9
  Requires-Python: >=3.11,<4.0
@@ -15,6 +16,7 @@ Classifier: Programming Language :: Python :: 3
15
16
  Classifier: Programming Language :: Python :: 3.11
16
17
  Classifier: Programming Language :: Python :: 3.12
17
18
  Classifier: Programming Language :: Python :: 3.13
19
+ Classifier: Programming Language :: Python :: 3.14
18
20
  Classifier: Topic :: Internet :: Log Analysis
19
21
  Classifier: Topic :: Scientific/Engineering :: Artificial Intelligence
20
22
  Classifier: Topic :: Software Development :: Debuggers
@@ -93,12 +95,13 @@ Usage
93
95
  -----
94
96
 
95
97
  To analyze a log file, run the script with the following command line arguments:
96
- - `url` (required): The URL of the log file to be analyzed.
97
- - `--model` (optional, default: "Mistral-7B-Instruct-v0.2-GGUF"): The path or URL of the language model for analysis. As we are using LLama.cpp we want this to be in the `gguf` format. You can include the download link to the model here. If the model is already on your machine it will skip the download.
98
+ - `file` (required): The path or URL of the log file to be analyzed.
99
+ - `--model` (optional, default: "Mistral-7B-Instruct-v0.3-GGUF"): The path or Hugging space name of the language model for analysis. For models from Hugging Face, write them as `namespace/repo_name`. As we are using LLama.cpp we want this to be in the `gguf` format. If the model is already on your machine it will skip the download.
100
+ - `--filename_suffix` (optional, default "Q4_K.gguf"): You can specify which suffix of the file to use. This option is applied when specifying model using the Hugging Face repository.
98
101
  - `--summarizer` DISABLED: LLM summarization option was removed. Argument is kept for backward compatibility only.(optional, default: "drain"): Choose between LLM and Drain template miner as the log summarizer. You can also provide the path to an existing language model file instead of using a URL.
99
102
  - `--n_lines` DISABLED: LLM summarization option was removed. Argument is kept for backward compatibility only. (optional, default: 8): The number of lines per chunk for LLM analysis. This only makes sense when you are summarizing with LLM.
100
- - `--n_clusters` (optional, default 8): Number of clusters for Drain to organize log chunks into. This only makes sense when you are summarizing with Drain
101
- - `--skip_snippets` Path to patterns for skipping snippets.
103
+ - `--n_clusters` (optional, default 8): Number of clusters for Drain to organize log chunks into. This only makes sense when you are summarizing with Drain.
104
+ - `--skip_snippets` Path to patterns for skipping snippets (in YAML).
102
105
 
103
106
  Example usage:
104
107
 
@@ -108,14 +111,10 @@ Or if the log file is stored locally:
108
111
 
109
112
  logdetective ./data/logs.txt
110
113
 
111
- Example you want to use a different model:
114
+ Examples of using different models. Note the use of `--filename_suffix` (or `-F`) option, useful for models that were quantized:
112
115
 
113
- logdetective https://example.com/logs.txt --model https://huggingface.co/QuantFactory/Meta-Llama-3-8B-Instruct-GGUF/resolve/main/Meta-Llama-3-8B-Instruct.Q5_K_S.gguf?download=true
114
- logdetective https://example.com/logs.txt --model QuantFactory/Meta-Llama-3-8B-Instruct-GGUF
115
-
116
- Example of different suffix (useful for models that were quantized)
117
-
118
- logdetective https://kojipkgs.fedoraproject.org//work/tasks/3367/131313367/build.log --model 'fedora-copr/granite-3.2-8b-instruct-GGUF' -F Q4_K.gguf
116
+ logdetective https://example.com/logs.txt --model QuantFactory/Meta-Llama-3-8B-Instruct-GGUF --filename_suffix Q5_K_S.gguf
117
+ logdetective https://kojipkgs.fedoraproject.org//work/tasks/3367/131313367/build.log --model 'fedora-copr/granite-3.2-8b-instruct-GGUF' -F Q4_K_M.gguf
119
118
 
120
119
  Example of altered prompts:
121
120
 
@@ -124,9 +123,9 @@ Example of altered prompts:
124
123
  logdetective https://kojipkgs.fedoraproject.org//work/tasks/3367/131313367/build.log --prompts ~/my-prompts.yml
125
124
 
126
125
 
127
- Note that streaming with some models (notably Meta-Llama-3 is broken) is broken and can be worked around by `no-stream` option:
126
+ Note that streaming with some models (notably Meta-Llama-3) is broken and can be worked around by `no-stream` option:
128
127
 
129
- logdetective https://example.com/logs.txt --model QuantFactory/Meta-Llama-3-8B-Instruct-GGUF --no-stream
128
+ logdetective https://example.com/logs.txt --model QuantFactory/Meta-Llama-3-8B-Instruct-GGUF --filename_suffix Q5_K_M.gguf --no-stream
130
129
 
131
130
 
132
131
  Real Example
@@ -1,7 +1,7 @@
1
1
  logdetective/__init__.py,sha256=VqRngDcuFT7JWms8Qc_MsOvajoXVOKPr-S1kqY3Pqhc,59
2
2
  logdetective/constants.py,sha256=aCwrkBrDdS_kbNESK-Z-ewg--DSzodV2OMgwEq3UE38,2456
3
3
  logdetective/drain3.ini,sha256=ni91eCT1TwTznZwcqWoOVMQcGEnWhEDNCoTPF7cfGfY,1360
4
- logdetective/extractors.py,sha256=Nh5wMcLXtcYLFAHwr6naCPPOtWzLUCW2iF__UKfckUY,5927
4
+ logdetective/extractors.py,sha256=vT-je4NkDgSj9rRtSeLpqBU52gIUnnVgJPHFbVihpCw,5993
5
5
  logdetective/logdetective.py,sha256=Ck7TL3YvdQG8zniudM8bM51LfTyVW6Ea3BarTjzjWHo,6606
6
6
  logdetective/models.py,sha256=uczmQtWFgSp_ZGssngdTM4qzPF1o64dCy0469GoSbjQ,2937
7
7
  logdetective/prompts-summary-first.yml,sha256=3Zfp4NNOfaFYq5xBlBjeQa5PdjYfS4v17OtJqQ-DRpU,821
@@ -20,20 +20,20 @@ logdetective/server/database/models/merge_request_jobs.py,sha256=q4reSC7YnEfWBPp
20
20
  logdetective/server/database/models/metrics.py,sha256=_UCaizcl9w4iX54EWvk5VvXeLcg2UfnQgXg4br3OLko,14214
21
21
  logdetective/server/emoji.py,sha256=hV4O0yfL0l1a3kWLImvBsY4AJQauKs7okYOGBEtYVz0,4795
22
22
  logdetective/server/exceptions.py,sha256=piV7wVKc-rw_pHrThbZbUjtmjuO5qUbjVNFwjdfcP3Q,864
23
- logdetective/server/gitlab.py,sha256=MrAprXLTN6Q15qBC_Y2y42iKdtmIfed_pfjEt0gABvc,16422
23
+ logdetective/server/gitlab.py,sha256=hPQICeYK1B_1BS56GIExQgEhcdS5Y6IgBCkk-eXtnDY,16708
24
24
  logdetective/server/koji.py,sha256=LG1pRiKUFvYFRKzgQoUG3pUHfcEwMoaMNjUSMKw_pBA,5640
25
25
  logdetective/server/llm.py,sha256=bmA6LsV80OdO60q4WLoKuehuVDEYq-HhBAYcZeLfrv8,10150
26
26
  logdetective/server/metric.py,sha256=QrrX1FmMa7sc57av0P9UFOiCIFYVLs1opOWV3ObYo0s,4086
27
- logdetective/server/models.py,sha256=rsdEf3lw0fvjWKhC9evaSsfZQR-H2mg0uig4KA6ho0c,20762
27
+ logdetective/server/models.py,sha256=jUzQUszMqgOeOrH1V2ORtejGrD1Nw1sX05bsbAyFvV4,20830
28
28
  logdetective/server/plot.py,sha256=C98U9prGoPkp8_t4v2dovdZuwOhSbxXSeB_K9Q2r3NE,14607
29
- logdetective/server/server.py,sha256=zap8Mz3NTFvaDJMNQDATbPYk6MhQ9o1J9gJECnGWvuQ,24694
29
+ logdetective/server/server.py,sha256=s1QtD6FYsQX7BaVi783v7sqCEk4ccqlBJHFKUQlGgWM,24684
30
30
  logdetective/server/templates/gitlab_full_comment.md.j2,sha256=H4NPjm3l8X5d0TNtfyZZZj_gHY1Y7hWEqY6RaVA8qt0,1947
31
31
  logdetective/server/templates/gitlab_short_comment.md.j2,sha256=vPisU1c98LPKEwlKtMrtlqnEOlbykPZK96MpHAf-o88,1758
32
32
  logdetective/server/utils.py,sha256=7ub-Nz7LUP_idwi2_nEC4FBuY9otSBUVy9nw86-sjYc,3861
33
33
  logdetective/skip_snippets.yml,sha256=reGlhPPCo06nNUJWiC2LY-OJOoPdcyOB7QBTSMeh0eg,487
34
34
  logdetective/utils.py,sha256=9EyHKGNxtS1ObSepL-T3M43rKIxQJkFDA5yllLbS5Bs,9178
35
- logdetective-2.2.0.dist-info/LICENSE,sha256=z8d0m5b2O9McPEK1xHG_dWgUBT6EfBDz6wA0F7xSPTA,11358
36
- logdetective-2.2.0.dist-info/METADATA,sha256=9bIs4_L1PPIilOBBsfoLULfTTtZ8RYLCmq_0XpxJHXQ,21455
37
- logdetective-2.2.0.dist-info/WHEEL,sha256=b4K_helf-jlQoXBBETfwnf4B04YC67LOev0jo4fX5m8,88
38
- logdetective-2.2.0.dist-info/entry_points.txt,sha256=3K_vXja6PmcA8sNdUi63WdImeiNhVZcEGPTaoJmltfA,63
39
- logdetective-2.2.0.dist-info/RECORD,,
35
+ logdetective-2.3.0.dist-info/METADATA,sha256=mQQpT-CjV5js3Rl0eU87hvvZcbheoUXV3niOTCjW6gY,21645
36
+ logdetective-2.3.0.dist-info/WHEEL,sha256=zp0Cn7JsFoX2ATtOhtaFYIiE2rmFAD4OcMhtUki8W3U,88
37
+ logdetective-2.3.0.dist-info/entry_points.txt,sha256=3K_vXja6PmcA8sNdUi63WdImeiNhVZcEGPTaoJmltfA,63
38
+ logdetective-2.3.0.dist-info/licenses/LICENSE,sha256=z8d0m5b2O9McPEK1xHG_dWgUBT6EfBDz6wA0F7xSPTA,11358
39
+ logdetective-2.3.0.dist-info/RECORD,,
@@ -1,4 +1,4 @@
1
1
  Wheel-Version: 1.0
2
- Generator: poetry-core 2.1.3
2
+ Generator: poetry-core 2.2.1
3
3
  Root-Is-Purelib: true
4
4
  Tag: py3-none-any