logdetective 0.6.0__py3-none-any.whl → 0.9.1__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/prompts.yml +4 -4
- logdetective/server/compressors.py +144 -0
- logdetective/server/database/base.py +3 -0
- logdetective/server/database/models/__init__.py +21 -0
- logdetective/server/database/models/merge_request_jobs.py +515 -0
- logdetective/server/database/{models.py → models/metrics.py} +105 -100
- logdetective/server/metric.py +40 -16
- logdetective/server/models.py +12 -3
- logdetective/server/remote_log.py +109 -0
- logdetective/server/server.py +287 -136
- logdetective/utils.py +9 -37
- {logdetective-0.6.0.dist-info → logdetective-0.9.1.dist-info}/METADATA +11 -6
- logdetective-0.9.1.dist-info/RECORD +28 -0
- {logdetective-0.6.0.dist-info → logdetective-0.9.1.dist-info}/WHEEL +1 -1
- logdetective-0.6.0.dist-info/RECORD +0 -24
- {logdetective-0.6.0.dist-info → logdetective-0.9.1.dist-info}/LICENSE +0 -0
- {logdetective-0.6.0.dist-info → logdetective-0.9.1.dist-info}/entry_points.txt +0 -0
logdetective/utils.py
CHANGED
|
@@ -9,6 +9,7 @@ import yaml
|
|
|
9
9
|
|
|
10
10
|
from llama_cpp import Llama, CreateCompletionResponse, CreateCompletionStreamResponse
|
|
11
11
|
from logdetective.models import PromptConfig
|
|
12
|
+
from logdetective.server.remote_log import RemoteLog
|
|
12
13
|
|
|
13
14
|
|
|
14
15
|
LOG = logging.getLogger("logdetective")
|
|
@@ -112,8 +113,7 @@ def compute_certainty(probs: List[Dict]) -> float:
|
|
|
112
113
|
|
|
113
114
|
|
|
114
115
|
def process_log(
|
|
115
|
-
log: str, model: Llama, stream: bool, prompt_template: str,
|
|
116
|
-
temperature: float
|
|
116
|
+
log: str, model: Llama, stream: bool, prompt_template: str, temperature: float
|
|
117
117
|
) -> CreateCompletionResponse | Iterator[CreateCompletionStreamResponse]:
|
|
118
118
|
"""Processes a given log using the provided language model and returns its summary.
|
|
119
119
|
|
|
@@ -127,30 +127,16 @@ def process_log(
|
|
|
127
127
|
str: The summary of the given log generated by the language model.
|
|
128
128
|
"""
|
|
129
129
|
response = model(
|
|
130
|
-
prompt=prompt_template.format(log),
|
|
131
|
-
|
|
130
|
+
prompt=prompt_template.format(log),
|
|
131
|
+
stream=stream,
|
|
132
|
+
max_tokens=0,
|
|
133
|
+
logprobs=1,
|
|
134
|
+
temperature=temperature,
|
|
132
135
|
)
|
|
133
136
|
|
|
134
137
|
return response
|
|
135
138
|
|
|
136
139
|
|
|
137
|
-
async def get_url_content(http: aiohttp.ClientSession, url: str, timeout: int) -> str:
|
|
138
|
-
"""validate log url and return log text."""
|
|
139
|
-
if validate_url(url=url):
|
|
140
|
-
LOG.debug("process url %s", url)
|
|
141
|
-
try:
|
|
142
|
-
response = await http.get(
|
|
143
|
-
url,
|
|
144
|
-
timeout=timeout,
|
|
145
|
-
raise_for_status=True
|
|
146
|
-
)
|
|
147
|
-
except aiohttp.ClientResponseError as ex:
|
|
148
|
-
raise RuntimeError(f"We couldn't obtain the logs: {ex}") from ex
|
|
149
|
-
return await response.text()
|
|
150
|
-
LOG.error("Invalid URL received ")
|
|
151
|
-
raise RuntimeError(f"Invalid log URL: {url}")
|
|
152
|
-
|
|
153
|
-
|
|
154
140
|
async def retrieve_log_content(http: aiohttp.ClientSession, log_path: str) -> str:
|
|
155
141
|
"""Get content of the file on the log_path path.
|
|
156
142
|
Path is assumed to be valid URL if it has a scheme.
|
|
@@ -166,7 +152,8 @@ async def retrieve_log_content(http: aiohttp.ClientSession, log_path: str) -> st
|
|
|
166
152
|
log = f.read()
|
|
167
153
|
|
|
168
154
|
else:
|
|
169
|
-
|
|
155
|
+
remote_log = RemoteLog(log_path, http)
|
|
156
|
+
log = await remote_log.get_url_content()
|
|
170
157
|
|
|
171
158
|
return log
|
|
172
159
|
|
|
@@ -198,21 +185,6 @@ def format_snippets(snippets: list[str] | list[Tuple[int, str]]) -> str:
|
|
|
198
185
|
return summary
|
|
199
186
|
|
|
200
187
|
|
|
201
|
-
def validate_url(url: str) -> bool:
|
|
202
|
-
"""Validate incoming URL to be at least somewhat sensible for log files
|
|
203
|
-
Only http and https protocols permitted. No result, params or query fields allowed.
|
|
204
|
-
Either netloc or path must have non-zero length.
|
|
205
|
-
"""
|
|
206
|
-
result = urlparse(url)
|
|
207
|
-
if result.scheme not in ["http", "https"]:
|
|
208
|
-
return False
|
|
209
|
-
if any([result.params, result.query, result.fragment]):
|
|
210
|
-
return False
|
|
211
|
-
if not (result.path or result.netloc):
|
|
212
|
-
return False
|
|
213
|
-
return True
|
|
214
|
-
|
|
215
|
-
|
|
216
188
|
def load_prompts(path: str | None) -> PromptConfig:
|
|
217
189
|
"""Load prompts from given yaml file if there is one.
|
|
218
190
|
Alternatively use defaults."""
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.3
|
|
2
2
|
Name: logdetective
|
|
3
|
-
Version: 0.
|
|
3
|
+
Version: 0.9.1
|
|
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
|
|
@@ -22,6 +22,7 @@ Provides-Extra: server
|
|
|
22
22
|
Provides-Extra: server-testing
|
|
23
23
|
Requires-Dist: aiohttp (>=3.7.4)
|
|
24
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"
|
|
25
26
|
Requires-Dist: drain3 (>=0.9.11,<0.10.0)
|
|
26
27
|
Requires-Dist: fastapi (>=0.111.1) ; extra == "server" or extra == "server-testing"
|
|
27
28
|
Requires-Dist: huggingface-hub (>0.23.2)
|
|
@@ -33,6 +34,7 @@ Requires-Dist: psycopg2-binary (>=2.9.9,<3.0.0) ; extra == "server-testing"
|
|
|
33
34
|
Requires-Dist: pydantic (>=2.8.2,<3.0.0)
|
|
34
35
|
Requires-Dist: python-gitlab (>=4.4.0)
|
|
35
36
|
Requires-Dist: pyyaml (>=6.0.1,<7.0.0)
|
|
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
|
|
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
|
-
-
|
|
364
|
-
-
|
|
365
|
-
-
|
|
366
|
-
-
|
|
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.1.dist-info/LICENSE,sha256=z8d0m5b2O9McPEK1xHG_dWgUBT6EfBDz6wA0F7xSPTA,11358
|
|
25
|
+
logdetective-0.9.1.dist-info/METADATA,sha256=gPt7wf0Lm6lFNOeDST6AK9eoxe5PD072CrfEs0nAwSg,16292
|
|
26
|
+
logdetective-0.9.1.dist-info/WHEEL,sha256=b4K_helf-jlQoXBBETfwnf4B04YC67LOev0jo4fX5m8,88
|
|
27
|
+
logdetective-0.9.1.dist-info/entry_points.txt,sha256=3K_vXja6PmcA8sNdUi63WdImeiNhVZcEGPTaoJmltfA,63
|
|
28
|
+
logdetective-0.9.1.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=cC2oL4yPNo94AB2nS4v1jpZi-Qo1g0_FEchL_yQL1UU,5832
|
|
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=AXduOwD6zPNFc-COw-JcTp4bPan9DfXJml52XiBHmds,29613
|
|
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=IBAH6hleuhtbA3cAGhiIDb3zwKaovunBfVsG0TKzoKA,7127
|
|
20
|
-
logdetective-0.6.0.dist-info/LICENSE,sha256=z8d0m5b2O9McPEK1xHG_dWgUBT6EfBDz6wA0F7xSPTA,11358
|
|
21
|
-
logdetective-0.6.0.dist-info/METADATA,sha256=zBYLi3jNjqR-6EYJY4wy5CS-1-ZgEzzRGofcqzXbHco,15880
|
|
22
|
-
logdetective-0.6.0.dist-info/WHEEL,sha256=fGIA9gx4Qxk2KDKeNJCbOEwSrmLtjWCwzBz351GyrPQ,88
|
|
23
|
-
logdetective-0.6.0.dist-info/entry_points.txt,sha256=3K_vXja6PmcA8sNdUi63WdImeiNhVZcEGPTaoJmltfA,63
|
|
24
|
-
logdetective-0.6.0.dist-info/RECORD,,
|
|
File without changes
|
|
File without changes
|