vnai 2.0.2__py3-none-any.whl → 2.0.3__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.
vnai/scope/promo.py CHANGED
@@ -1,55 +1,125 @@
1
- _G='init'
2
- _F='simple'
3
- _E='markdown'
4
- _D=True
5
- _C=None
6
- _B='terminal'
7
- _A='html'
1
+ import logging
8
2
  import requests
9
3
  from datetime import datetime
10
- import random,threading,time,urllib.parse
4
+ import random
5
+ import threading
6
+ import time
7
+ import urllib.parse
8
+
9
+ logger = logging.getLogger(__name__)
10
+ if not logger.hasHandlers():
11
+ handler = logging.StreamHandler()
12
+ handler.setFormatter(logging.Formatter('%(message)s'))
13
+ logger.addHandler(handler)
14
+ logger.setLevel(logging.INFO)
15
+
11
16
  class ContentManager:
12
- _instance=_C;_lock=threading.Lock()
13
- def __new__(A):
14
- with A._lock:
15
- if A._instance is _C:A._instance=super(ContentManager,A).__new__(A);A._instance._initialize()
16
- return A._instance
17
- def _initialize(A):A.last_display=0;A.display_interval=86400;A.content_base_url='https://vnstock-beam.hf.space/content-delivery';A.target_url='https://vnstocks.com/lp-khoa-hoc-python-chung-khoan';A.image_url='https://vnstocks.com/img/trang-chu-vnstock-python-api-phan-tich-giao-dich-chung-khoan.jpg';A._start_periodic_display()
18
- def _start_periodic_display(A):
19
- def B():
20
- while _D:
21
- B=random.randint(7200,21600);time.sleep(B);C=time.time()
22
- if C-A.last_display>=A.display_interval:A.present_content(context='periodic')
23
- C=threading.Thread(target=B,daemon=_D);C.start()
24
- def fetch_remote_content(B,context=_G,html=_D):
25
- try:
26
- C={'context':context,_A:'true'if html else'false'};D=f"{B.content_base_url}?{urllib.parse.urlencode(C)}";A=requests.get(D,timeout=3)
27
- if A.status_code==200:return A.text
28
- return
29
- except:return
30
- def present_content(C,environment=_C,context=_G):
31
- I='jupyter';H='unknown';E=context;A=environment;C.last_display=time.time()
32
- if A is _C:
33
- try:from vnai.scope.profile import inspector as J;A=J.examine().get('environment',H)
34
- except:A=H
35
- if A==I:B=C.fetch_remote_content(context=E,html=_D)
36
- else:B=C.fetch_remote_content(context=E,html=False)
37
- D=C._generate_fallback_content(E)
38
- if A==I:
39
- try:
40
- from IPython.display import display as F,HTML as G,Markdown as K
41
- if B:F(G(B))
42
- else:
43
- try:F(K(D[_E]))
44
- except:F(G(D[_A]))
45
- except:pass
46
- elif A==_B:
47
- if B:print(B)
48
- else:print(D[_B])
49
- else:print(D[_F])
50
- def _generate_fallback_content(B,context):
51
- A={_A:'',_E:'',_B:'',_F:''}
52
- if context=='loop':A[_A]=f'''
17
+ _instance = None
18
+ _lock = threading.Lock()
19
+
20
+ def __new__(cls):
21
+ with cls._lock:
22
+ if cls._instance is None:
23
+ cls._instance = super(ContentManager, cls).__new__(cls)
24
+ cls._instance._initialize()
25
+ return cls._instance
26
+
27
+ def _initialize(self):
28
+ self.last_display = 0
29
+ self.display_interval = 24 * 3600
30
+
31
+ self.content_base_url = (
32
+ "https://vnstock-beam.hf.space/content-delivery"
33
+ )
34
+ self.target_url = (
35
+ "https://vnstocks.com/lp-khoa-hoc-python-chung-khoan"
36
+ )
37
+ self.image_url = (
38
+ "https://vnstocks.com/img/trang-chu-vnstock-python-api-phan-tich-giao-dich-chung-khoan.jpg"
39
+ )
40
+
41
+ self._start_periodic_display()
42
+
43
+ def _start_periodic_display(self):
44
+ def periodic_display():
45
+ while True:
46
+ sleep_time = random.randint(2 * 3600, 6 * 3600)
47
+ time.sleep(sleep_time)
48
+
49
+ current_time = time.time()
50
+ if current_time - self.last_display >= self.display_interval:
51
+ self.present_content(context="periodic")
52
+
53
+ thread = threading.Thread(target=periodic_display, daemon=True)
54
+ thread.start()
55
+
56
+ def fetch_remote_content(self, context="init", html=True):
57
+ try:
58
+ params = {"context": context, "html": "true" if html else "false"}
59
+ url = f"{self.content_base_url}?{urllib.parse.urlencode(params)}"
60
+
61
+ response = requests.get(url, timeout=3)
62
+ if response.status_code == 200:
63
+ return response.text
64
+ logger.debug(f"Non-200 response fetching content: {response.status_code}")
65
+ return None
66
+ except Exception as e:
67
+ logger.debug(f"Failed to fetch remote content: {e}")
68
+ return None
69
+
70
+ def present_content(self, environment=None, context="init"):
71
+ self.last_display = time.time()
72
+
73
+ if environment is None:
74
+ try:
75
+ from vnai.scope.profile import inspector
76
+
77
+ environment = (
78
+ inspector.examine().get("environment", "unknown")
79
+ )
80
+ except Exception:
81
+ environment = "unknown"
82
+
83
+ if environment == "jupyter":
84
+ remote_content = self.fetch_remote_content(
85
+ context=context, html=True
86
+ )
87
+ else:
88
+ remote_content = self.fetch_remote_content(
89
+ context=context, html=False
90
+ )
91
+
92
+ fallback_content = self._generate_fallback_content(context)
93
+
94
+ if environment == "jupyter":
95
+ try:
96
+ from IPython.display import display, HTML, Markdown
97
+
98
+ if remote_content:
99
+ display(HTML(remote_content))
100
+ else:
101
+ try:
102
+ display(Markdown(fallback_content["markdown"]))
103
+ except Exception:
104
+ display(HTML(fallback_content["html"]))
105
+ except Exception as e:
106
+ logger.debug(f"Jupyter display failed: {e}")
107
+
108
+ elif environment == "terminal":
109
+ if remote_content:
110
+ logger.info(remote_content)
111
+ else:
112
+ logger.info(fallback_content["terminal"])
113
+
114
+ else:
115
+ logger.info(fallback_content["simple"])
116
+
117
+ def _generate_fallback_content(self, context):
118
+ fallback = {"html": "", "markdown": "", "terminal": "", "simple": ""}
119
+
120
+ if context == "loop":
121
+ fallback["html"] = (
122
+ f"""
53
123
  <div style="border: 1px solid #e74c3c; padding: 15px; border-radius: 5px; margin: 10px 0;">
54
124
  <h3 style="color: #e74c3c;">⚠️ Bạn đang sử dụng vòng lặp với quá nhiều requests</h3>
55
125
  <p>Để tránh bị giới hạn tốc độ và tối ưu hiệu suất:</p>
@@ -59,8 +129,40 @@ class ContentManager:
59
129
  <li>Tham gia gói tài trợ <a href="https://vnstocks.com/insiders-program" style="color: #3498db;">Vnstock Insider</a> để tăng 5X giới hạn API</li>
60
130
  </ul>
61
131
  </div>
62
- ''';A[_E]='\n## ⚠️ Bạn đang sử dụng vòng lặp với quá nhiều requests\n\nĐể tránh bị giới hạn tốc độ và tối ưu hiệu suất:\n* Thêm thời gian chờ giữa các lần gọi API\n* Sử dụng xử lý theo batch thay vì lặp liên tục\n* Tham gia gói tài trợ [Vnstock Insider](https://vnstocks.com/insiders-program) để tăng 5X giới hạn API\n ';A[_B]='\n╔═════════════════════════════════════════════════════════════════╗\n║ ║\n║ 🚫 ĐANG BỊ CHẶN BỞI GIỚI HẠN API? GIẢI PHÁP Ở ĐÂY! ║\n║ ║\n║ ✓ Tăng ngay 500% tốc độ gọi API - Không còn lỗi RateLimit ║\n║ ✓ Tiết kiệm 85% thời gian chờ đợi giữa các request ║\n║ ║\n║ ➤ NÂNG CẤP NGAY VỚI GÓI TÀI TRỢ VNSTOCK: ║\n║ https://vnstocks.com/insiders-program ║\n║ ║\n╚═════════════════════════════════════════════════════════════════╝\n ';A[_F]='🚫 Đang bị giới hạn API? Tăng tốc độ gọi API lên 500% với gói Vnstock Insider: https://vnstocks.com/insiders-program'
63
- else:A[_A]=f'''
132
+ """
133
+ )
134
+ fallback["markdown"] = (
135
+ """
136
+ ## ⚠️ Bạn đang sử dụng vòng lặp với quá nhiều requests
137
+
138
+ Để tránh bị giới hạn tốc độ và tối ưu hiệu suất:
139
+ * Thêm thời gian chờ giữa các lần gọi API
140
+ * Sử dụng xử lý theo batch thay vì lặp liên tục
141
+ * Tham gia gói tài trợ [Vnstock Insider](https://vnstocks.com/insiders-program) để tăng 5X giới hạn API
142
+ """
143
+ )
144
+ fallback["terminal"] = (
145
+ """
146
+ ╔═════════════════════════════════════════════════════════════════╗
147
+ ║ ║
148
+ ║ 🚫 ĐANG BỊ CHẶN BỞI GIỚI HẠN API? GIẢI PHÁP Ở ĐÂY! ║
149
+ ║ ║
150
+ ║ ✓ Tăng ngay 500% tốc độ gọi API - Không còn lỗi RateLimit ║
151
+ ║ ✓ Tiết kiệm 85% thời gian chờ đợi giữa các request ║
152
+ ║ ║
153
+ ║ ➤ NÂNG CẤP NGAY VỚI GÓI TÀI TRỢ VNSTOCK: ║
154
+ ║ https://vnstocks.com/insiders-program ║
155
+ ║ ║
156
+ ╚═════════════════════════════════════════════════════════════════╝
157
+ """
158
+ )
159
+ fallback["simple"] = (
160
+ "🚫 Đang bị giới hạn API? Tăng tốc độ gọi API lên 500% với gói "
161
+ "Vnstock Insider: https://vnstocks.com/insiders-program"
162
+ )
163
+ else:
164
+ fallback["html"] = (
165
+ f"""
64
166
  <div style="border: 1px solid #3498db; padding: 15px; border-radius: 5px; margin: 10px 0;">
65
167
  <h3 style="color: #3498db;">👋 Chào mừng bạn đến với Vnstock!</h3>
66
168
  <p>Cảm ơn bạn đã sử dụng thư viện phân tích chứng khoán #1 tại Việt Nam cho Python</p>
@@ -70,7 +172,47 @@ class ContentManager:
70
172
  </ul>
71
173
  <p>Khám phá các tính năng mới nhất và tham gia cộng đồng để nhận hỗ trợ.</p>
72
174
  </div>
73
- ''';A[_E]='\n## 👋 Chào mừng bạn đến với Vnstock!\n\nCảm ơn bạn đã sử dụng package phân tích chứng khoán #1 tại Việt Nam\n\n* Tài liệu: [vnstocks.com/docs](https://vnstocks.com/docs)\n* Cộng đồng: [vnstocks.com/community](https://vnstocks.com/community)\n\nKhám phá các tính năng mới nhất và tham gia cộng đồng để nhận hỗ trợ.\n ';A[_B]='\n╔══════════════════════════════════════════════════════════╗\n║ ║\n║ 👋 Chào mừng bạn đến với Vnstock! ║\n║ ║\n║ Cảm ơn bạn đã sử dụng package phân tích ║\n║ chứng khoán #1 tại Việt Nam ║\n║ ║\n║ ✓ Tài liệu: https://vnstocks.com/docs ║\n║ ✓ Cộng đồng: https://vnstocks.com/community ║\n║ ║\n║ Khám phá các tính năng mới nhất và tham gia ║\n║ cộng đồng để nhận hỗ trợ. ║\n║ ║\n╚══════════════════════════════════════════════════════════╝\n ';A[_F]='👋 Chào mừng bạn đến với Vnstock! Tài liệu: https://vnstocks.com/docs | Cộng đồng: https://vnstocks.com/community'
74
- return A
75
- manager=ContentManager()
76
- def present(context=_G):return manager.present_content(context=context)
175
+ """
176
+ )
177
+ fallback["markdown"] = (
178
+ """
179
+ ## 👋 Chào mừng bạn đến với Vnstock!
180
+
181
+ Cảm ơn bạn đã sử dụng package phân tích chứng khoán #1 tại Việt Nam
182
+
183
+ * Tài liệu: [Sổ tay hướng dẫn](https://vnstocks.com/docs/category/s%E1%BB%95-tay-h%C6%B0%E1%BB%9Bng-d%E1%BA%ABn)
184
+ * Cộng đồng: [Nhóm Facebook](https://www.facebook.com/groups/vnstock.official)
185
+
186
+ Khám phá các tính năng mới nhất và tham gia cộng đồng để nhận hỗ trợ.
187
+ """
188
+ )
189
+ fallback["terminal"] = (
190
+ """
191
+ ╔══════════════════════════════════════════════════════════╗
192
+ ║ ║
193
+ ║ 👋 Chào mừng bạn đến với Vnstock! ║
194
+ ║ ║
195
+ ║ Cảm ơn bạn đã sử dụng package phân tích ║
196
+ ║ chứng khoán #1 tại Việt Nam ║
197
+ ║ ║
198
+ ║ ✓ Tài liệu: https://vnstocks.com/docs/category/s%E1%BB%95-tay-h%C6%B0%E1%BB%9Bng-d%E1%BA%ABn ║
199
+ ║ ✓ Cộng đồng: https://www.facebook.com/groups/vnstock.official ║
200
+ ║ ║
201
+ ║ Khám phá các tính năng mới nhất và tham gia ║
202
+ ║ cộng đồng để nhận hỗ trợ. ║
203
+ ║ ║
204
+ ╚══════════════════════════════════════════════════════════╝
205
+ """
206
+ )
207
+ fallback["simple"] = (
208
+ "👋 Chào mừng bạn đến với Vnstock! "
209
+ "Tài liệu: https://vnstocks.com/docs/tai-lieu/huong-dan-nhanh | "
210
+ "Cộng đồng: https://www.facebook.com/groups/vnstock.official"
211
+ )
212
+ return fallback
213
+
214
+ # Singleton instance
215
+ manager = ContentManager()
216
+
217
+ def present(context="init"): # module-level shortcut
218
+ return manager.present_content(context=context)
vnai/scope/state.py CHANGED
@@ -1,74 +1,249 @@
1
- _L='minimal'
2
- _K='warnings'
3
- _J='api_requests'
4
- _I='last_error_time'
5
- _H='startup_time'
6
- _G='standard'
7
- _F='function_calls'
8
- _E='peak_memory'
9
- _D='errors'
10
- _C=True
11
- _B=None
12
- _A='execution_times'
13
- import time,threading,json,os
1
+ ##
2
+
3
+ ##
4
+
5
+
6
+ import time
7
+ import threading
8
+ import json
9
+ import os
14
10
  from datetime import datetime
15
11
  from pathlib import Path
12
+
16
13
  class Tracker:
17
- _instance=_B;_lock=threading.Lock()
18
- def __new__(A):
19
- with A._lock:
20
- if A._instance is _B:A._instance=super(Tracker,A).__new__(A);A._instance._initialize()
21
- return A._instance
22
- def _initialize(A):A.metrics={_H:datetime.now().isoformat(),_F:0,_J:0,_D:0,_K:0};A.performance_metrics={_A:[],_I:_B,_E:0};A.privacy_level=_G;A.home_dir=Path.home();A.project_dir=A.home_dir/'.vnstock';A.project_dir.mkdir(exist_ok=_C);A.data_dir=A.project_dir/'data';A.data_dir.mkdir(exist_ok=_C);A.metrics_path=A.data_dir/'usage_metrics.json';A.privacy_config_path=A.project_dir/'config'/'privacy.json';os.makedirs(os.path.dirname(A.privacy_config_path),exist_ok=_C);A._load_metrics();A._load_privacy_settings();A._start_background_collector()
23
- def _load_metrics(A):
24
- if A.metrics_path.exists():
25
- try:
26
- with open(A.metrics_path,'r')as C:D=json.load(C)
27
- for(B,E)in D.items():
28
- if B in A.metrics:A.metrics[B]=E
29
- except:pass
30
- def _save_metrics(A):
31
- try:
32
- with open(A.metrics_path,'w')as B:json.dump(A.metrics,B)
33
- except:pass
34
- def _load_privacy_settings(A):
35
- if A.privacy_config_path.exists():
36
- try:
37
- with open(A.privacy_config_path,'r')as B:C=json.load(B);A.privacy_level=C.get('level',_G)
38
- except:pass
39
- def setup_privacy(B,level=_B):
40
- A=level;C={_L:'Essential system data only',_G:'Performance metrics and errors','enhanced':'Detailed operation analytics'}
41
- if A is _B:A=_G
42
- if A not in C:raise ValueError(f"Invalid privacy level: {A}. Choose from {', '.join(C.keys())}")
43
- B.privacy_level=A
44
- with open(B.privacy_config_path,'w')as D:json.dump({'level':A},D)
45
- return A
46
- def get_privacy_level(A):return A.privacy_level
47
- def _start_background_collector(A):
48
- def B():
49
- while _C:
50
- try:
51
- import psutil as C;D=C.Process();E=D.memory_info();B=E.rss/1048576
52
- if B>A.performance_metrics[_E]:A.performance_metrics[_E]=B
53
- A._save_metrics()
54
- except:pass
55
- time.sleep(300)
56
- C=threading.Thread(target=B,daemon=_C);C.start()
57
- def record(A,event_type,data=_B):
58
- D='execution_time';C=data;B=event_type
59
- if A.privacy_level==_L and B!=_D:return _C
60
- if B in A.metrics:A.metrics[B]+=1
61
- else:A.metrics[B]=1
62
- if B==_D:A.performance_metrics[_I]=datetime.now().isoformat()
63
- if B==_F and C and D in C:
64
- A.performance_metrics[_A].append(C[D])
65
- if len(A.performance_metrics[_A])>100:A.performance_metrics[_A]=A.performance_metrics[_A][-100:]
66
- if A.metrics[_F]%100==0 or B==_D:A._save_metrics()
67
- return _C
68
- def get_metrics(A):
69
- B=0
70
- if A.performance_metrics[_A]:B=sum(A.performance_metrics[_A])/len(A.performance_metrics[_A])
71
- C=A.metrics.copy();C.update({'avg_execution_time':B,'peak_memory_mb':A.performance_metrics[_E],'uptime':(datetime.now()-datetime.fromisoformat(A.metrics[_H])).total_seconds(),'privacy_level':A.privacy_level});return C
72
- def reset(A):A.metrics={_H:datetime.now().isoformat(),_F:0,_J:0,_D:0,_K:0};A.performance_metrics={_A:[],_I:_B,_E:0};A._save_metrics();return _C
73
- tracker=Tracker()
74
- def record(event_type,data=_B):return tracker.record(event_type,data)
14
+ #--
15
+
16
+ _instance = None
17
+ _lock = threading.Lock()
18
+
19
+ def __new__(cls):
20
+ with cls._lock:
21
+ if cls._instance is None:
22
+ cls._instance = super(Tracker, cls).__new__(cls)
23
+ cls._instance._initialize()
24
+ return cls._instance
25
+
26
+ def _initialize(self):
27
+ #--
28
+ self.metrics = {
29
+ "startup_time": datetime.now().isoformat(),
30
+ "function_calls": 0,
31
+ "api_requests": 0,
32
+ "errors": 0,
33
+ "warnings": 0
34
+ }
35
+
36
+ self.performance_metrics = {
37
+ "execution_times": [],
38
+ "last_error_time": None,
39
+ "peak_memory": 0
40
+ }
41
+
42
+ self.privacy_level = "standard"
43
+
44
+ ##
45
+
46
+ self.home_dir = Path.home()
47
+ self.project_dir = self.home_dir / ".vnstock"
48
+ self.project_dir.mkdir(exist_ok=True)
49
+ self.data_dir = self.project_dir / 'data'
50
+ self.data_dir.mkdir(exist_ok=True)
51
+ self.metrics_path = self.data_dir / "usage_metrics.json"
52
+ self.privacy_config_path = self.project_dir / 'config' / "privacy.json"
53
+
54
+ ##
55
+
56
+ os.makedirs(os.path.dirname(self.privacy_config_path), exist_ok=True)
57
+
58
+ ##
59
+
60
+ self._load_metrics()
61
+
62
+ ##
63
+
64
+ self._load_privacy_settings()
65
+
66
+ ##
67
+
68
+ self._start_background_collector()
69
+
70
+ def _load_metrics(self):
71
+ #--
72
+ if self.metrics_path.exists():
73
+ try:
74
+ with open(self.metrics_path, 'r') as f:
75
+ stored_metrics = json.load(f)
76
+
77
+ ##
78
+
79
+ for key, value in stored_metrics.items():
80
+ if key in self.metrics:
81
+ self.metrics[key] = value
82
+ except:
83
+ pass
84
+
85
+ def _save_metrics(self):
86
+ #--
87
+ try:
88
+ with open(self.metrics_path, 'w') as f:
89
+ json.dump(self.metrics, f)
90
+ except:
91
+ pass
92
+
93
+ def _load_privacy_settings(self):
94
+ #--
95
+ if self.privacy_config_path.exists():
96
+ try:
97
+ with open(self.privacy_config_path, 'r') as f:
98
+ settings = json.load(f)
99
+ self.privacy_level = settings.get("level", "standard")
100
+ except:
101
+ pass
102
+
103
+ def setup_privacy(self, level=None):
104
+ #--
105
+ privacy_levels = {
106
+ "minimal": "Essential system data only",
107
+ "standard": "Performance metrics and errors",
108
+ "enhanced": "Detailed operation analytics"
109
+ }
110
+
111
+ if level is None:
112
+ ##
113
+
114
+ level = "standard"
115
+
116
+ if level not in privacy_levels:
117
+ raise ValueError(f"Invalid privacy level: {level}. Choose from {', '.join(privacy_levels.keys())}")
118
+
119
+ ##
120
+
121
+ self.privacy_level = level
122
+
123
+ ##
124
+
125
+ with open(self.privacy_config_path, "w") as f:
126
+ json.dump({"level": level}, f)
127
+
128
+ return level
129
+
130
+ def get_privacy_level(self):
131
+ #--
132
+ return self.privacy_level
133
+
134
+ def _start_background_collector(self):
135
+ #--
136
+ def collect_metrics():
137
+ while True:
138
+ try:
139
+ import psutil
140
+
141
+ ##
142
+
143
+ current_process = psutil.Process()
144
+ memory_info = current_process.memory_info()
145
+ memory_usage = memory_info.rss / (1024 * 1024) ##
146
+
147
+
148
+ if memory_usage > self.performance_metrics["peak_memory"]:
149
+ self.performance_metrics["peak_memory"] = memory_usage
150
+
151
+ ##
152
+
153
+ self._save_metrics()
154
+
155
+ except:
156
+ pass
157
+
158
+ time.sleep(300) ##
159
+
160
+
161
+ ##
162
+
163
+ thread = threading.Thread(target=collect_metrics, daemon=True)
164
+ thread.start()
165
+
166
+ def record(self, event_type, data=None):
167
+ #--
168
+ ##
169
+
170
+ if self.privacy_level == "minimal" and event_type != "errors":
171
+ ##
172
+
173
+ return True
174
+
175
+ ##
176
+
177
+ if event_type in self.metrics:
178
+ self.metrics[event_type] += 1
179
+ else:
180
+ self.metrics[event_type] = 1
181
+
182
+ ##
183
+
184
+ if event_type == "errors":
185
+ self.performance_metrics["last_error_time"] = datetime.now().isoformat()
186
+
187
+ ##
188
+
189
+ if event_type == "function_calls" and data and "execution_time" in data:
190
+ ##
191
+
192
+ self.performance_metrics["execution_times"].append(data["execution_time"])
193
+ if len(self.performance_metrics["execution_times"]) > 100:
194
+ self.performance_metrics["execution_times"] = self.performance_metrics["execution_times"][-100:]
195
+
196
+ ##
197
+
198
+ if self.metrics["function_calls"] % 100 == 0 or event_type == "errors":
199
+ self._save_metrics()
200
+
201
+ return True
202
+
203
+ def get_metrics(self):
204
+ #--
205
+ ##
206
+
207
+ avg_execution_time = 0
208
+ if self.performance_metrics["execution_times"]:
209
+ avg_execution_time = sum(self.performance_metrics["execution_times"]) / len(self.performance_metrics["execution_times"])
210
+
211
+ ##
212
+
213
+ output = self.metrics.copy()
214
+ output.update({
215
+ "avg_execution_time": avg_execution_time,
216
+ "peak_memory_mb": self.performance_metrics["peak_memory"],
217
+ "uptime": (datetime.now() - datetime.fromisoformat(self.metrics["startup_time"])).total_seconds(),
218
+ "privacy_level": self.privacy_level
219
+ })
220
+
221
+ return output
222
+
223
+ def reset(self):
224
+ #--
225
+ self.metrics = {
226
+ "startup_time": datetime.now().isoformat(),
227
+ "function_calls": 0,
228
+ "api_requests": 0,
229
+ "errors": 0,
230
+ "warnings": 0
231
+ }
232
+
233
+ self.performance_metrics = {
234
+ "execution_times": [],
235
+ "last_error_time": None,
236
+ "peak_memory": 0
237
+ }
238
+
239
+ self._save_metrics()
240
+ return True
241
+
242
+ ##
243
+
244
+ tracker = Tracker()
245
+
246
+
247
+ def record(event_type, data=None):
248
+ #--
249
+ return tracker.record(event_type, data)
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: vnai
3
- Version: 2.0.2
3
+ Version: 2.0.3
4
4
  Summary: System optimization and resource management toolkit
5
5
  Home-page: https://github.com/yourusername/vnai
6
6
  Author: Your Name
@@ -0,0 +1,16 @@
1
+ vnai/__init__.py,sha256=SF3HcEadrvSmtotBCy8a6637UwTFiSAaAN0Azi0X4qg,7219
2
+ vnai/beam/__init__.py,sha256=h19ZEQFnWTvqed0mpTcuQf-sT9XifWhfVbaobTEs91Q,131
3
+ vnai/beam/metrics.py,sha256=lNYEeav5kMm8SGnlsxwz6aD3fRzOytopHhUPkUx9Avs,5950
4
+ vnai/beam/pulse.py,sha256=-rN4tbcgNKmA74P2ThVkQqxabG0-UlhfRbFCyYPvKFw,2920
5
+ vnai/beam/quota.py,sha256=DRlqZpztppdFDJymuJS6VCKLHZrkI_PX8cUtStHDSFM,16934
6
+ vnai/flow/__init__.py,sha256=VW6R7c30M4q8PhOUqXyHwWlmk1BwPrYvcxtLFI0fWJo,91
7
+ vnai/flow/queue.py,sha256=0R6LjF6PSUz37JV2SnsOQMBHps3bG5c0BGfEOUIPhcA,3650
8
+ vnai/flow/relay.py,sha256=wIRojuZKQ5Jk1N-p2PkA9fkx-F7kwgVu0JIc0Iya5aw,13783
9
+ vnai/scope/__init__.py,sha256=yB0qWMlKd2ix5tFlBcRPX6SYR1O8Di0mwgQC15u8l2o,207
10
+ vnai/scope/profile.py,sha256=tIy39_FpcNKZCg3Dy5mgy0jdLQCH2FK2nfvUlTM72wM,26781
11
+ vnai/scope/promo.py,sha256=NlKcyadl6BlOr2TMlKkdri4dkm8xIoI_3Z05ErcVnGo,9930
12
+ vnai/scope/state.py,sha256=XUhuXNx1W6pce5vRY3IkSrR__MGetRo8lQt1bQIAOLM,6550
13
+ vnai-2.0.3.dist-info/METADATA,sha256=IlnWkYA8m9Rxjyfu7JCgpwJw0C7ldherJqhQnAdRrug,1017
14
+ vnai-2.0.3.dist-info/WHEEL,sha256=pxyMxgL8-pra_rKaQ4drOZAegBVuX-G_4nRHjjgWbmo,91
15
+ vnai-2.0.3.dist-info/top_level.txt,sha256=4zI0qZHePCwvgSqXl4420sBcd0VzZn4MEcRsAIFae3k,5
16
+ vnai-2.0.3.dist-info/RECORD,,
@@ -1,5 +1,5 @@
1
1
  Wheel-Version: 1.0
2
- Generator: setuptools (78.1.0)
2
+ Generator: setuptools (79.0.0)
3
3
  Root-Is-Purelib: true
4
4
  Tag: py3-none-any
5
5
 
@@ -1,16 +0,0 @@
1
- vnai/__init__.py,sha256=iS0LLz-J9MnC1m3aLPBPGfc7B36t2v4YX5lK4pRoiEU,4791
2
- vnai/beam/__init__.py,sha256=MG_4FkhQZyuKeaoQQh-KaULhxcGu370lGR6FVV5blU4,129
3
- vnai/beam/metrics.py,sha256=nVKoe0SJg0TNCPvAOaE99ZyBJ9Tw5WSRydyAObH8FrA,2709
4
- vnai/beam/pulse.py,sha256=5e21Ky6rVKD57bf8BzSA2lGzwHhohansoQzggrnEpIE,1580
5
- vnai/beam/quota.py,sha256=zJWONvtd4pxYGDtdalrXHj1yBDasEzoQpMkENN38a70,7364
6
- vnai/flow/__init__.py,sha256=BURTo8cXicmqqTbeB0qfXwVole0oGDVp_UxRSeh4qfA,80
7
- vnai/flow/queue.py,sha256=pvC_HSjctR62Uzt4b3h3EANJXmrkKBm3iiNVIrlTnJA,1912
8
- vnai/flow/relay.py,sha256=RU-paE3HVkgodPmNlAI8fAoVUcwufegY1WmsGL-sWpY,6676
9
- vnai/scope/__init__.py,sha256=o7N7JjgSqIfQeDojgnxzV9gthEWL3YxxljnvRO9AXkQ,196
10
- vnai/scope/profile.py,sha256=BHgX2yUQOMoJeUp_AaUWuc635bT1AJfw-FShNVRPikw,14985
11
- vnai/scope/promo.py,sha256=5Q8VQszYdUaHt-3VPQrZsnxSSYgaXYG-oXnGridBM7U,7167
12
- vnai/scope/state.py,sha256=JkVwJv8l_-ef201I_O1PHqFyp8KJ3VWyfmZnCltH18c,3283
13
- vnai-2.0.2.dist-info/METADATA,sha256=_jz71GfABM6GmUKnPCwZ4vc2iSwJEQOphpbozgitdDw,1017
14
- vnai-2.0.2.dist-info/WHEEL,sha256=CmyFI0kx5cdEMTLiONQRbGQwjIoR1aIYB7eCAQ4KPJ0,91
15
- vnai-2.0.2.dist-info/top_level.txt,sha256=4zI0qZHePCwvgSqXl4420sBcd0VzZn4MEcRsAIFae3k,5
16
- vnai-2.0.2.dist-info/RECORD,,