Fix cluster nodes API to show actual worker counts

- Get real worker process information from cluster master instead of placeholder data
- Display correct number of workers and their actual backends
- Improve accuracy of cluster node statistics
parent 4907cef6
...@@ -482,9 +482,30 @@ def api_cluster_nodes(): ...@@ -482,9 +482,30 @@ def api_cluster_nodes():
'workers': [] # Will collect worker details 'workers': [] # Will collect worker details
} }
# For now, we don't have worker details in database, so we'll use placeholder # Get actual worker processes from cluster master
# In a full implementation, you'd store worker info in database too from .cluster_master import cluster_master
# For now, assume standard workers based on available backends client_id = None
for cid, client_info in cluster_master.clients.items():
if client_info['token'] == token:
client_id = cid
break
if client_id:
# Get registered processes for this client
workers = []
for proc_key, proc_info in cluster_master.processes.items():
if proc_info['client_id'] == client_id:
worker_info = {
'type': proc_info['name'].split('_')[0], # analysis or training
'backend': proc_info['name'].split('_')[1] if '_' in proc_info['name'] else 'unknown',
'weight': proc_info.get('weight', 10),
'model': proc_info.get('model', 'default'),
'status': proc_info.get('status', 'active')
}
workers.append(worker_info)
node_map[node_key]['workers'] = workers
else:
# Fallback: assume standard workers based on available_backends
workers = [] workers = []
for backend in available_backends: for backend in available_backends:
workers.extend([ workers.extend([
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment