Open moritzmolch opened 1 month ago
I added the proposed fix as a pull request: https://github.com/KIT-CMS/CROWN/pull/280 Sorry for the spam, should've packed it in one thread. :sweat_smile:
Hi,
thanks for the report. This is the way the ReplaceProducer
is supposed to work (or at least sort of). There are still the RemoveProducer
and AppendProducer
functions that should be used if the outputs are different after replacement. ReplaceProducer
should only be used, if the new producer has the same outputs as the old one, to avoid confusion and unintended Replacements. I agree that the current implementation is not ideal, and you case should raise an error with a hint to use a Remove/Append combination instead.
I want to replace a ProducerGroup with ReplaceProducer for a scope (in this example the
mm
scope). However, when I do that the outputs of the new producer are not showing up in the list of all outputs (the list of branch names in the output file of the respective scope.The old producer is
with outputs
nbtag
andnbtag_boosted
and the new producer iswith the output
nbtag
. The modification in the main config file is declared withThe problem is now that I cannot find
nbtag
as branch in the output file of themm
scope, although it is an output of the new producer. I also declared it with theconfiguration.add_outputs
explicitly as output variable in themm
scope.Also, the debug output of the
cmake
compilation of the configuration shows that the outputnbtag
is removed. The variablenbtag_boosted
is not appearing here as I didn't declare it as an output of themm
scope in the main configuration, so I guess this part is okay. However, there is no line saying thatnbtag
is added back:I think the problem lies in this
else
branch of theupdate_outputs
method of theReplaceProducer
class: https://github.com/KIT-CMS/CROWN/blob/92b2187b12bb84b96326458b41203ca178c95eb4/code_generation/rules.py#L383-L400 Line 394 should be changed fromto
right? If I apply this change, I get the following output, which is what I would expect:
Finally,
nbtag
is then also a branch of the output file, so this change should fix the problem.I think that this bug only affects producers, which have different sets of outputs. In that case, the if-else query goes to the
if added_outputs == removed_outputs
branch, which does not modify the output set.