Spaces:
Build error
Build error
Create processing_helpers.py
Browse files- utils/processing_helpers.py +23 -0
utils/processing_helpers.py
ADDED
|
@@ -0,0 +1,23 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import multiprocessing
|
| 2 |
+
import streamlit as st
|
| 3 |
+
|
| 4 |
+
def get_optimal_workers():
|
| 5 |
+
"""Get optimal number of workers based on CPU cores."""
|
| 6 |
+
return max(multiprocessing.cpu_count() - 1, 1)
|
| 7 |
+
|
| 8 |
+
def display_performance_metrics():
|
| 9 |
+
"""Display current system performance metrics."""
|
| 10 |
+
st.sidebar.markdown("### System Performance")
|
| 11 |
+
available_cores = multiprocessing.cpu_count()
|
| 12 |
+
used_cores = st.sidebar.slider(
|
| 13 |
+
"CPU Cores to Use",
|
| 14 |
+
min_value=1,
|
| 15 |
+
max_value=available_cores,
|
| 16 |
+
value=get_optimal_workers(),
|
| 17 |
+
help="Adjust the number of CPU cores used for processing"
|
| 18 |
+
)
|
| 19 |
+
|
| 20 |
+
return {
|
| 21 |
+
'used_cores': used_cores,
|
| 22 |
+
'total_cores': available_cores
|
| 23 |
+
}
|