{"action":"created","issue":{"url":"https://api.github.com/repos/cms-sw/cmssw/issues/13381","repository_url":"https://api.github.com/repos/cms-sw/cmssw","labels_url":"https://api.github.com/repos/cms-sw/cmssw/issues/13381/labels{/name}","comments_url":"https://api.github.com/repos/cms-sw/cmssw/issues/13381/comments","events_url":"https://api.github.com/repos/cms-sw/cmssw/issues/13381/events","html_url":"https://github.com/cms-sw/cmssw/pull/13381","id":134534784,"number":13381,"title":"Add a simplified way for eras to modify the whole process","user":{"login":"cmsbuild","id":4170616,"avatar_url":"https://avatars.githubusercontent.com/u/4170616?v=3","gravatar_id":"","url":"https://api.github.com/users/cmsbuild","html_url":"https://github.com/cmsbuild","followers_url":"https://api.github.com/users/cmsbuild/followers","following_url":"https://api.github.com/users/cmsbuild/following{/other_user}","gists_url":"https://api.github.com/users/cmsbuild/gists{/gist_id}","starred_url":"https://api.github.com/users/cmsbuild/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/cmsbuild/subscriptions","organizations_url":"https://api.github.com/users/cmsbuild/orgs","repos_url":"https://api.github.com/users/cmsbuild/repos","events_url":"https://api.github.com/users/cmsbuild/events{/privacy}","received_events_url":"https://api.github.com/users/cmsbuild/received_events","type":"User","site_admin":false},"labels":[{"url":"https://api.github.com/repos/cms-sw/cmssw/labels/comparison-pending","name":"comparison-pending","color":"fbca04"},{"url":"https://api.github.com/repos/cms-sw/cmssw/labels/core-pending","name":"core-pending","color":"fbca04"},{"url":"https://api.github.com/repos/cms-sw/cmssw/labels/orp-pending","name":"orp-pending","color":"fbca04"},{"url":"https://api.github.com/repos/cms-sw/cmssw/labels/pending-signatures","name":"pending-signatures","color":"eb6420"},{"url":"https://api.github.com/repos/cms-sw/cmssw/labels/tests-pending","name":"tests-pending","color":"fbca04"}],"state":"open","locked":false,"assignee":null,"milestone":{"url":"https://api.github.com/repos/cms-sw/cmssw/milestones/59","html_url":"https://github.com/cms-sw/cmssw/milestones/Next%20CMSSW_8_1_X","labels_url":"https://api.github.com/repos/cms-sw/cmssw/milestones/59/labels","id":1590252,"number":59,"title":"Next CMSSW_8_1_X","description":null,"creator":{"login":"smuzaffar","id":4115138,"avatar_url":"https://avatars.githubusercontent.com/u/4115138?v=3","gravatar_id":"","url":"https://api.github.com/users/smuzaffar","html_url":"https://github.com/smuzaffar","followers_url":"https://api.github.com/users/smuzaffar/followers","following_url":"https://api.github.com/users/smuzaffar/following{/other_user}","gists_url":"https://api.github.com/users/smuzaffar/gists{/gist_id}","starred_url":"https://api.github.com/users/smuzaffar/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/smuzaffar/subscriptions","organizations_url":"https://api.github.com/users/smuzaffar/orgs","repos_url":"https://api.github.com/users/smuzaffar/repos","events_url":"https://api.github.com/users/smuzaffar/events{/privacy}","received_events_url":"https://api.github.com/users/smuzaffar/received_events","type":"User","site_admin":false},"open_issues":72,"closed_issues":606,"state":"open","created_at":"2016-02-18T09:12:12Z","updated_at":"2016-05-16T09:22:31Z","due_on":null,"closed_at":null},"comments":39,"created_at":"2016-02-18T10:08:51Z","updated_at":"2016-05-16T13:14:10Z","closed_at":null,"pull_request":{"url":"https://api.github.com/repos/cms-sw/cmssw/pulls/13381","html_url":"https://github.com/cms-sw/cmssw/pull/13381","diff_url":"https://github.com/cms-sw/cmssw/pull/13381.diff","patch_url":"https://github.com/cms-sw/cmssw/pull/13381.patch"},"body":"**Current code**\r\nCurrently the only way for an era to make a modification to the whole process object is to create a ProcessModifier and assign it a unique name, e.g.:\r\n```python\r\ndef _modificationFunction( theProcess ) :\r\n    theProcess.someThing = blah\r\nsomeUniqueName_ = eras.run2_common.makeProcessModifier( _modificationFunction )\r\n```\r\nWhen the process object scans the imported objects at the end of the `load(...)` it sees that `someUniqueName_` is an instance of ProcessModifier and applies the change to itself.\r\n\r\nThis has the disadvantage of requiring a unique name, and also that it can be easily broken depending on how the file with the era change is imported.  For example, if the file above is imported with\r\n```python\r\nfrom SomePackage.SubPackage.file import somePSet\r\n```\r\nThen only `somePSet` is imported and not the ProcessModifier object, hence the era changes are never applied.\r\n\r\n**Proposal**\r\nThis pull request adds the method `toModifyProcess` to the era which stores the ProcessModifier object inside the era itself.  When the process object has finished the `load(...)` it scans all its active eras and applies any stored ProcessModifiers, then clears the list ready for the next `load(...)`.  This bypasses the import problem above and also (I think) looks much cleaner.  The new way of modifying the process object would be:\r\n```python\r\ndef _modificationFunction( theProcess ) :\r\n    theProcess.someThing = blah\r\neras.run2_common.toModifyProcess( _modificationFunction )\r\n```\r\nThe old way of modifying the process is still available.  If this PR is accepted then we could mark it as deprecated or remove it later.\r\n\r\n@Dr15Jones let me know if you can see any disadvantages or have any comments.  Note that as well as adding methods I've made use of the `__processModifiers` attribute which doesn't appear to be used elsewhere.  If this is a problem I can easily modify it to use a different attribute.\nAutomatically ported from CMSSW_8_0_X #12256 (original by @mark-grimes)."},"comment":{"url":"https://api.github.com/repos/cms-sw/cmssw/issues/comments/219421600","html_url":"https://github.com/cms-sw/cmssw/pull/13381#issuecomment-219421600","issue_url":"https://api.github.com/repos/cms-sw/cmssw/issues/13381","id":219421600,"user":{"login":"Dr15Jones","id":3757616,"avatar_url":"https://avatars.githubusercontent.com/u/3757616?v=3","gravatar_id":"","url":"https://api.github.com/users/Dr15Jones","html_url":"https://github.com/Dr15Jones","followers_url":"https://api.github.com/users/Dr15Jones/followers","following_url":"https://api.github.com/users/Dr15Jones/following{/other_user}","gists_url":"https://api.github.com/users/Dr15Jones/gists{/gist_id}","starred_url":"https://api.github.com/users/Dr15Jones/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Dr15Jones/subscriptions","organizations_url":"https://api.github.com/users/Dr15Jones/orgs","repos_url":"https://api.github.com/users/Dr15Jones/repos","events_url":"https://api.github.com/users/Dr15Jones/events{/privacy}","received_events_url":"https://api.github.com/users/Dr15Jones/received_events","type":"User","site_admin":false},"created_at":"2016-05-16T13:14:10Z","updated_at":"2016-05-16T13:14:10Z","body":"-1\r\nAn alternate way of handling this was done"}}