Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2026-11-09 10:47:32

0001 """Production dashboard: the home tab and its standalone document."""
0002 
0003 import logging
0004 
0005 from django.shortcuts import render
0006 from django.template.loader import render_to_string
0007 from django.templatetags.static import static
0008 from django.urls import reverse
0009 
0010 from monitor_app.comp_snapshot import get_snapshot
0011 
0012 logger = logging.getLogger(__name__)
0013 
0014 
0015 def dashboard_document(request):
0016     """Render the shared dashboard with the current cached production record."""
0017     try:
0018         record = get_snapshot()
0019     except Exception:
0020         logger.exception('Production dashboard snapshot unavailable')
0021         record = {'error': 'The production record is temporarily unavailable.'}
0022     config = {
0023         'snapshotUrl': reverse('monitor_app:comp_snapshot_json'),
0024         'historyUrl': reverse('monitor_app:prod_dashboard_history'),
0025         'resourcesUrl': reverse('monitor_app:prod_dashboard_resources'),
0026         'efficiencyUrl': reverse('monitor_app:compute_efficiency_data') + '?summary=1',
0027         'productiveCoresUrl': reverse('monitor_app:compute_efficiency_data') + '?daily_cores=1',
0028         'efficiencyHistoryUrl': reverse('monitor_app:compute_efficiency'),
0029         'taskUrl': reverse('monitor_app:panda_task_detail', args=[0]),
0030         'breakoutUrl': reverse('monitor_app:prod_dashboard'),
0031         'weeklyUrl': static('monitor_app/prod_dashboard/weekly-cores.json'),
0032         # Google's 100 sits above its five-pod cap of 70 cores; Perlmutter's
0033         # 1,000 above its five-node production of 640 work lanes (128 a node).
0034         'pillarScales': {'OSG': 2500, 'GREX': 2500, 'Google': 100, 'Perlmutter': 1000},
0035         'siteTrendMinimums': {'google': 15},
0036         'siteNodeCaps': {'Google': 5},
0037         'sitePanels': {'osg': 'OSG', 'grex': 'GREX', 'nersc': 'Perlmutter',
0038                        'google': 'Google', 'compute-canada': 'Compute Canada', 'jlab': 'JLab'},
0039     }
0040     return render_to_string('monitor_app/prod_dashboard.html', {
0041         'dashboard_record': record,
0042         'dashboard_config': config,
0043         'dashboard_version': '20261028-node-multipliers',
0044     }, request=request)
0045 
0046 
0047 def prod_dashboard(request):
0048     """The full-page dashboard, without application navigation headers."""
0049     from django.http import HttpResponse
0050 
0051     return HttpResponse(dashboard_document(request))
0052 
0053 
0054 def task_resources_json(request):
0055     from django.http import JsonResponse
0056     from monitor_app.task_resources import product
0057 
0058     try:
0059         result = product(refresh=request.GET.get('refresh') == '1')
0060         return JsonResponse({'record': result['value'],
0061                              'built_at': result['built_at'],
0062                              'refreshing': result['refreshing']})
0063     except Exception:
0064         logger.exception('Task resource history unavailable')
0065         return JsonResponse({'error': 'Task resource history is temporarily unavailable.'}, status=503)
0066 
0067 
0068 def dashboard_home(request):
0069     """The dashboard tab within the production home."""
0070     return render(request, 'monitor_app/prod_hub_dashboard.html', {
0071         'active_tab': 'dash',
0072         'nav_mode': 'production',
0073         'dashboard_html': dashboard_document(request),
0074     })