vectorwave 0.1.3__tar.gz → 0.1.5__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.
- {vectorwave-0.1.3/src/vectorwave.egg-info → vectorwave-0.1.5}/PKG-INFO +141 -48
- {vectorwave-0.1.3 → vectorwave-0.1.5}/Readme.md +138 -47
- {vectorwave-0.1.3 → vectorwave-0.1.5}/pyproject.toml +4 -2
- {vectorwave-0.1.3 → vectorwave-0.1.5}/src/tests/database/test_db.py +2 -2
- {vectorwave-0.1.3 → vectorwave-0.1.5}/src/tests/models/test_db_config.py +13 -14
- vectorwave-0.1.5/src/tests/monitoring/alert/test_alerter.py +70 -0
- vectorwave-0.1.5/src/tests/monitoring/test_async_trace.py +282 -0
- {vectorwave-0.1.3 → vectorwave-0.1.5}/src/tests/monitoring/test_tracer.py +78 -3
- vectorwave-0.1.5/src/tests/search/test_execution_search.py +120 -0
- {vectorwave-0.1.3 → vectorwave-0.1.5}/src/vectorwave/core/decorator.py +66 -39
- {vectorwave-0.1.3 → vectorwave-0.1.5}/src/vectorwave/database/db.py +7 -3
- {vectorwave-0.1.3 → vectorwave-0.1.5}/src/vectorwave/models/db_config.py +24 -1
- vectorwave-0.1.5/src/vectorwave/monitoring/alert/base.py +8 -0
- vectorwave-0.1.5/src/vectorwave/monitoring/alert/factory.py +19 -0
- vectorwave-0.1.5/src/vectorwave/monitoring/alert/null_alerter.py +7 -0
- vectorwave-0.1.5/src/vectorwave/monitoring/alert/webhook_alerter.py +69 -0
- vectorwave-0.1.5/src/vectorwave/monitoring/tracer.py +273 -0
- vectorwave-0.1.5/src/vectorwave/prediction/__init__.py +0 -0
- vectorwave-0.1.5/src/vectorwave/prediction/predictor.py +0 -0
- vectorwave-0.1.5/src/vectorwave/search/__init__.py +0 -0
- vectorwave-0.1.5/src/vectorwave/search/execution_search.py +148 -0
- vectorwave-0.1.5/src/vectorwave/search/extended_search.py +0 -0
- vectorwave-0.1.5/src/vectorwave/search/rag_search.py +0 -0
- vectorwave-0.1.5/src/vectorwave/vectorizer/__init__.py +0 -0
- {vectorwave-0.1.3 → vectorwave-0.1.5/src/vectorwave.egg-info}/PKG-INFO +141 -48
- {vectorwave-0.1.3 → vectorwave-0.1.5}/src/vectorwave.egg-info/SOURCES.txt +14 -0
- {vectorwave-0.1.3 → vectorwave-0.1.5}/src/vectorwave.egg-info/requires.txt +2 -0
- vectorwave-0.1.3/src/vectorwave/monitoring/tracer.py +0 -131
- {vectorwave-0.1.3 → vectorwave-0.1.5}/LICENSE +0 -0
- {vectorwave-0.1.3 → vectorwave-0.1.5}/MANIFEST.in +0 -0
- {vectorwave-0.1.3 → vectorwave-0.1.5}/NOTICE +0 -0
- {vectorwave-0.1.3 → vectorwave-0.1.5}/setup.cfg +0 -0
- {vectorwave-0.1.3 → vectorwave-0.1.5}/src/tests/__init__.py +0 -0
- {vectorwave-0.1.3 → vectorwave-0.1.5}/src/tests/batch/__init__.py +0 -0
- {vectorwave-0.1.3 → vectorwave-0.1.5}/src/tests/batch/test_batch.py +0 -0
- {vectorwave-0.1.3 → vectorwave-0.1.5}/src/tests/core/__init__.py +0 -0
- {vectorwave-0.1.3 → vectorwave-0.1.5}/src/tests/core/test_decorator.py +0 -0
- {vectorwave-0.1.3 → vectorwave-0.1.5}/src/tests/database/__init__.py +0 -0
- {vectorwave-0.1.3 → vectorwave-0.1.5}/src/tests/database/test_db_search.py +0 -0
- {vectorwave-0.1.3 → vectorwave-0.1.5}/src/tests/exception/__init__.py +0 -0
- {vectorwave-0.1.3 → vectorwave-0.1.5}/src/tests/models/__init__.py +0 -0
- {vectorwave-0.1.3 → vectorwave-0.1.5}/src/tests/monitoring/__init__.py +0 -0
- {vectorwave-0.1.3/src/tests/prediction → vectorwave-0.1.5/src/tests/monitoring/alert}/__init__.py +0 -0
- {vectorwave-0.1.3/src/tests/vectorizer → vectorwave-0.1.5/src/tests/prediction}/__init__.py +0 -0
- {vectorwave-0.1.3/src/vectorwave/batch → vectorwave-0.1.5/src/tests/search}/__init__.py +0 -0
- {vectorwave-0.1.3/src/vectorwave/core → vectorwave-0.1.5/src/tests/vectorizer}/__init__.py +0 -0
- {vectorwave-0.1.3 → vectorwave-0.1.5}/src/vectorwave/__init__.py +0 -0
- {vectorwave-0.1.3/src/vectorwave/database → vectorwave-0.1.5/src/vectorwave/batch}/__init__.py +0 -0
- {vectorwave-0.1.3 → vectorwave-0.1.5}/src/vectorwave/batch/batch.py +0 -0
- {vectorwave-0.1.3/src/vectorwave/exception → vectorwave-0.1.5/src/vectorwave/core}/__init__.py +0 -0
- {vectorwave-0.1.3 → vectorwave-0.1.5}/src/vectorwave/core/core.py +0 -0
- {vectorwave-0.1.3/src/vectorwave/models → vectorwave-0.1.5/src/vectorwave/database}/__init__.py +0 -0
- {vectorwave-0.1.3 → vectorwave-0.1.5}/src/vectorwave/database/db_search.py +0 -0
- {vectorwave-0.1.3/src/vectorwave/monitoring → vectorwave-0.1.5/src/vectorwave/exception}/__init__.py +0 -0
- {vectorwave-0.1.3 → vectorwave-0.1.5}/src/vectorwave/exception/exceptions.py +0 -0
- {vectorwave-0.1.3/src/vectorwave/prediction → vectorwave-0.1.5/src/vectorwave/models}/__init__.py +0 -0
- {vectorwave-0.1.3/src/vectorwave/vectorizer → vectorwave-0.1.5/src/vectorwave/monitoring}/__init__.py +0 -0
- /vectorwave-0.1.3/src/vectorwave/monitoring/monitoring.py → /vectorwave-0.1.5/src/vectorwave/monitoring/alert/__init__.py +0 -0
- /vectorwave-0.1.3/src/vectorwave/prediction/predictor.py → /vectorwave-0.1.5/src/vectorwave/monitoring/monitoring.py +0 -0
- {vectorwave-0.1.3 → vectorwave-0.1.5}/src/vectorwave/vectorizer/base.py +0 -0
- {vectorwave-0.1.3 → vectorwave-0.1.5}/src/vectorwave/vectorizer/factory.py +0 -0
- {vectorwave-0.1.3 → vectorwave-0.1.5}/src/vectorwave/vectorizer/huggingface_vectorizer.py +0 -0
- {vectorwave-0.1.3 → vectorwave-0.1.5}/src/vectorwave/vectorizer/openai_vectorizer.py +0 -0
- {vectorwave-0.1.3 → vectorwave-0.1.5}/src/vectorwave.egg-info/dependency_links.txt +0 -0
- {vectorwave-0.1.3 → vectorwave-0.1.5}/src/vectorwave.egg-info/top_level.txt +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: vectorwave
|
|
3
|
-
Version: 0.1.
|
|
3
|
+
Version: 0.1.5
|
|
4
4
|
Summary: VectorWave: Seamless Auto-Vectorization Framework
|
|
5
5
|
Author-email: junyeonggim <junyeonggim5@gmail.com>
|
|
6
6
|
License-Expression: MIT
|
|
@@ -19,34 +19,37 @@ License-File: LICENSE
|
|
|
19
19
|
License-File: NOTICE
|
|
20
20
|
Requires-Dist: weaviate-client>=4.0.0
|
|
21
21
|
Requires-Dist: pydantic-settings>=2.0.0
|
|
22
|
+
Requires-Dist: sentence-transformers
|
|
23
|
+
Requires-Dist: requests
|
|
22
24
|
Dynamic: license-file
|
|
23
25
|
|
|
24
26
|
|
|
27
|
+
|
|
25
28
|
# VectorWave: Seamless Auto-Vectorization Framework
|
|
26
29
|
|
|
27
|
-
[](https://
|
|
30
|
+
[](https://opensource.org/licenses/MIT)
|
|
28
31
|
|
|
29
32
|
## 🌟 Overview
|
|
30
33
|
|
|
31
|
-
**VectorWave** is an innovative framework that uses
|
|
34
|
+
**VectorWave** is an innovative framework that uses **decorators** to automatically save and manage the output of Python functions/methods in a **Vector Database (Vector DB)**. Developers can convert function outputs into intelligent vector data with just a single line of code (`@vectorize`), without worrying about the complex processes of data collection, embedding generation, and Vector DB storage.
|
|
32
35
|
|
|
33
|
-
|
|
36
|
+
-----
|
|
34
37
|
|
|
35
38
|
## ✨ Features
|
|
36
39
|
|
|
37
40
|
* **`@vectorize` Decorator:**
|
|
38
|
-
1. **Static Data Collection:**
|
|
39
|
-
2. **Dynamic Data Logging:**
|
|
40
|
-
* **Distributed Tracing:**
|
|
41
|
-
* **Search Interface:** Provides `search_functions`
|
|
41
|
+
1. **Static Data Collection:** Upon script load, the function's source code, docstring, and metadata are saved once to the `VectorWaveFunctions` collection.
|
|
42
|
+
2. **Dynamic Data Logging:** Each time the function is called, its execution time, success/failure status, error logs, and "dynamic tags" are recorded in the `VectorWaveExecutions` collection.
|
|
43
|
+
* **Distributed Tracing:** Combines `@vectorize` and `@trace_span` decorators to bundle the execution of complex, multi-step workflows under a single **`trace_id`** for analysis.
|
|
44
|
+
* **Search Interface:** Provides `search_functions` and `search_executions` to query the stored vector data (function definitions) and logs (execution history), facilitating the construction of RAG and monitoring systems.
|
|
42
45
|
|
|
43
|
-
|
|
46
|
+
-----
|
|
44
47
|
|
|
45
48
|
## 🚀 Usage
|
|
46
49
|
|
|
47
|
-
VectorWave consists of
|
|
50
|
+
VectorWave consists of "storage" via decorators and "retrieval" via functions, and now includes **execution flow tracing**.
|
|
48
51
|
|
|
49
|
-
### 1
|
|
52
|
+
### 1\. (Required) Database Initialization and Setup
|
|
50
53
|
|
|
51
54
|
```python
|
|
52
55
|
import time
|
|
@@ -56,50 +59,50 @@ from vectorwave import (
|
|
|
56
59
|
search_functions,
|
|
57
60
|
search_executions
|
|
58
61
|
)
|
|
59
|
-
# [
|
|
62
|
+
# [New] Import trace_span separately for distributed tracing.
|
|
60
63
|
from vectorwave.monitoring.tracer import trace_span
|
|
61
64
|
|
|
62
|
-
#
|
|
65
|
+
# Needs to be called only once at script startup.
|
|
63
66
|
try:
|
|
64
67
|
client = initialize_database()
|
|
65
|
-
print("VectorWave DB
|
|
68
|
+
print("VectorWave DB initialization successful.")
|
|
66
69
|
except Exception as e:
|
|
67
70
|
print(f"DB initialization failed: {e}")
|
|
68
71
|
exit()
|
|
69
|
-
|
|
72
|
+
```
|
|
70
73
|
|
|
71
|
-
### 2\. [
|
|
74
|
+
### 2\. [Storage] Using `@vectorize` and Distributed Tracing
|
|
72
75
|
|
|
73
|
-
|
|
76
|
+
`@vectorize` acts as the **Root** of the trace, and applying `@trace_span` to internal functions bundles the workflow execution under a **single `trace_id`**.
|
|
74
77
|
|
|
75
78
|
```python
|
|
76
79
|
# --- Child Span Function: Captures arguments ---
|
|
77
80
|
@trace_span(attributes_to_capture=['user_id', 'amount'])
|
|
78
81
|
def step_1_validate_payment(user_id: str, amount: int):
|
|
79
|
-
"""(Span)
|
|
82
|
+
"""(Span) Validates payment. Logs user_id and amount."""
|
|
80
83
|
print(f" [SPAN 1] Validating payment for {user_id}...")
|
|
81
84
|
time.sleep(0.1)
|
|
82
85
|
return True
|
|
83
86
|
|
|
84
87
|
@trace_span(attributes_to_capture=['user_id', 'receipt_id'])
|
|
85
88
|
def step_2_send_receipt(user_id: str, receipt_id: str):
|
|
86
|
-
"""(Span) Sends
|
|
89
|
+
"""(Span) Sends receipt."""
|
|
87
90
|
print(f" [SPAN 2] Sending receipt {receipt_id}...")
|
|
88
91
|
time.sleep(0.2)
|
|
89
92
|
|
|
90
93
|
|
|
91
|
-
# --- Root Function (@trace_root
|
|
94
|
+
# --- Root Function (acts as @trace_root) ---
|
|
92
95
|
@vectorize(
|
|
93
|
-
search_description="
|
|
94
|
-
sequence_narrative="
|
|
95
|
-
team="billing", #
|
|
96
|
-
priority=1 #
|
|
96
|
+
search_description="Processes a user payment and returns a receipt.",
|
|
97
|
+
sequence_narrative="After payment is complete, a receipt is sent via email.",
|
|
98
|
+
team="billing", # ⬅️ Custom tag (logged on all executions)
|
|
99
|
+
priority=1 # ⬅️ Custom tag (execution importance)
|
|
97
100
|
)
|
|
98
101
|
def process_payment(user_id: str, amount: int):
|
|
99
102
|
"""(Root Span) Executes the user payment workflow."""
|
|
100
103
|
print(f" [ROOT EXEC] process_payment: Starting workflow for {user_id}...")
|
|
101
104
|
|
|
102
|
-
# When
|
|
105
|
+
# When child functions are called, the same trace_id is automatically inherited via ContextVar.
|
|
103
106
|
step_1_validate_payment(user_id=user_id, amount=amount)
|
|
104
107
|
|
|
105
108
|
receipt_id = f"receipt_{user_id}_{amount}"
|
|
@@ -108,20 +111,20 @@ def process_payment(user_id: str, amount: int):
|
|
|
108
111
|
print(f" [ROOT DONE] process_payment")
|
|
109
112
|
return {"status": "success", "receipt_id": receipt_id}
|
|
110
113
|
|
|
111
|
-
# ---
|
|
114
|
+
# --- Function Execution ---
|
|
112
115
|
print("Now calling 'process_payment'...")
|
|
113
|
-
# This single call
|
|
114
|
-
# all
|
|
116
|
+
# This single call will record a total of 3 execution logs (spans) in the DB,
|
|
117
|
+
# and all three logs will be tied to a single 'trace_id'.
|
|
115
118
|
process_payment("user_789", 5000)
|
|
116
119
|
```
|
|
117
120
|
|
|
118
|
-
### 3\. [
|
|
121
|
+
### 3\. [Retrieval ①] Search Function Definitions (for RAG)
|
|
119
122
|
|
|
120
123
|
```python
|
|
121
|
-
# Search for functions related to 'payment' using natural language (vector
|
|
122
|
-
print("\n--- Searching for 'payment' functions ---")
|
|
124
|
+
# Search for functions related to 'payment' using natural language (vector).
|
|
125
|
+
print("\n--- Searching for 'payment' related functions ---")
|
|
123
126
|
payment_funcs = search_functions(
|
|
124
|
-
query="
|
|
127
|
+
query="User payment processing feature",
|
|
125
128
|
limit=3
|
|
126
129
|
)
|
|
127
130
|
for func in payment_funcs:
|
|
@@ -130,9 +133,9 @@ for func in payment_funcs:
|
|
|
130
133
|
print(f" - Similarity (Distance): {func['metadata'].distance:.4f}")
|
|
131
134
|
```
|
|
132
135
|
|
|
133
|
-
### 4\. [
|
|
136
|
+
### 4\. [Retrieval ②] Search Execution Logs (for Monitoring & Tracing)
|
|
134
137
|
|
|
135
|
-
|
|
138
|
+
`search_executions` can now retrieve all related execution logs (spans) based on a `trace_id`.
|
|
136
139
|
|
|
137
140
|
```python
|
|
138
141
|
# 1. Find the Trace ID of a specific workflow (process_payment).
|
|
@@ -144,24 +147,25 @@ latest_payment_span = search_executions(
|
|
|
144
147
|
)
|
|
145
148
|
trace_id = latest_payment_span[0]["trace_id"]
|
|
146
149
|
|
|
147
|
-
# 2.
|
|
150
|
+
# 2. Retrieve all spans belonging to that Trace ID in chronological order.
|
|
148
151
|
print(f"\n--- Full Trace for ID ({trace_id[:8]}...) ---")
|
|
149
152
|
trace_spans = search_executions(
|
|
150
153
|
limit=10,
|
|
151
154
|
filters={"trace_id": trace_id},
|
|
152
155
|
sort_by="timestamp_utc",
|
|
153
|
-
sort_ascending=True #
|
|
156
|
+
sort_ascending=True # Sort ascending to analyze workflow
|
|
154
157
|
)
|
|
155
158
|
|
|
156
159
|
for i, span in enumerate(trace_spans):
|
|
157
160
|
print(f" - [Span {i+1}] {span['function_name']} ({span['duration_ms']:.2f}ms)")
|
|
158
|
-
# Captured arguments (user_id, amount, etc.)
|
|
161
|
+
# Captured arguments (user_id, amount, etc.) from child spans will also be visible.
|
|
159
162
|
|
|
160
|
-
#
|
|
163
|
+
# Expected Output:
|
|
161
164
|
# - [Span 1] step_1_validate_payment (100.81ms)
|
|
162
165
|
# - [Span 2] step_2_send_receipt (202.06ms)
|
|
163
166
|
# - [Span 3] process_payment (333.18ms)
|
|
164
167
|
```
|
|
168
|
+
|
|
165
169
|
-----
|
|
166
170
|
|
|
167
171
|
## ⚙️ Configuration
|
|
@@ -176,10 +180,10 @@ You can select the text vectorization method via the `VECTORIZER` environment va
|
|
|
176
180
|
|
|
177
181
|
| `VECTORIZER` Setting | Description | Required Additional Settings |
|
|
178
182
|
| :--- | :--- | :--- |
|
|
179
|
-
| **`huggingface`** | (Default Recommended) Uses the `sentence-transformers` library to vectorize on your local CPU. No API key is needed
|
|
180
|
-
| **`openai_client`** | (High-Performance) Uses the OpenAI Python client to vectorize with
|
|
181
|
-
| **`weaviate_module`** | (Docker Delegate) Delegates
|
|
182
|
-
| **`none`** | Disables vectorization. Data
|
|
183
|
+
| **`huggingface`** | (Default Recommended) Uses the `sentence-transformers` library to vectorize on your local CPU. No API key is needed. | `HF_MODEL_NAME` (e.g., "sentence-transformers/all-MiniLM-L6-v2") |
|
|
184
|
+
| **`openai_client`** | (High-Performance) Uses the OpenAI Python client to vectorize with models like `text-embedding-3-small`. | `OPENAI_API_KEY` (A valid OpenAI API key) |
|
|
185
|
+
| **`weaviate_module`** | (Docker Delegate) Delegates vectorization to Weaviate's built-in module (e.g., `text2vec-openai`). | `WEAVIATE_VECTORIZER_MODULE`, `OPENAI_API_KEY` |
|
|
186
|
+
| **`none`** | Disables vectorization. Data is stored without vectors. | None |
|
|
183
187
|
|
|
184
188
|
-----
|
|
185
189
|
|
|
@@ -207,6 +211,7 @@ OPENAI_API_KEY=sk-...
|
|
|
207
211
|
|
|
208
212
|
# --- [Advanced] Custom Properties ---
|
|
209
213
|
CUSTOM_PROPERTIES_FILE_PATH=.weaviate_properties
|
|
214
|
+
FAILURE_MAPPING_FILE_PATH=.vectorwave_errors.json
|
|
210
215
|
RUN_ID=test-run-001
|
|
211
216
|
```
|
|
212
217
|
|
|
@@ -232,6 +237,7 @@ HF_MODEL_NAME=...
|
|
|
232
237
|
|
|
233
238
|
# --- [Advanced] Custom Properties ---
|
|
234
239
|
CUSTOM_PROPERTIES_FILE_PATH=.weaviate_properties
|
|
240
|
+
FAILURE_MAPPING_FILE_PATH=.vectorwave_errors.json
|
|
235
241
|
RUN_ID=test-run-001
|
|
236
242
|
```
|
|
237
243
|
|
|
@@ -256,11 +262,72 @@ OPENAI_API_KEY=sk-xxxxxxxxxxxxxxxxxxxxxxxxxxxx
|
|
|
256
262
|
|
|
257
263
|
# --- [Advanced] Custom Properties ---
|
|
258
264
|
CUSTOM_PROPERTIES_FILE_PATH=.weaviate_properties
|
|
265
|
+
FAILURE_MAPPING_FILE_PATH=.vectorwave_errors.json
|
|
259
266
|
RUN_ID=test-run-001
|
|
260
267
|
```
|
|
261
268
|
|
|
262
269
|
-----
|
|
263
270
|
|
|
271
|
+
### 🚀 Advanced Failure Tracing (Error Code)
|
|
272
|
+
|
|
273
|
+
This enhances `VectorWaveExecutions` logs beyond a simple `status: "ERROR"`. An `error_code` property is added to the schema for granular failure analysis.
|
|
274
|
+
|
|
275
|
+
When a function wrapped by `@vectorize` or `@trace_span` fails, the `error_code` is automatically determined based on three priorities:
|
|
276
|
+
|
|
277
|
+
1. **Custom Exception Attribute (Priority 1):**
|
|
278
|
+
The most specific method. If the raised exception object `e` has an `e.error_code` attribute, its value is used.
|
|
279
|
+
|
|
280
|
+
```python
|
|
281
|
+
class PaymentError(Exception):
|
|
282
|
+
def __init__(self, message, error_code):
|
|
283
|
+
super().__init__(message)
|
|
284
|
+
self.error_code = error_code # ⬅️ This attribute is detected.
|
|
285
|
+
|
|
286
|
+
@vectorize(...)
|
|
287
|
+
def process_payment(amount):
|
|
288
|
+
if amount < 0:
|
|
289
|
+
raise PaymentError("Amount < 0", error_code="PAYMENT_NEGATIVE_AMOUNT")
|
|
290
|
+
|
|
291
|
+
# DB Log on execution: { "status": "ERROR", "error_code": "PAYMENT_NEGATIVE_AMOUNT" }
|
|
292
|
+
```
|
|
293
|
+
|
|
294
|
+
2. **Global Mapping File (Priority 2):**
|
|
295
|
+
Centrally manage common exceptions. VectorWave loads a JSON file specified by `FAILURE_MAPPING_FILE_PATH` in your `.env` (default: `.vectorwave_errors.json`) and maps the exception class name to a code.
|
|
296
|
+
|
|
297
|
+
**`.vectorwave_errors.json` Example:**
|
|
298
|
+
|
|
299
|
+
```json
|
|
300
|
+
{
|
|
301
|
+
"ValueError": "INVALID_INPUT",
|
|
302
|
+
"KeyError": "CONFIG_MISSING",
|
|
303
|
+
"TypeError": "INVALID_INPUT"
|
|
304
|
+
}
|
|
305
|
+
```
|
|
306
|
+
|
|
307
|
+
```python
|
|
308
|
+
@vectorize(...)
|
|
309
|
+
def get_config(key):
|
|
310
|
+
return os.environ[key] # ⬅️ Raises KeyError
|
|
311
|
+
|
|
312
|
+
# DB Log on execution: { "status": "ERROR", "error_code": "CONFIG_MISSING" }
|
|
313
|
+
```
|
|
314
|
+
|
|
315
|
+
3. **Default (Priority 3):**
|
|
316
|
+
If neither of the above applies, the exception's class name (e.g., `"ZeroDivisionError"`) is stored as the default `error_code`.
|
|
317
|
+
|
|
318
|
+
**[Usage] Searching for Failures:**
|
|
319
|
+
You can now filter for specific failure types using `search_executions`.
|
|
320
|
+
|
|
321
|
+
```python
|
|
322
|
+
# Find all failure logs categorized as "INVALID_INPUT"
|
|
323
|
+
invalid_logs = search_executions(
|
|
324
|
+
filters={"error_code": "INVALID_INPUT"},
|
|
325
|
+
limit=10
|
|
326
|
+
)
|
|
327
|
+
```
|
|
328
|
+
|
|
329
|
+
-----
|
|
330
|
+
|
|
264
331
|
### Custom Properties and Dynamic Execution Tagging
|
|
265
332
|
|
|
266
333
|
VectorWave can store user-defined metadata in addition to static data (function definitions) and dynamic data (execution logs). This works in two steps.
|
|
@@ -304,7 +371,7 @@ When a function is executed, VectorWave adds tags to the `VectorWaveExecutions`
|
|
|
304
371
|
VectorWave looks for environment variables matching the **UPPERCASE name** of the keys defined in Step 1 (e.g., `RUN_ID`, `EXPERIMENT_ID`). Found values are loaded as `global_custom_values` and added to *all* execution logs. Ideal for run-wide metadata.
|
|
305
372
|
|
|
306
373
|
**2. Function-Specific Tags (Decorator)**
|
|
307
|
-
You can pass tags as keyword arguments (`**execution_tags`) directly to the `@vectorize` decorator.
|
|
374
|
+
You can pass tags as keyword arguments (`**execution_tags`) directly to the `@vectorize` decorator. This is ideal for function-specific metadata.
|
|
308
375
|
|
|
309
376
|
```python
|
|
310
377
|
# --- .env file ---
|
|
@@ -329,9 +396,8 @@ def other_function():
|
|
|
329
396
|
pass
|
|
330
397
|
```
|
|
331
398
|
|
|
332
|
-
**Tag Merging and Validation Rules**
|
|
333
399
|
|
|
334
|
-
1. **Validation (Important):** Tags (global or function-specific) will **only** be saved to Weaviate if their key (e.g., `run_id`, `team`, `priority`) was first defined in the `.weaviate_properties` file (Step 1). Tags not defined in the schema are **ignored**, and a warning is
|
|
400
|
+
1. **Validation (Important):** Tags (global or function-specific) will **only** be saved to Weaviate if their key (e.g., `run_id`, `team`, `priority`) was first defined in the `.weaviate_properties` file (Step 1). Tags not defined in the schema are **ignored**, and a warning is logged at startup.
|
|
335
401
|
|
|
336
402
|
2. **Priority (Override):** If a tag key is defined in both places (e.g., global `RUN_ID` in `.env` and `run_id="override-xyz"` in the decorator), the **function-specific tag from the decorator always wins**.
|
|
337
403
|
|
|
@@ -342,11 +408,38 @@ def other_function():
|
|
|
342
408
|
|
|
343
409
|
-----
|
|
344
410
|
|
|
411
|
+
### 🚀 Real-time Error Alerting (Webhook)
|
|
412
|
+
|
|
413
|
+
Beyond just logging, `VectorWave` can send **real-time notifications via webhook** the instant an error occurs. This functionality is built directly into the tracer and can be activated simply by updating your `.env` file.
|
|
414
|
+
|
|
415
|
+
**How it Works:**
|
|
416
|
+
1. An exception is raised within a function decorated by `@trace_span` or `@vectorize`.
|
|
417
|
+
2. The tracer catches the exception in its `except` block and immediately calls the `alerter` object.
|
|
418
|
+
3. The alerter reads the `.env` configuration and uses the `WebhookAlerter` to dispatch the error details to your specified URL.
|
|
419
|
+
4. The notification is optimized for **Discord Embeds**, sending a rich report including the error code, trace ID, captured attributes (`user_id`, etc.), and the full stack trace.
|
|
420
|
+
|
|
421
|
+
**How to Enable:**
|
|
422
|
+
Add the following two variables to your `test_ex/.env` file (or environment variables):
|
|
423
|
+
|
|
424
|
+
```ini
|
|
425
|
+
# .env file
|
|
426
|
+
|
|
427
|
+
# 1. Set the alerter strategy to 'webhook'. (Default: "none")
|
|
428
|
+
ALERTER_STRATEGY="webhook"
|
|
429
|
+
|
|
430
|
+
# 2. Provide your webhook URL from Discord, Slack, etc.
|
|
431
|
+
ALERTER_WEBHOOK_URL="[https://discord.com/api/webhooks/YOUR_HOOK_ID/](https://discord.com/api/webhooks/YOUR_HOOK_ID/)..."
|
|
432
|
+
With just these two lines, running test_ex/example.py will now instantly send a Discord alert when the CustomValueError is raised.
|
|
433
|
+
|
|
434
|
+
Extensibility (Strategy Pattern): The alerting system is built on a Strategy Pattern. You can easily extend it by implementing the BaseAlerter interface to support other channels like email, PagerDuty, or more.
|
|
435
|
+
|
|
436
|
+
**Tag Merging and Validation Rules**
|
|
437
|
+
```
|
|
438
|
+
|
|
345
439
|
## 🤝 Contributing
|
|
346
440
|
|
|
347
|
-
|
|
441
|
+
Bug reports, feature requests, and code contributions are all welcome. For details, please see [CONTRIBUTING.md](https://www.google.com/search?q=httpsS://www.google.com/search%3Fq%3DCONTRIBUTING.md).
|
|
348
442
|
|
|
349
443
|
## 📜 License
|
|
350
444
|
|
|
351
|
-
This project is distributed under the MIT License. See the [LICENSE](https://www.google.com/search?q=
|
|
352
|
-
|
|
445
|
+
This project is distributed under the MIT License. See the [LICENSE](https://www.google.com/search?q=LICENSE) file for details.
|