dsa-helpers 1.0.4.dev1__tar.gz → 1.0.5.dev0__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.
- {dsa_helpers-1.0.4.dev1/dsa_helpers.egg-info → dsa_helpers-1.0.5.dev0}/PKG-INFO +1 -1
- dsa_helpers-1.0.5.dev0/dsa_helpers/cli_utils.py +183 -0
- {dsa_helpers-1.0.4.dev1 → dsa_helpers-1.0.5.dev0}/dsa_helpers/image_utils.py +7 -6
- {dsa_helpers-1.0.4.dev1 → dsa_helpers-1.0.5.dev0/dsa_helpers.egg-info}/PKG-INFO +1 -1
- {dsa_helpers-1.0.4.dev1 → dsa_helpers-1.0.5.dev0}/dsa_helpers.egg-info/SOURCES.txt +1 -0
- {dsa_helpers-1.0.4.dev1 → dsa_helpers-1.0.5.dev0}/pyproject.toml +1 -1
- {dsa_helpers-1.0.4.dev1 → dsa_helpers-1.0.5.dev0}/.gitignore +0 -0
- {dsa_helpers-1.0.4.dev1 → dsa_helpers-1.0.5.dev0}/.readthedocs.yaml +0 -0
- {dsa_helpers-1.0.4.dev1 → dsa_helpers-1.0.5.dev0}/LICENSE +0 -0
- {dsa_helpers-1.0.4.dev1 → dsa_helpers-1.0.5.dev0}/README.md +0 -0
- {dsa_helpers-1.0.4.dev1 → dsa_helpers-1.0.5.dev0}/app.py +0 -0
- {dsa_helpers-1.0.4.dev1 → dsa_helpers-1.0.5.dev0}/docs/requirements.txt +0 -0
- {dsa_helpers-1.0.4.dev1 → dsa_helpers-1.0.5.dev0}/docs/source/conf.py +0 -0
- {dsa_helpers-1.0.4.dev1 → dsa_helpers-1.0.5.dev0}/docs/source/index.rst +0 -0
- {dsa_helpers-1.0.4.dev1 → dsa_helpers-1.0.5.dev0}/dsa_helpers/__init__.py +0 -0
- {dsa_helpers-1.0.4.dev1 → dsa_helpers-1.0.5.dev0}/dsa_helpers/dash/__init__.py +0 -0
- {dsa_helpers-1.0.4.dev1 → dsa_helpers-1.0.5.dev0}/dsa_helpers/dash/dash_paperdragon_utils.py +0 -0
- {dsa_helpers-1.0.4.dev1 → dsa_helpers-1.0.5.dev0}/dsa_helpers/dash/header.py +0 -0
- {dsa_helpers-1.0.4.dev1 → dsa_helpers-1.0.5.dev0}/dsa_helpers/dash/header_callbacks.py +0 -0
- {dsa_helpers-1.0.4.dev1 → dsa_helpers-1.0.5.dev0}/dsa_helpers/girder_utils.py +0 -0
- {dsa_helpers-1.0.4.dev1 → dsa_helpers-1.0.5.dev0}/dsa_helpers/imread.py +0 -0
- {dsa_helpers-1.0.4.dev1 → dsa_helpers-1.0.5.dev0}/dsa_helpers/imwrite.py +0 -0
- {dsa_helpers-1.0.4.dev1 → dsa_helpers-1.0.5.dev0}/dsa_helpers/ml/__init__.py +0 -0
- {dsa_helpers-1.0.4.dev1 → dsa_helpers-1.0.5.dev0}/dsa_helpers/ml/callbacks.py +0 -0
- {dsa_helpers-1.0.4.dev1 → dsa_helpers-1.0.5.dev0}/dsa_helpers/ml/datasets/SegFormerSegmentationDataset.py +0 -0
- {dsa_helpers-1.0.4.dev1 → dsa_helpers-1.0.5.dev0}/dsa_helpers/ml/datasets/__init__.py +0 -0
- {dsa_helpers-1.0.4.dev1 → dsa_helpers-1.0.5.dev0}/dsa_helpers/ml/datasets/utils.py +0 -0
- {dsa_helpers-1.0.4.dev1 → dsa_helpers-1.0.5.dev0}/dsa_helpers/ml/evaluate.py +0 -0
- {dsa_helpers-1.0.4.dev1 → dsa_helpers-1.0.5.dev0}/dsa_helpers/ml/metrics.py +0 -0
- {dsa_helpers-1.0.4.dev1 → dsa_helpers-1.0.5.dev0}/dsa_helpers/ml/object_detection/__init__.py +0 -0
- {dsa_helpers-1.0.4.dev1 → dsa_helpers-1.0.5.dev0}/dsa_helpers/ml/object_detection/get_pearce_roi_images.py +0 -0
- {dsa_helpers-1.0.4.dev1 → dsa_helpers-1.0.5.dev0}/dsa_helpers/ml/object_detection/tile_image.py +0 -0
- {dsa_helpers-1.0.4.dev1 → dsa_helpers-1.0.5.dev0}/dsa_helpers/ml/object_detection/utils.py +0 -0
- {dsa_helpers-1.0.4.dev1 → dsa_helpers-1.0.5.dev0}/dsa_helpers/ml/segformer_semantic_segmentation/__init__.py +0 -0
- {dsa_helpers-1.0.4.dev1 → dsa_helpers-1.0.5.dev0}/dsa_helpers/ml/segformer_semantic_segmentation/inference.py +0 -0
- {dsa_helpers-1.0.4.dev1 → dsa_helpers-1.0.5.dev0}/dsa_helpers/ml/transforms/__init__.py +0 -0
- {dsa_helpers-1.0.4.dev1 → dsa_helpers-1.0.5.dev0}/dsa_helpers/ml/transforms/segformer_transforms.py +0 -0
- {dsa_helpers-1.0.4.dev1 → dsa_helpers-1.0.5.dev0}/dsa_helpers/mongo_utils.py +0 -0
- {dsa_helpers-1.0.4.dev1 → dsa_helpers-1.0.5.dev0}/dsa_helpers/tile_utils.py +0 -0
- {dsa_helpers-1.0.4.dev1 → dsa_helpers-1.0.5.dev0}/dsa_helpers/tiling.py +0 -0
- {dsa_helpers-1.0.4.dev1 → dsa_helpers-1.0.5.dev0}/dsa_helpers/utils.py +0 -0
- {dsa_helpers-1.0.4.dev1 → dsa_helpers-1.0.5.dev0}/dsa_helpers.egg-info/dependency_links.txt +0 -0
- {dsa_helpers-1.0.4.dev1 → dsa_helpers-1.0.5.dev0}/dsa_helpers.egg-info/requires.txt +0 -0
- {dsa_helpers-1.0.4.dev1 → dsa_helpers-1.0.5.dev0}/dsa_helpers.egg-info/top_level.txt +0 -0
- {dsa_helpers-1.0.4.dev1 → dsa_helpers-1.0.5.dev0}/setup.cfg +0 -0
- {dsa_helpers-1.0.4.dev1 → dsa_helpers-1.0.5.dev0}/tests/app/Dockerfile +0 -0
- {dsa_helpers-1.0.4.dev1 → dsa_helpers-1.0.5.dev0}/tests/app/app.py +0 -0
- {dsa_helpers-1.0.4.dev1 → dsa_helpers-1.0.5.dev0}/tests/docker-compose.yaml +0 -0
- {dsa_helpers-1.0.4.dev1 → dsa_helpers-1.0.5.dev0}/tests/test.ipynb +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: dsa_helpers
|
|
3
|
-
Version: 1.0.
|
|
3
|
+
Version: 1.0.5.dev0
|
|
4
4
|
Summary: Utility functions for working with the DSA girder client.
|
|
5
5
|
Author-email: "Juan C. Vizcarra" <jvizcar@emory.edu>
|
|
6
6
|
Maintainer-email: "Juan C. Vizcarra" <jvizcar@emory.edu>
|
|
@@ -0,0 +1,183 @@
|
|
|
1
|
+
from collections import deque
|
|
2
|
+
import psutil, threading, time
|
|
3
|
+
import numpy as np
|
|
4
|
+
|
|
5
|
+
|
|
6
|
+
class SystemMonitor:
|
|
7
|
+
def __init__(self, interval=0.5):
|
|
8
|
+
self.interval = interval
|
|
9
|
+
self.cpu_percentages = deque(maxlen=100)
|
|
10
|
+
self.memory_usage = deque(maxlen=100)
|
|
11
|
+
self.io_wait = deque(maxlen=100)
|
|
12
|
+
self.cpu_per_core = deque(maxlen=100) # Track per-core usage
|
|
13
|
+
self.memory_bandwidth = deque(maxlen=100)
|
|
14
|
+
self.io_stats = deque(maxlen=100)
|
|
15
|
+
self.stop_flag = False
|
|
16
|
+
self.process = psutil.Process()
|
|
17
|
+
|
|
18
|
+
def start(self):
|
|
19
|
+
self.stop_flag = False
|
|
20
|
+
self.monitor_thread = threading.Thread(target=self._monitor)
|
|
21
|
+
self.monitor_thread.start()
|
|
22
|
+
|
|
23
|
+
def stop(self):
|
|
24
|
+
self.stop_flag = True
|
|
25
|
+
self.monitor_thread.join()
|
|
26
|
+
|
|
27
|
+
# Calculate statistics with safety checks
|
|
28
|
+
cpu_stats = {
|
|
29
|
+
"mean": (
|
|
30
|
+
np.mean(self.cpu_percentages)
|
|
31
|
+
if len(self.cpu_percentages) > 0
|
|
32
|
+
else 0
|
|
33
|
+
),
|
|
34
|
+
"max": (
|
|
35
|
+
np.max(self.cpu_percentages)
|
|
36
|
+
if len(self.cpu_percentages) > 0
|
|
37
|
+
else 0
|
|
38
|
+
),
|
|
39
|
+
"min": (
|
|
40
|
+
np.min(self.cpu_percentages)
|
|
41
|
+
if len(self.cpu_percentages) > 0
|
|
42
|
+
else 0
|
|
43
|
+
),
|
|
44
|
+
"per_core_mean": (
|
|
45
|
+
np.mean(self.cpu_per_core, axis=0)
|
|
46
|
+
if len(self.cpu_per_core) > 0
|
|
47
|
+
else np.zeros(psutil.cpu_count())
|
|
48
|
+
),
|
|
49
|
+
"per_core_max": (
|
|
50
|
+
np.max(self.cpu_per_core, axis=0)
|
|
51
|
+
if len(self.cpu_per_core) > 0
|
|
52
|
+
else np.zeros(psutil.cpu_count())
|
|
53
|
+
),
|
|
54
|
+
"active_cores_mean": (
|
|
55
|
+
np.mean(
|
|
56
|
+
[
|
|
57
|
+
sum(1 for x in cores if x > 10)
|
|
58
|
+
for cores in self.cpu_per_core
|
|
59
|
+
]
|
|
60
|
+
)
|
|
61
|
+
if len(self.cpu_per_core) > 0
|
|
62
|
+
else 0
|
|
63
|
+
),
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
mem_stats = {
|
|
67
|
+
"mean": (
|
|
68
|
+
np.mean(self.memory_usage) if len(self.memory_usage) > 0 else 0
|
|
69
|
+
),
|
|
70
|
+
"max": (
|
|
71
|
+
np.max(self.memory_usage) if len(self.memory_usage) > 0 else 0
|
|
72
|
+
),
|
|
73
|
+
"min": (
|
|
74
|
+
np.min(self.memory_usage) if len(self.memory_usage) > 0 else 0
|
|
75
|
+
),
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
io_stats = {
|
|
79
|
+
"wait_mean": np.mean(self.io_wait) if len(self.io_wait) > 0 else 0,
|
|
80
|
+
"wait_max": np.max(self.io_wait) if len(self.io_wait) > 0 else 0,
|
|
81
|
+
"throughput_read": (
|
|
82
|
+
np.mean(
|
|
83
|
+
[
|
|
84
|
+
sum(disk["read_bytes"] for disk in x["disk"].values())
|
|
85
|
+
/ x["time_delta"]
|
|
86
|
+
for x in self.io_stats
|
|
87
|
+
]
|
|
88
|
+
)
|
|
89
|
+
/ 1024
|
|
90
|
+
/ 1024
|
|
91
|
+
if len(self.io_stats) > 0
|
|
92
|
+
else 0
|
|
93
|
+
),
|
|
94
|
+
"throughput_write": (
|
|
95
|
+
np.mean(
|
|
96
|
+
[
|
|
97
|
+
sum(disk["write_bytes"] for disk in x["disk"].values())
|
|
98
|
+
/ x["time_delta"]
|
|
99
|
+
for x in self.io_stats
|
|
100
|
+
]
|
|
101
|
+
)
|
|
102
|
+
/ 1024
|
|
103
|
+
/ 1024
|
|
104
|
+
if len(self.io_stats) > 0
|
|
105
|
+
else 0
|
|
106
|
+
),
|
|
107
|
+
"network_read": (
|
|
108
|
+
np.mean(
|
|
109
|
+
[
|
|
110
|
+
x["network"]["bytes_recv"] / x["time_delta"]
|
|
111
|
+
for x in self.io_stats
|
|
112
|
+
]
|
|
113
|
+
)
|
|
114
|
+
/ 1024
|
|
115
|
+
/ 1024
|
|
116
|
+
if len(self.io_stats) > 0
|
|
117
|
+
else 0
|
|
118
|
+
),
|
|
119
|
+
"network_write": (
|
|
120
|
+
np.mean(
|
|
121
|
+
[
|
|
122
|
+
x["network"]["bytes_sent"] / x["time_delta"]
|
|
123
|
+
for x in self.io_stats
|
|
124
|
+
]
|
|
125
|
+
)
|
|
126
|
+
/ 1024
|
|
127
|
+
/ 1024
|
|
128
|
+
if len(self.io_stats) > 0
|
|
129
|
+
else 0
|
|
130
|
+
),
|
|
131
|
+
}
|
|
132
|
+
|
|
133
|
+
return {"cpu": cpu_stats, "memory": mem_stats, "io": io_stats}
|
|
134
|
+
|
|
135
|
+
def _monitor(self):
|
|
136
|
+
last_io = psutil.disk_io_counters(perdisk=True) # Monitor per-disk
|
|
137
|
+
last_net = psutil.net_io_counters() # Add network monitoring
|
|
138
|
+
last_time = time.time()
|
|
139
|
+
|
|
140
|
+
while not self.stop_flag:
|
|
141
|
+
# CPU usage (overall and per-core)
|
|
142
|
+
per_core = psutil.cpu_percent(percpu=True)
|
|
143
|
+
self.cpu_percentages.append(np.mean(per_core))
|
|
144
|
+
self.cpu_per_core.append(per_core)
|
|
145
|
+
|
|
146
|
+
# Memory usage
|
|
147
|
+
mem = self.process.memory_info()
|
|
148
|
+
self.memory_usage.append(mem.rss / 1024 / 1024) # Convert to MB
|
|
149
|
+
|
|
150
|
+
# IO wait and throughput
|
|
151
|
+
cpu_times = psutil.cpu_times_percent()
|
|
152
|
+
self.io_wait.append(cpu_times.iowait)
|
|
153
|
+
|
|
154
|
+
# Enhanced IO monitoring
|
|
155
|
+
current_io = psutil.disk_io_counters(perdisk=True)
|
|
156
|
+
current_net = psutil.net_io_counters()
|
|
157
|
+
current_time = time.time()
|
|
158
|
+
|
|
159
|
+
# Calculate both disk and network throughput
|
|
160
|
+
delta_time = current_time - last_time
|
|
161
|
+
io_delta = {
|
|
162
|
+
"disk": {
|
|
163
|
+
disk: {
|
|
164
|
+
"read_bytes": current_io[disk].read_bytes
|
|
165
|
+
- last_io[disk].read_bytes,
|
|
166
|
+
"write_bytes": current_io[disk].write_bytes
|
|
167
|
+
- last_io[disk].write_bytes,
|
|
168
|
+
}
|
|
169
|
+
for disk in current_io
|
|
170
|
+
},
|
|
171
|
+
"network": {
|
|
172
|
+
"bytes_recv": current_net.bytes_recv - last_net.bytes_recv,
|
|
173
|
+
"bytes_sent": current_net.bytes_sent - last_net.bytes_sent,
|
|
174
|
+
},
|
|
175
|
+
"time_delta": delta_time,
|
|
176
|
+
}
|
|
177
|
+
self.io_stats.append(io_delta)
|
|
178
|
+
|
|
179
|
+
last_io = current_io
|
|
180
|
+
last_net = current_net
|
|
181
|
+
last_time = current_time
|
|
182
|
+
|
|
183
|
+
time.sleep(self.interval)
|
|
@@ -89,13 +89,14 @@ def label_mask_to_polygons(
|
|
|
89
89
|
|
|
90
90
|
# Convert to shapely polygon objects.
|
|
91
91
|
for data in polygons_dict.values():
|
|
92
|
-
|
|
92
|
+
if "polygon" in data:
|
|
93
|
+
polygon = Polygon(data["polygon"], holes=data["holes"])
|
|
93
94
|
|
|
94
|
-
|
|
95
|
-
|
|
95
|
+
# Shift the polygon by the offset.
|
|
96
|
+
polygon = translate(polygon, xoff=x_offset, yoff=y_offset)
|
|
96
97
|
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
98
|
+
# Include the polygon if it's greater than the minimum area.
|
|
99
|
+
if polygon.area >= min_area:
|
|
100
|
+
polygons.append([polygon, int(label)])
|
|
100
101
|
|
|
101
102
|
return polygons
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: dsa_helpers
|
|
3
|
-
Version: 1.0.
|
|
3
|
+
Version: 1.0.5.dev0
|
|
4
4
|
Summary: Utility functions for working with the DSA girder client.
|
|
5
5
|
Author-email: "Juan C. Vizcarra" <jvizcar@emory.edu>
|
|
6
6
|
Maintainer-email: "Juan C. Vizcarra" <jvizcar@emory.edu>
|
|
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
|
{dsa_helpers-1.0.4.dev1 → dsa_helpers-1.0.5.dev0}/dsa_helpers/dash/dash_paperdragon_utils.py
RENAMED
|
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
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
{dsa_helpers-1.0.4.dev1 → dsa_helpers-1.0.5.dev0}/dsa_helpers/ml/object_detection/__init__.py
RENAMED
|
File without changes
|
|
File without changes
|
{dsa_helpers-1.0.4.dev1 → dsa_helpers-1.0.5.dev0}/dsa_helpers/ml/object_detection/tile_image.py
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
{dsa_helpers-1.0.4.dev1 → dsa_helpers-1.0.5.dev0}/dsa_helpers/ml/transforms/segformer_transforms.py
RENAMED
|
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
|
|
File without changes
|
|
File without changes
|
|
File without changes
|