Back to home page

EIC code displayed by LXR

 
 

    


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

0001 """Short names for concise settings: the computing centre floor and its
0002 board lines, compact tables, titles. One filter, so a name reads the same
0003 everywhere it is shortened (Torre Wenaus, 2026-10-22); templates use it as
0004 ``{{ name|short }}`` (swf_fmt). A name with no short form passes through
0005 unchanged, and the full name stays in the record and on detail pages.
0006 """
0007 import re
0008 
0009 # A name whose short form no rule below gives.
0010 SHORT_NAMES = {
0011     'NERSC': 'Perlmutter',
0012     'Compute Canada': 'Canada',
0013     'BNL_OSG_PanDA_1': 'OSG',
0014     'UM_GREX_PanDA_1': 'GREX',
0015     'IRISHEP-SSL-UCHICAGO': 'IRISHEP',
0016     'UNL-PATH': 'UNL',
0017     'UWM-Mortimer': 'UWM',
0018     'Rhodes-HPC': 'Rhodes',
0019     'OSG_US_FSU_HNPGRID': 'FSU',
0020     'UW-La Crosse CSCPE': 'La Crosse',
0021     'UA Little Rock ITS': 'UALR',
0022     'Center for Advanced Research Computi': 'CARC',
0023     'Center for Advanced Research Computing': 'CARC',
0024     'WISC-PATH': 'WISC',
0025     'FANDM-ITS': 'F&M',
0026     'Colgate ITS': 'Colgate',
0027     'Syracuse-OSPool': 'Syracuse',
0028     'SYRA-PATH': 'SYRA',
0029     'OU-Sooner': 'OU',
0030     'FIU-IRCC': 'FIU',
0031     'ND_CAMLGPU': 'ND-CAML',
0032     # the OSG pools our submit host negotiates in, by central manager
0033     'cm-1.ospool.osg-htc.org': 'OSPool',
0034     'cm-2.ospool.osg-htc.org': 'OSPool',
0035     'jlab-cm.osg.chtc.io': 'JLab pool',
0036     'scicollector901.jlab.org': 'JLab pool',
0037 }
0038 
0039 # Organisation prefixes a site name carries before the cluster's own name:
0040 # ComputeCanada-Fir reads Fir.
0041 PREFIXES = ('ComputeCanada-',)
0042 
0043 
0044 def short_name(name):
0045     """The concise form of a site, queue or resource name."""
0046     if not name:
0047         return name
0048     name = str(name)
0049     if name in SHORT_NAMES:
0050         return SHORT_NAMES[name]
0051     for prefix in PREFIXES:
0052         if name.startswith(prefix) and len(name) > len(prefix):
0053             return name[len(prefix):]
0054     return name
0055 
0056 
0057 def short_text(value):
0058     """Use display site names in prose, preserving internal identifiers."""
0059     return re.sub(r'(?<!\w)(NERSC|Compute Canada)(?!\w)',
0060                   lambda match: short_name(match.group()), str(value or ''))