-
Notifications
You must be signed in to change notification settings - Fork 4.3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
VarParsing default doesn't work for lists? #45961
Comments
cms-bot internal usage |
A new Issue was created by @gpetruc. @Dr15Jones, @antoniovilela, @makortel, @mandrenguyen, @rappoccio, @sextonkennedy, @smuzaffar can you please review it and eventually sign/assign? Thanks. cms-bot commands are listed here |
assign core |
New categories assigned: core @Dr15Jones,@makortel,@smuzaffar you have been requested to review this Pull request/Issue and eventually sign? Thanks |
Code https://github.com/cms-sw/cmssw/blob/master/FWCore/ParameterSet/python/VarParsing.py#L416 Reproducer code import FWCore.ParameterSet.Config as cms
import FWCore.ParameterSet.VarParsing as VarParsing
options = VarParsing.VarParsing ('analysis')
options.register ('buNumStreams',
[1], # default value
VarParsing.VarParsing.multiplicity.list,
VarParsing.VarParsing.varType.int, # string, int, or float
"Number of input streams (i.e. files) used simultaneously for each BU directory")
options.parseArguments()
print(f"numStreams set to '{options.buNumStreams}', len {len(options.buNumStreams)}, type of first element is {type(options.buNumStreams[0])}")
process = cms.Process("NULL") if run with |
Although this code is in FWCore.ParameterSet, it really isn't maintained anymore. Instead, we suggest people migrate the the python standard That being said, we do accept changes done to VarParsing committed by others. |
This looks like the same issue reported already in #44630, and for which there is a PR open #45640 to try to improve the situation (see especially #45640 (comment)).
I believe the knowledge on "intended behavior" of |
Hi,
The behaviour of VarParsing for lists doesn't seem right to me,
The first line checks whether the provided default is a non-empty list, but then the second appends the whole list as entry in the default. As a result, what one gets as default value is not what is passed as
default
toregister
, but rather a list of lists, with one single entry that is equal of lists.What would make more sense to me if the line were to be
self._lists[name] += default
.As is I can't call
register
with as default a non-empty list (except in the case where it's a list of strings containing just one entry, as in that case I can pass the entry value as default, andlen()
will act on the string)I can make a PR, but git blame records the code as being 11 years old, so maybe this is the intended behaviour and I'm not understanding the logic for it?
The text was updated successfully, but these errors were encountered: