sciveo 0.0.34__tar.gz → 0.0.35__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.
Files changed (37) hide show
  1. {sciveo-0.0.34 → sciveo-0.0.35}/PKG-INFO +1 -1
  2. {sciveo-0.0.34 → sciveo-0.0.35}/sciveo/monitoring/monitor.py +46 -27
  3. sciveo-0.0.35/sciveo/version.py +2 -0
  4. {sciveo-0.0.34 → sciveo-0.0.35}/sciveo.egg-info/PKG-INFO +1 -1
  5. {sciveo-0.0.34 → sciveo-0.0.35}/sciveo.egg-info/SOURCES.txt +1 -0
  6. sciveo-0.0.35/test/test_monitoring.py +26 -0
  7. sciveo-0.0.34/sciveo/version.py +0 -2
  8. {sciveo-0.0.34 → sciveo-0.0.35}/README.md +0 -0
  9. {sciveo-0.0.34 → sciveo-0.0.35}/sciveo/__init__.py +0 -0
  10. {sciveo-0.0.34 → sciveo-0.0.35}/sciveo/api/__init__.py +0 -0
  11. {sciveo-0.0.34 → sciveo-0.0.35}/sciveo/api/base.py +0 -0
  12. {sciveo-0.0.34 → sciveo-0.0.35}/sciveo/api/upload.py +0 -0
  13. {sciveo-0.0.34 → sciveo-0.0.35}/sciveo/common/__init__.py +0 -0
  14. {sciveo-0.0.34 → sciveo-0.0.35}/sciveo/common/configuration.py +0 -0
  15. {sciveo-0.0.34 → sciveo-0.0.35}/sciveo/common/model.py +0 -0
  16. {sciveo-0.0.34 → sciveo-0.0.35}/sciveo/common/optimizers.py +0 -0
  17. {sciveo-0.0.34 → sciveo-0.0.35}/sciveo/common/sampling.py +0 -0
  18. {sciveo-0.0.34 → sciveo-0.0.35}/sciveo/common/tools/__init__.py +0 -0
  19. {sciveo-0.0.34 → sciveo-0.0.35}/sciveo/common/tools/daemon.py +0 -0
  20. {sciveo-0.0.34 → sciveo-0.0.35}/sciveo/common/tools/formating.py +0 -0
  21. {sciveo-0.0.34 → sciveo-0.0.35}/sciveo/common/tools/hardware.py +0 -0
  22. {sciveo-0.0.34 → sciveo-0.0.35}/sciveo/common/tools/logger.py +0 -0
  23. {sciveo-0.0.34 → sciveo-0.0.35}/sciveo/common/tools/synchronized.py +0 -0
  24. {sciveo-0.0.34 → sciveo-0.0.35}/sciveo/content/__init__.py +0 -0
  25. {sciveo-0.0.34 → sciveo-0.0.35}/sciveo/content/dataset.py +0 -0
  26. {sciveo-0.0.34 → sciveo-0.0.35}/sciveo/content/experiment.py +0 -0
  27. {sciveo-0.0.34 → sciveo-0.0.35}/sciveo/content/project.py +0 -0
  28. {sciveo-0.0.34 → sciveo-0.0.35}/sciveo/content/runner.py +0 -0
  29. {sciveo-0.0.34 → sciveo-0.0.35}/sciveo/monitoring/__init__.py +0 -0
  30. {sciveo-0.0.34 → sciveo-0.0.35}/sciveo.egg-info/dependency_links.txt +0 -0
  31. {sciveo-0.0.34 → sciveo-0.0.35}/sciveo.egg-info/requires.txt +0 -0
  32. {sciveo-0.0.34 → sciveo-0.0.35}/sciveo.egg-info/top_level.txt +0 -0
  33. {sciveo-0.0.34 → sciveo-0.0.35}/setup.cfg +0 -0
  34. {sciveo-0.0.34 → sciveo-0.0.35}/setup.py +0 -0
  35. {sciveo-0.0.34 → sciveo-0.0.35}/test/test_configuration.py +0 -0
  36. {sciveo-0.0.34 → sciveo-0.0.35}/test/test_runner.py +0 -0
  37. {sciveo-0.0.34 → sciveo-0.0.35}/test/test_sampling.py +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: sciveo
3
- Version: 0.0.34
3
+ Version: 0.0.35
4
4
  Description-Content-Type: text/markdown
5
5
  Provides-Extra: mon
6
6
 
@@ -33,8 +33,24 @@ class BaseMonitor(DaemonBase):
33
33
  self.data["RAM"] = {
34
34
  "installed": self.data["RAM"]
35
35
  }
36
+ self.data["LOG"] = {}
37
+ self.data["sample"] = {}
38
+
39
+ self.data["config"] = {
40
+ "CPU usage": {"ratio": 1.0, "metric": "%", "ylim": [0.0, 100.0]},
41
+ "CPU usage per core": {"ratio": 1.0, "metric": "%", "ylim": [0.0, 100.0]},
42
+
43
+ "RAM used": {"ratio": 1.0 / (1024 * 1024 * 1024), "metric": "GB"},
44
+
45
+ "GPU fan.speed": {"ratio": 1.0, "metric": "%", "ylim": [0.0, 100.0]},
46
+ "GPU power.draw": {"ratio": 1.0, "metric": "W", "ylim": [0.0, 200.0]},
47
+ "GPU memory.free": {"ratio": 1.0 / 1024, "metric": "GB"},
48
+ "GPU memory.used": {"ratio": 1.0 / 1024, "metric": "GB"},
49
+ "GPU temperature.gpu": {"ratio": 1.0, "metric": "°C"},
50
+ "GPU utilization.gpu": {"ratio": 1.0, "metric": "%", "ylim": [0.0, 100.0]},
51
+ "GPU utilization.memory": {"ratio": 1.0, "metric": "%", "ylim": [0.0, 100.0]},
52
+ }
36
53
 
37
- self.data["logs"] = {}
38
54
  self.list_logs = []
39
55
 
40
56
  self.api = APIRemoteClient()
@@ -44,9 +60,9 @@ class BaseMonitor(DaemonBase):
44
60
  initial_cpu_usage = psutil.cpu_percent(interval=None, percpu=True)
45
61
  time.sleep(1)
46
62
 
47
- cpuserial = self.getserial()
63
+ machine_serial = self.getserial()
48
64
 
49
- debug(type(self).__name__, "init", cpuserial, "initial_cpu_usage", initial_cpu_usage)
65
+ debug(type(self).__name__, "init", machine_serial, "initial_cpu_usage", initial_cpu_usage)
50
66
 
51
67
  def __call__(self):
52
68
  return self.data
@@ -58,6 +74,7 @@ class BaseMonitor(DaemonBase):
58
74
 
59
75
  self.tail_logs()
60
76
  self.data["local_time"] = datetime.datetime.now().strftime("%Y-%m-%d %H:%M:%S")
77
+ self.data["sample"]["time"] = self.data["local_time"]
61
78
 
62
79
  api_result = self.api.POST_SCI("monitor", {"data": self.data})
63
80
 
@@ -65,38 +82,39 @@ class BaseMonitor(DaemonBase):
65
82
 
66
83
  def tail_logs(self):
67
84
  for log_name, log_path in self.list_logs:
68
- self.data["logs"][log_name] = self.tail_file(log_path)[-3:]
85
+ self.data["LOG"][log_name] = self.tail_file(log_path)[-3:]
69
86
 
70
87
  def get_cpu_usage(self):
71
- self.data["CPU"]["usage_per_core"] = psutil.cpu_percent(interval=None, percpu=True)
72
- # self.data["CPU"]["usage_per_core"] = (np.array(self.data["CPU"]["usage_per_core"]) / 100.0).tolist()
73
- self.data["CPU"]["usage"] = np.array(self.data["CPU"]["usage_per_core"]).mean()
88
+ usage_per_core = psutil.cpu_percent(interval=None, percpu=True)
89
+ self.data["sample"]["CPU usage per core"] = usage_per_core
90
+ self.data["sample"]["CPU usage"] = np.array(usage_per_core).mean()
74
91
 
75
92
  def get_memory(self):
76
93
  memory = psutil.virtual_memory()
94
+ self.data["sample"]["RAM used"] = memory.used
95
+ self.data["config"]["RAM used"]["ylim"] = [0, memory.total * self.data["config"]["RAM used"]["ratio"]]
77
96
  self.data["RAM"]["total"] = memory.total
78
- self.data["RAM"]["used"] = memory.used
79
97
  self.data["RAM"]["free"] = memory.free
80
98
  self.data["RAM"]["print"] = f"total: {format_memory_size(memory.total)} used: {format_memory_size(memory.used)}"
81
99
 
82
100
  def getserial(self):
83
- cpuserial = None
101
+ machine_serial = None
84
102
  try:
85
103
  with open('/proc/cpuinfo','r') as fp:
86
104
  for line in fp:
87
105
  if line.startswith('Serial'):
88
- cpuserial = line[10:26]
106
+ machine_serial = line[10:26]
89
107
  except Exception:
90
108
  pass
91
- if cpuserial is None:
109
+ if machine_serial is None:
92
110
  try:
93
- cpuserial = socket.gethostname()
111
+ machine_serial = socket.gethostname()
94
112
  except Exception:
95
113
  pass
96
- if cpuserial is None:
97
- cpuserial = f"RND-{random_token(8)}"
98
- self.data["serial"] = cpuserial
99
- return cpuserial
114
+ if machine_serial is None:
115
+ machine_serial = f"RND-{random_token(8)}"
116
+ self.data["serial"] = machine_serial
117
+ return machine_serial
100
118
 
101
119
  def tail_file(self, file_path, block_size=1024):
102
120
  result = ["EMPTY"]
@@ -124,28 +142,29 @@ class BaseMonitor(DaemonBase):
124
142
  header = lines[0].split(", ")
125
143
 
126
144
  keys = []
127
- units = {}
145
+ gpu_keys = []
128
146
  for k in header:
129
147
  k_split = k.split(' ')
130
148
  key = k_split[0]
131
149
  keys.append(key)
132
- if len(k_split) >= 2:
133
- units[key] = k_split[1].replace('[', '').replace(']', '')
150
+ gpu_keys.append(f"GPU {key}")
151
+
152
+ self.data.setdefault("GPU", {})
134
153
 
135
- data = []
136
154
  for i in range(1, len(lines)):
137
155
  line_values = lines[i].split(", ")
138
- line_data = {}
139
156
  for j, value in enumerate(line_values):
140
157
  value = value.split(' ')[0]
141
- line_data[keys[j]] = value
142
- data.append(line_data)
158
+ if gpu_keys[j] in self.data["config"]:
159
+ self.data["sample"][gpu_keys[j]] = value
160
+ else:
161
+ self.data["GPU"][keys[j]] = value
143
162
 
144
- self.data.setdefault("GPU", {})
145
- self.data["GPU"]["units"] = units
146
- self.data["GPU"]["data"] = data
163
+ if "memory.total" in self.data["GPU"]:
164
+ for k in ["GPU memory.used", "GPU memory.free"]:
165
+ self.data["config"][k]["ylim"] = [0, self.data["GPU"]["memory.total"] * self.data["config"][k]["ratio"]]
147
166
 
148
- except subprocess.CalledProcessError as e:
167
+ except Exception as e:
149
168
  pass
150
169
 
151
170
 
@@ -0,0 +1,2 @@
1
+
2
+ __version__ = '0.0.35'
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: sciveo
3
- Version: 0.0.34
3
+ Version: 0.0.35
4
4
  Description-Content-Type: text/markdown
5
5
  Provides-Extra: mon
6
6
 
@@ -29,5 +29,6 @@ sciveo/content/runner.py
29
29
  sciveo/monitoring/__init__.py
30
30
  sciveo/monitoring/monitor.py
31
31
  test/test_configuration.py
32
+ test/test_monitoring.py
32
33
  test/test_runner.py
33
34
  test/test_sampling.py
@@ -0,0 +1,26 @@
1
+ #
2
+ # Pavlin Georgiev, Softel Labs
3
+ #
4
+ # This is a proprietary file and may not be copied,
5
+ # distributed, or modified without express permission
6
+ # from the owner. For licensing inquiries, please
7
+ # contact pavlin@softel.bg.
8
+ #
9
+ # 2024
10
+ #
11
+
12
+ import unittest
13
+ import numpy as np
14
+
15
+ from sciveo.common.tools.logger import *
16
+ from sciveo.monitoring.monitor import *
17
+
18
+
19
+ class TestMonitoring(unittest.TestCase):
20
+ def test_cpu(self):
21
+ m = BaseMonitor()
22
+ m.get_cpu_usage()
23
+ print(m.data)
24
+
25
+ self.assertTrue("usage_per_core" in m.data["CPU"])
26
+ self.assertTrue("usage" in m.data["CPU"])
@@ -1,2 +0,0 @@
1
-
2
- __version__ = '0.0.34'
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes