Impact of the new feature
WMCore in general
Is your feature request related to a problem? Please describe.
While running one StdSpecs_t unittest with the now python 3.12 wmcore-dev image, there were a bunch of SyntaxWarning messages in stdout [1].
According to https://docs.python.org/dev/whatsnew/3.12.html#other-language-changes, we need to use raw strings for regular expressions. In addition, a SyntaxError is supposed to be raised in future Python versions.
Describe the solution you'd like
Convert regular expressions with the back-slack sign \ to raw strings, hence resolving the invalid escape and resolving the warning.
Describe alternatives you've considered
Not do anything and trust that our runtime code won't be executed in a python version newer than 3.12
Additional context
[1]
/workspaces/WMCore/src/python/WMCore/Lexicon.py:27: SyntaxWarning: invalid escape sequence '\-'
PRIMARY_DS = {'re': '^[a-zA-Z][a-zA-Z0-9\-_]*$', 'maxLength': 99}
/workspaces/WMCore/src/python/WMCore/Lexicon.py:28: SyntaxWarning: invalid escape sequence '\.'
PROCESSED_DS = {'re': '[a-zA-Z0-9\.\-_]+', 'maxLength': 199}
/workspaces/WMCore/src/python/WMCore/Lexicon.py:29: SyntaxWarning: invalid escape sequence '\-'
TIER = {'re': '[A-Z0-9\-_]+', 'maxLength': 99}
/workspaces/WMCore/src/python/WMCore/Lexicon.py:30: SyntaxWarning: invalid escape sequence '\.'
BLOCK_STR = {'re': '#[a-zA-Z0-9\.\-_]+', 'maxLength': 100}
/workspaces/WMCore/src/python/WMCore/Lexicon.py:33: SyntaxWarning: invalid escape sequence '\-'
'era': '([a-zA-Z0-9\-_]+)',
/workspaces/WMCore/src/python/WMCore/Lexicon.py:34: SyntaxWarning: invalid escape sequence '\-'
'primDS': '([a-zA-Z][a-zA-Z0-9\-_]*)',
/workspaces/WMCore/src/python/WMCore/Lexicon.py:36: SyntaxWarning: invalid escape sequence '\-'
'version': '([a-zA-Z0-9\-_]+)',
/workspaces/WMCore/src/python/WMCore/Lexicon.py:37: SyntaxWarning: invalid escape sequence '\-'
'procDS': '([a-zA-Z0-9\-_]+)', # Processed dataset = Processing string + Processing version
/workspaces/WMCore/src/python/WMCore/Lexicon.py:39: SyntaxWarning: invalid escape sequence '\-'
'root': '([a-zA-Z0-9\-_]+).root',
/workspaces/WMCore/src/python/WMCore/Lexicon.py:40: SyntaxWarning: invalid escape sequence '\.'
'hnName': '([a-zA-Z0-9\.]+)',
/workspaces/WMCore/src/python/WMCore/Lexicon.py:41: SyntaxWarning: invalid escape sequence '\-'
'subdir': '([a-zA-Z0-9\-_]+)',
/workspaces/WMCore/src/python/WMCore/Lexicon.py:42: SyntaxWarning: invalid escape sequence '\-'
'file': '([a-zA-Z0-9\-\._]+)',
/workspaces/WMCore/src/python/WMCore/Lexicon.py:43: SyntaxWarning: invalid escape sequence '\-'
'workflow': '([a-zA-Z0-9\-_]+)',
/workspaces/WMCore/src/python/WMCore/Lexicon.py:44: SyntaxWarning: invalid escape sequence '\-'
'physics_group': '([a-zA-Z0-9\-_]+)'
/workspaces/WMCore/src/python/WMCore/Lexicon.py:48: SyntaxWarning: invalid escape sequence '\.'
'groupuser': '([a-zA-Z0-9\.\-_])+',
/workspaces/WMCore/src/python/WMCore/Lexicon.py:49: SyntaxWarning: invalid escape sequence '\-'
'publishdataname': '([a-zA-Z0-9\-_])+',
/workspaces/WMCore/src/python/WMCore/Lexicon.py:56: SyntaxWarning: invalid escape sequence '\%'
WMEXCEPTION_FILTER = "(?P<WMException>\%s(?!<@).*?\%s)" % (WMEXCEPTION_START_STR, WMEXCEPTION_END_STR)
/workspaces/WMCore/src/python/WMCore/Lexicon.py:151: SyntaxWarning: invalid escape sequence '\d'
return check("^\d+(-\d+)?(,\d+(-\d+)?)*$", candidate)
/workspaces/WMCore/src/python/WMCore/Lexicon.py:328: SyntaxWarning: invalid escape sequence '\-'
TASK_STEP_NAME = {'re': '^[a-zA-Z][a-zA-Z0-9\-_]*$', 'maxLength': 50}
/workspaces/WMCore/src/python/WMCore/Lexicon.py:357: SyntaxWarning: invalid escape sequence '\-'
regexp1 = '/([a-z]+)/([a-z0-9]+)/(%(era)s)/([a-zA-Z0-9\-_]+)/([A-Z0-9\-_]+)/([a-zA-Z0-9\-_]+)((/[0-9]+){3}){0,1}/([0-9]+)/([a-zA-Z0-9\-_]+).root' % lfnParts
/workspaces/WMCore/src/python/WMCore/Lexicon.py:358: SyntaxWarning: invalid escape sequence '\-'
regexp2 = '/([a-z]+)/([a-z0-9]+)/([a-z0-9]+)/([a-zA-Z0-9\-_]+)/([a-zA-Z0-9\-_]+)/([A-Z0-9\-_]+)/([a-zA-Z0-9\-_]+)((/[0-9]+){3}){0,1}/([0-9]+)/([a-zA-Z0-9\-_]+).root'
/workspaces/WMCore/src/python/WMCore/Lexicon.py:365: SyntaxWarning: invalid escape sequence '\-'
storeMcLFN = '/store/mc/(%(era)s)/([a-zA-Z0-9\-_]+)/([a-zA-Z0-9\-_]+)/([a-zA-Z0-9\-_]+)(/([a-zA-Z0-9\-_]+))*/([a-zA-Z0-9\-_]+).root' % lfnParts
/workspaces/WMCore/src/python/WMCore/Lexicon.py:372: SyntaxWarning: invalid escape sequence '\-'
lheLFN1 = '/store/lhe/([0-9]+)/([a-zA-Z0-9\-_]+).lhe(.xz){0,1}'
/workspaces/WMCore/src/python/WMCore/Lexicon.py:374: SyntaxWarning: invalid escape sequence '\-'
lheLFN2 = '/store/lhe/%(era)s/%(primDS)s/([0-9]+)/([a-zA-Z0-9\-_]+).lhe(.xz){0,1}' % lfnParts
/workspaces/WMCore/src/python/WMCore/Lexicon.py:440: SyntaxWarning: invalid escape sequence '\-'
regexp1 = '/([a-z]+)/([a-z0-9]+)/([a-zA-Z0-9\-_]+)/([a-zA-Z0-9\-_]+)/([A-Z0-9\-_]+)/([a-zA-Z0-9\-_]+)'
/workspaces/WMCore/src/python/WMCore/Lexicon.py:441: SyntaxWarning: invalid escape sequence '\-'
regexp2 = '/([a-z]+)/([a-z0-9]+)/([a-z0-9]+)/([a-zA-Z0-9\-_]+)/([a-zA-Z0-9\-_]+)/([A-Z0-9\-_]+)/([a-zA-Z0-9\-_]+)((/[0-9]+){3}){0,1}'
/workspaces/WMCore/src/python/WMCore/Lexicon.py:492: SyntaxWarning: invalid escape sequence '\d'
return check('CMSSW(_\d+){3}(_[a-zA-Z0-9_]+)?$', candidate)
/workspaces/WMCore/src/python/WMCore/Lexicon.py:496: SyntaxWarning: invalid escape sequence '\.'
return check('https?://(([a-zA-Z0-9:@\.\-_]){0,100})([a-z0-9\.]+)(:\d+|/couchdb)', candidate)
/workspaces/WMCore/src/python/WMCore/Lexicon.py:769: SyntaxWarning: invalid escape sequence '\d'
in the list and matching this regex: `r"^\d+.\d$"`. E.g.: ["7.5", "8.0"]
Impact of the new feature
WMCore in general
Is your feature request related to a problem? Please describe.
While running one StdSpecs_t unittest with the now python 3.12 wmcore-dev image, there were a bunch of
SyntaxWarningmessages in stdout [1].According to https://docs.python.org/dev/whatsnew/3.12.html#other-language-changes, we need to use raw strings for regular expressions. In addition, a
SyntaxErroris supposed to be raised in future Python versions.Describe the solution you'd like
Convert regular expressions with the back-slack sign
\to raw strings, hence resolving the invalid escape and resolving the warning.Describe alternatives you've considered
Not do anything and trust that our runtime code won't be executed in a python version newer than 3.12
Additional context
[1]