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

Fix some exceptions of cms.Modifier #16570

Merged
merged 2 commits into from Nov 15, 2016

Conversation

makortel
Copy link
Contributor

While working on something else, I found out that when having a typo in the cms.Modifier parameters (i.e. trying to modify a non-existing parameter without an explicit type), the cms.Modifier machinery does not raise a helpful exception. This PR proposes fixes for those along unit tests (that demonstrate the "mistakes").

Without this PR, the first error case gives the following traceback

  File "FWCore/ParameterSet/python/Config.py", line 1194, in toModify
    temp(obj)
  File "FWCore/ParameterSet/python/Config.py", line 1124, in __call__
    _modifyParametersFromDict(params, self.__args, self._raiseUnknownKey)
  File "FWCore/ParameterSet/python/Mixins.py", line 626, in _modifyParametersFromDict
    keyDepth+"."+key)
  File "FWCore/ParameterSet/python/Mixins.py", line 639, in _modifyParametersFromDict
    errorRaiser(key)
TypeError: _raiseUnknownKey() takes exactly 1 argument (2 given)

and the second the following

  File "FWCore/ParameterSet/python/Config.py", line 1194, in toModify
    temp(obj)
  File "FWCore/ParameterSet/python/Config.py", line 1124, in __call__
    _modifyParametersFromDict(params, self.__args, self._raiseUnknownKey)
  File "FWCore/ParameterSet/python/Mixins.py", line 634, in _modifyParametersFromDict
    params[key].setValue(value)

Tested in 8_1_0_pre16, no changes expected.

@makortel
Copy link
Contributor Author

@cmsbuild, please test

@cmsbuild
Copy link
Contributor

A new Pull Request was created by @makortel (Matti Kortelainen) for CMSSW_8_1_X.

It involves the following packages:

FWCore/ParameterSet

@cmsbuild, @smuzaffar, @Dr15Jones, @davidlange6 can you please review it and eventually sign? Thanks.
@Martin-Grunewald, @wddgit, @wmtan this is something you requested to watch as well.
@slava77, @smuzaffar you are the release manager for this.

cms-bot commands are listed here #13028

_modifyParametersFromDict(params, self.__args, self._raiseUnknownKey)
for k in self.__args.iterkeys():
if k in params:
setattr(obj,k,params[k])
else:
#the parameter must have been removed
delattr(obj,k)
@staticmethod
def _raiseUnknownKey(key):
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Other option would have been to add self parameter, but since it would go unused I chose @staticmethod.

@@ -1119,17 +1119,16 @@ def __call__(self,obj):
for k in self.__args.iterkeys():
if hasattr(obj,k):
params[k] = getattr(obj,k)
else:
params[k] = self.__args[k]
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not 100 % sure if this is a correct fix. I first started to patch Mixins._modifyParametersFromDict() to raise an exception if params[key] does not have setValue attribute. But after staring the code a bit I started to wonder why self.__args is copied to params here when Mixins._modifyParametersFromDict() does effectively same thing.

Anyway, unit tests pass and (subset of) limited matrix workflows give exactly the same config dumps.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm guessing the copy was historic.

@makortel
Copy link
Contributor Author

@cmsbuild, please test
(let's try again)

@cmsbuild
Copy link
Contributor

cmsbuild commented Nov 14, 2016

The tests are being triggered in jenkins.
https://cmssdt.cern.ch/jenkins/job/ib-any-integration/16329/console

@@ -1119,17 +1119,16 @@ def __call__(self,obj):
for k in self.__args.iterkeys():
if hasattr(obj,k):
params[k] = getattr(obj,k)
else:
params[k] = self.__args[k]
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm guessing the copy was historic.

@Dr15Jones
Copy link
Contributor

+1

@cmsbuild
Copy link
Contributor

This pull request is fully signed and it will be integrated in one of the next CMSSW_8_1_X IBs after it passes the integration tests. This pull request requires discussion in the ORP meeting before it's merged. @slava77, @davidlange6, @smuzaffar

@Dr15Jones
Copy link
Contributor

@makortel thanks for the fix

@cmsbuild
Copy link
Contributor

-1

Tested at: af4d95b

You can see the results of the tests here:
https://cmssdt.cern.ch/SDT/jenkins-artifacts/pull-request-integration/PR-16570/16329/summary.html

I found follow errors while testing this PR

Failed tests: UnitTests

  • Unit Tests:

I found errors in the following unit tests:

---> test testJetMETCorrectionsType1MET had ERRORS

@cmsbuild
Copy link
Contributor

Comparison job queued.

@cmsbuild
Copy link
Contributor

Comparison is ready
https://cmssdt.cern.ch/SDT/jenkins-artifacts/pull-request-integration/PR-16570/16329/summary.html

Alternative comparison was/were failed for workflow(s):
21224.0

@Dr15Jones
Copy link
Contributor

The unit test failure was actually from a DAS failure.

There was a problem while querying DAS with query 'file dataset=/RelValTTbar_13/CMSSW_7_4_0_pre6-PU50ns_MCRUN2_74_V0-v2/GEN-SIM-RECO | grep file.name'. Server reply was:
 {u'status': u'fail', u'mongo_query': {}, u'ctime': 0, u'timestamp': 1479137493.66, u'reason': u'request expired', u'data': []}
----- Begin Fatal Exception 14-Nov-2016 16:31:53 CET-----------------------
An exception of category 'ConfigFileReadError' occurred while
   [0] Processing the python configuration file named /build/cmsbld/jenkins-workarea/workspace/ib-any-integration/CMSSW_8_1_X_2016-11-13-2300/src/JetMETCorrections/Type1MET/test/corrMET_caloMet_cfg.py
Exception Message:
python encountered the error: <type 'exceptions.SystemExit'>
1
----- End Fatal Exception -------------------------------------------------

@davidlange6 davidlange6 merged commit 14cb428 into cms-sw:CMSSW_8_1_X Nov 15, 2016
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants