logdetective 0.5.11__py3-none-any.whl → 0.9.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.
logdetective/utils.py CHANGED
@@ -2,12 +2,14 @@ import logging
2
2
  import os
3
3
  from typing import Iterator, List, Dict, Tuple, Generator
4
4
  from urllib.parse import urlparse
5
+
6
+ import aiohttp
5
7
  import numpy as np
6
- import requests
7
8
  import yaml
8
9
 
9
10
  from llama_cpp import Llama, CreateCompletionResponse, CreateCompletionStreamResponse
10
11
  from logdetective.models import PromptConfig
12
+ from logdetective.server.remote_log import RemoteLog
11
13
 
12
14
 
13
15
  LOG = logging.getLogger("logdetective")
@@ -111,8 +113,7 @@ def compute_certainty(probs: List[Dict]) -> float:
111
113
 
112
114
 
113
115
  def process_log(
114
- log: str, model: Llama, stream: bool, prompt_template: str,
115
- temperature: float
116
+ log: str, model: Llama, stream: bool, prompt_template: str, temperature: float
116
117
  ) -> CreateCompletionResponse | Iterator[CreateCompletionStreamResponse]:
117
118
  """Processes a given log using the provided language model and returns its summary.
118
119
 
@@ -126,14 +127,17 @@ def process_log(
126
127
  str: The summary of the given log generated by the language model.
127
128
  """
128
129
  response = model(
129
- prompt=prompt_template.format(log), stream=stream, max_tokens=0, logprobs=1,
130
- temperature=temperature
130
+ prompt=prompt_template.format(log),
131
+ stream=stream,
132
+ max_tokens=0,
133
+ logprobs=1,
134
+ temperature=temperature,
131
135
  )
132
136
 
133
137
  return response
134
138
 
135
139
 
136
- def retrieve_log_content(log_path: str) -> str:
140
+ async def retrieve_log_content(http: aiohttp.ClientSession, log_path: str) -> str:
137
141
  """Get content of the file on the log_path path.
138
142
  Path is assumed to be valid URL if it has a scheme.
139
143
  Otherwise it attempts to pull it from local filesystem."""
@@ -148,7 +152,8 @@ def retrieve_log_content(log_path: str) -> str:
148
152
  log = f.read()
149
153
 
150
154
  else:
151
- log = requests.get(log_path, timeout=60).text
155
+ remote_log = RemoteLog(log_path, http)
156
+ log = await remote_log.get_url_content()
152
157
 
153
158
  return log
154
159
 
@@ -180,21 +185,6 @@ def format_snippets(snippets: list[str] | list[Tuple[int, str]]) -> str:
180
185
  return summary
181
186
 
182
187
 
183
- def validate_url(url: str) -> bool:
184
- """Validate incoming URL to be at least somewhat sensible for log files
185
- Only http and https protocols permitted. No result, params or query fields allowed.
186
- Either netloc or path must have non-zero length.
187
- """
188
- result = urlparse(url)
189
- if result.scheme not in ["http", "https"]:
190
- return False
191
- if any([result.params, result.query, result.fragment]):
192
- return False
193
- if not (result.path or result.netloc):
194
- return False
195
- return True
196
-
197
-
198
188
  def load_prompts(path: str | None) -> PromptConfig:
199
189
  """Load prompts from given yaml file if there is one.
200
190
  Alternatively use defaults."""
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.3
2
2
  Name: logdetective
3
- Version: 0.5.11
3
+ Version: 0.9.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
6
  Author: Jiri Podivin
@@ -20,7 +20,9 @@ Classifier: Topic :: Scientific/Engineering :: Artificial Intelligence
20
20
  Classifier: Topic :: Software Development :: Debuggers
21
21
  Provides-Extra: server
22
22
  Provides-Extra: server-testing
23
+ Requires-Dist: aiohttp (>=3.7.4)
23
24
  Requires-Dist: alembic (>=1.13.3,<2.0.0) ; extra == "server" or extra == "server-testing"
25
+ Requires-Dist: backoff (==2.2.1) ; extra == "server" or extra == "server-testing"
24
26
  Requires-Dist: drain3 (>=0.9.11,<0.10.0)
25
27
  Requires-Dist: fastapi (>=0.111.1) ; extra == "server" or extra == "server-testing"
26
28
  Requires-Dist: huggingface-hub (>0.23.2)
@@ -32,7 +34,7 @@ Requires-Dist: psycopg2-binary (>=2.9.9,<3.0.0) ; extra == "server-testing"
32
34
  Requires-Dist: pydantic (>=2.8.2,<3.0.0)
33
35
  Requires-Dist: python-gitlab (>=4.4.0)
34
36
  Requires-Dist: pyyaml (>=6.0.1,<7.0.0)
35
- Requires-Dist: requests (>0.2.31)
37
+ Requires-Dist: sentry-sdk[fastapi] (>=2.17.0,<3.0.0)
36
38
  Requires-Dist: sqlalchemy (>=2.0.36,<3.0.0) ; extra == "server" or extra == "server-testing"
37
39
  Project-URL: homepage, https://github.com/fedora-copr/logdetective
38
40
  Project-URL: issues, https://github.com/fedora-copr/logdetective/issues
@@ -357,13 +359,16 @@ When no time period is specified, the query defaults to the last 2 days:
357
359
 
358
360
  You can view requests and responses statistics
359
361
  - for the `/analyze` endpoint at http://localhost:8080/metrics/analyze
360
- - for the `/analyze/staged` endpoint at http://localhost:8080/metrics/analyze/staged.
362
+ - for the `/analyze-staged` endpoint at http://localhost:8080/metrics/analyze-staged.
363
+ - for the requests coming from gitlab: http://localhost:8080/metrics/analyze-gitlab.
361
364
 
362
365
  You can retrieve single svg images at the following endpoints:
363
- - `/metrics/analyze/requests`
364
- - `/metrics/analyze/responses`
365
- - `/metrics/analyze/staged/requests`
366
- - `/metrics/analyze/stages/responses`
366
+ - http://localhost:8080/metrics/analyze/requests
367
+ - http://localhost:8080/metrics/analyze/responses
368
+ - http://localhost:8080/metrics/analyze-staged/requests
369
+ - http://localhost:8080/metrics/analyze-staged/responses
370
+ - http://localhost:8080/metrics/analyze-gitlab/requests
371
+ - http://localhost:8080/metrics/analyze-gitlab/responses
367
372
 
368
373
  Examples:
369
374
 
@@ -0,0 +1,28 @@
1
+ logdetective/__init__.py,sha256=VqRngDcuFT7JWms8Qc_MsOvajoXVOKPr-S1kqY3Pqhc,59
2
+ logdetective/constants.py,sha256=A5PzeqlQqDbBS_kzP2hl-lhJ0lCEqdbvW3CaQUYVxjw,1849
3
+ logdetective/drain3.ini,sha256=ni91eCT1TwTznZwcqWoOVMQcGEnWhEDNCoTPF7cfGfY,1360
4
+ logdetective/extractors.py,sha256=7ahzWbTtU9MveG1Q7wU9LO8OJgs85X-cHmWltUhCe9M,3491
5
+ logdetective/logdetective.py,sha256=cC2oL4yPNo94AB2nS4v1jpZi-Qo1g0_FEchL_yQL1UU,5832
6
+ logdetective/models.py,sha256=nrGBmMRu8i6UhFflQKAp81Y3Sd_Aaoor0i_yqSJoLT0,1115
7
+ logdetective/prompts.yml,sha256=urPKG068TYxi58EicFVUH6FavZq_q36oM1LvfI4ddjg,1729
8
+ logdetective/server/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
9
+ logdetective/server/compressors.py,sha256=oT-jQPX3VfYzG0rIhvrQSR6oW_5FNkBGjaKbXIHmbGQ,4261
10
+ logdetective/server/database/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
11
+ logdetective/server/database/base.py,sha256=1mcjEbhwLl4RalvT3oy6XVctjJoWIW3H9aI_sMWJBK8,1728
12
+ logdetective/server/database/models/__init__.py,sha256=xy2hkygyw6_87zPKkG20i7g7_LXTGR__PUeojhbvv94,496
13
+ logdetective/server/database/models/merge_request_jobs.py,sha256=hrtZdYO09p8bMjOpjP2KEQeBj3_-fsb89-Br0Myk-yo,15571
14
+ logdetective/server/database/models/metrics.py,sha256=yl9fS4IPVFWDeFvPAxO6zOVu6oLF319ApvVLAgnD5yU,13928
15
+ logdetective/server/metric.py,sha256=DyhbFuQIBX8mUC27ilPenphPKVZ3tSjrvRwe_Lu4Gw8,3301
16
+ logdetective/server/models.py,sha256=XlaIElxraZnUVjE--UTgUcinMVwicQFV_l5QbvkMsY4,8674
17
+ logdetective/server/plot.py,sha256=B2rOngqx7g-Z3NfttboTip3frkypdF1H7FhK8vh45mE,9655
18
+ logdetective/server/remote_log.py,sha256=BHCIWCppIRoT6MJfJvXtmbrG5BpGqFuULyAaC0WrTDo,3274
19
+ logdetective/server/server.py,sha256=MUnaJETQlJD2ISzkx835eFnwMNgWCosf7iqv3zdYSM8,33783
20
+ logdetective/server/templates/gitlab_full_comment.md.j2,sha256=DQZ2WVFedpuXI6znbHIW4wpF9BmFS8FaUkowh8AnGhE,1627
21
+ logdetective/server/templates/gitlab_short_comment.md.j2,sha256=fzScpayv2vpRLczP_0O0YxtA8rsKvR6gSv4ntNdWb98,1443
22
+ logdetective/server/utils.py,sha256=QO0H1q55YLCLKxkViqex4Uu31LnakpYUKJfZHysonSc,1838
23
+ logdetective/utils.py,sha256=zghwtFSagHTmO0qrYAfXZfUEnt-BdnqD7DEGv6SbvpE,6095
24
+ logdetective-0.9.0.dist-info/LICENSE,sha256=z8d0m5b2O9McPEK1xHG_dWgUBT6EfBDz6wA0F7xSPTA,11358
25
+ logdetective-0.9.0.dist-info/METADATA,sha256=DwnAmPZMQ9Mr0sulWx1_R0TsqiA4lEDFQfTDAC8rSd0,16292
26
+ logdetective-0.9.0.dist-info/WHEEL,sha256=fGIA9gx4Qxk2KDKeNJCbOEwSrmLtjWCwzBz351GyrPQ,88
27
+ logdetective-0.9.0.dist-info/entry_points.txt,sha256=3K_vXja6PmcA8sNdUi63WdImeiNhVZcEGPTaoJmltfA,63
28
+ logdetective-0.9.0.dist-info/RECORD,,
@@ -1,24 +0,0 @@
1
- logdetective/__init__.py,sha256=VqRngDcuFT7JWms8Qc_MsOvajoXVOKPr-S1kqY3Pqhc,59
2
- logdetective/constants.py,sha256=A5PzeqlQqDbBS_kzP2hl-lhJ0lCEqdbvW3CaQUYVxjw,1849
3
- logdetective/drain3.ini,sha256=ni91eCT1TwTznZwcqWoOVMQcGEnWhEDNCoTPF7cfGfY,1360
4
- logdetective/extractors.py,sha256=7ahzWbTtU9MveG1Q7wU9LO8OJgs85X-cHmWltUhCe9M,3491
5
- logdetective/logdetective.py,sha256=Q1SfQ9sWR5sIvHJag61-F-8edwf7p1SV7QZRg9VaWcc,5604
6
- logdetective/models.py,sha256=nrGBmMRu8i6UhFflQKAp81Y3Sd_Aaoor0i_yqSJoLT0,1115
7
- logdetective/prompts.yml,sha256=dMW2-bdTIqv7LF_owqRD4xinMK5ZWcNhDynnX1zoKns,1722
8
- logdetective/server/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
9
- logdetective/server/database/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
10
- logdetective/server/database/base.py,sha256=oMJUvbWeapIUP-8Cf_DR9ptFg8CsYeaBAIjOVEzx8SM,1668
11
- logdetective/server/database/models.py,sha256=m_3qNBWJwLSwjJn0AmwSxXMJk75Gu1bXFtGAP_4zps4,14088
12
- logdetective/server/metric.py,sha256=-uM_-yqxNA-EZTCnNRdQ8g1MicmE5eC6jRFI_mBBYUg,2606
13
- logdetective/server/models.py,sha256=URqZcfx5yUsifZ1pOwZ_uU3Tyjcdvuq6qEnAvTexl4A,8475
14
- logdetective/server/plot.py,sha256=B2rOngqx7g-Z3NfttboTip3frkypdF1H7FhK8vh45mE,9655
15
- logdetective/server/server.py,sha256=4NylBojHm9E3gjByVWs870T204ls39EbZmUfU0Kyq4U,28395
16
- logdetective/server/templates/gitlab_full_comment.md.j2,sha256=DQZ2WVFedpuXI6znbHIW4wpF9BmFS8FaUkowh8AnGhE,1627
17
- logdetective/server/templates/gitlab_short_comment.md.j2,sha256=fzScpayv2vpRLczP_0O0YxtA8rsKvR6gSv4ntNdWb98,1443
18
- logdetective/server/utils.py,sha256=QO0H1q55YLCLKxkViqex4Uu31LnakpYUKJfZHysonSc,1838
19
- logdetective/utils.py,sha256=nklnTipAet9P9aEiuHcnK62WT0DmNHbvO1TvNlrxlik,6463
20
- logdetective-0.5.11.dist-info/LICENSE,sha256=z8d0m5b2O9McPEK1xHG_dWgUBT6EfBDz6wA0F7xSPTA,11358
21
- logdetective-0.5.11.dist-info/METADATA,sha256=LOOzu99kJaP02U2OaFQciPdWKhlgr4Vm4tVKijTY7NM,15882
22
- logdetective-0.5.11.dist-info/WHEEL,sha256=fGIA9gx4Qxk2KDKeNJCbOEwSrmLtjWCwzBz351GyrPQ,88
23
- logdetective-0.5.11.dist-info/entry_points.txt,sha256=3K_vXja6PmcA8sNdUi63WdImeiNhVZcEGPTaoJmltfA,63
24
- logdetective-0.5.11.dist-info/RECORD,,