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,28 +482,49 @@ def api_cluster_nodes(): ...@@ -482,28 +482,49 @@ 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
workers = [] for cid, client_info in cluster_master.clients.items():
for backend in available_backends: if client_info['token'] == token:
workers.extend([ client_id = cid
{ break
'type': 'analysis',
'backend': backend, if client_id:
'weight': 10, # Get registered processes for this client
'model': 'default', workers = []
'status': 'active' for proc_key, proc_info in cluster_master.processes.items():
}, if proc_info['client_id'] == client_id:
{ worker_info = {
'type': 'training', 'type': proc_info['name'].split('_')[0], # analysis or training
'backend': backend, 'backend': proc_info['name'].split('_')[1] if '_' in proc_info['name'] else 'unknown',
'weight': 5, 'weight': proc_info.get('weight', 10),
'model': 'default', 'model': proc_info.get('model', 'default'),
'status': 'active' 'status': proc_info.get('status', 'active')
} }
]) workers.append(worker_info)
node_map[node_key]['workers'] = workers node_map[node_key]['workers'] = workers
else:
# Fallback: assume standard workers based on available_backends
workers = []
for backend in available_backends:
workers.extend([
{
'type': 'analysis',
'backend': backend,
'weight': 10,
'model': 'default',
'status': 'active'
},
{
'type': 'training',
'backend': backend,
'weight': 5,
'model': 'default',
'status': 'active'
}
])
node_map[node_key]['workers'] = workers
# Convert node_map to nodes list # Convert node_map to nodes list
for node_key, node_data in node_map.items(): for node_key, node_data in node_map.items():
......
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