Skip to content
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

Introduce toReplaceWith()-equivalent to EDModules/Sequences/Paths themselves? #15425

Open
makortel opened this issue Aug 11, 2016 · 5 comments
Open

Comments

@makortel
Copy link
Contributor

Now that we have some experience of eras (cms.Modifier) with toReplaceWith() and toModify(), I'd like to suggest to add toReplaceWith() mechanism to the EDModules/Sequences/(End)Paths directly (probably named as e.g. replaceWith() as the action can and should be taken immediately).

This would be useful for the remaining use-cases of customize functions (e.g. test recipes or HLTrigger/Configuration/python/customizeHLTforCMSSW.py) when one needs to replace a module with another in all Sequences while keeping the label. Currently the same effect can be achieved with

foo = cms.Modifier()
foo._setChosen()
foo.toReplaceWith(process.bar, cms.EDProducer("BetterBar", ...))

# Below is what I'd like to have
#process.bar.replaceWith(cms.EDProducer("BetterBar", ...))

I'm already using this pattern in Validation/RecoTrack/python/customiseTrackingNtuple.py#L16 (for EndPath), but I'll soon (~week) have another case for EDProducers in customizeHLTforCMSSW.py.

Note that I can live with the use of Modifier as above (the need is not that frequent, and it is already much simpler than the "old way" of first removing the module from all sequences, replacing the module, and re-inserting to all sequences), but I though to raise the question in case the mechanism would have wider interest.

If replaceWith() gets accepted, I'd suggest to consider adding also modify() for EDModules on the same go (for consistency).

@Dr15Jones

@cmsbuild
Copy link
Contributor

cmsbuild commented Aug 11, 2016

A new Issue was created by @makortel Matti Kortelainen.

@davidlange6, @smuzaffar, @Dr15Jones can you please review it and eventually sign/assign? Thanks.

cms-bot commands are listed here

@Dr15Jones
Copy link
Contributor

assign core

@cmsbuild
Copy link
Contributor

New categories assigned: core

@Dr15Jones,@smuzaffar you have been requested to review this Pull request/Issue and eventually sign? Thanks

@smuzaffar
Copy link
Contributor

@Dr15Jones , @makortel , do we still need this or was it already implemented?

@makortel
Copy link
Contributor Author

It has not been implemented, in principle it could be useful. On the other hand there is

# logic from Modifier.toModify from FWCore/ParameterSet/python/Config.py
def replace_with(fromObj, toObj):
"""Replace one object with a different one of the same type.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants