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

cms.allowed now accepts a dict when assigning value #44002

Merged
merged 1 commit into from
Feb 21, 2024

Conversation

Dr15Jones
Copy link
Contributor

PR description:

Extended code to also allow PSetTemplate in a cms.allowed statement.

PR validation:

Python unit test passes.

@cmsbuild
Copy link
Contributor

cmsbuild commented Feb 16, 2024

cms-bot internal usage

@cmsbuild
Copy link
Contributor

+code-checks

Logs: https://cmssdt.cern.ch/SDT/code-checks/cms-sw-PR-44002/38922

  • This PR adds an extra 36KB to repository

@cmsbuild
Copy link
Contributor

A new Pull Request was created by @Dr15Jones for master.

It involves the following packages:

  • FWCore/ParameterSet (core)

@cmsbuild, @smuzaffar, @makortel, @Dr15Jones can you please review it and eventually sign? Thanks.
@wddgit, @makortel, @missirol this is something you requested to watch as well.
@sextonkennedy, @rappoccio, @antoniovilela you are the release manager for this.

cms-bot commands are listed here

@Dr15Jones
Copy link
Contributor Author

please test

@@ -109,7 +109,7 @@ def dumpPython(self, options=PrintOptions()):
v+=".untracked"
if hasattr(self.__type, "__name__"):
return v+'.'+self.__type.__name__
return v+'.'+self.__type.dumpPython(options)
return v+'.'+self.__type.dumpPython()
Copy link
Contributor

Choose a reason for hiding this comment

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

Why not passing options anymore? Or was this causing the extra indentation that is now removed (as visible in the tests below)?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

It removes the extra indention.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

After seeing the additional failures of unit tests, I determined we do want the extra indents.

self.assertEqual(p2.aValue.b.value(),3)
self.assertEqual(p2.dumpPython(), 'cms.PSet(\n aValue = cms.PSet(\n b = cms.int32(3)\n )\n)')
p2 = PSet(aValue=optional.allowed(int32,PSetTemplate(b=optional.int32)))
self.assertRaises(TypeError, lambda: setattr(p2, "aValue", dict(i = 1)) )
Copy link
Contributor

Choose a reason for hiding this comment

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

Could you add a tests for

# Assign something not int32 nor PSet, e.g.
p2.aValue = double(3.14)

# Assign non-int32 inside the PSet, e.g.
p2.aValue = PSet(b = double(3.14))

?

Such assignments should raise an Exception, right?

Copy link
Contributor

Choose a reason for hiding this comment

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

The assertRaises() could be also

Suggested change
self.assertRaises(TypeError, lambda: setattr(p2, "aValue", dict(i = 1)) )
self.assertRaises(TypeError, setattr, p2, "aValue", dict(i = 1) )

(I don't have strong preferences though)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

p2.aValue = PSet(b=double(3.14))

does not throw. I think that is expected for a PSetTemplate since the code explicitly states the type and we assume that if you do that you know what you intended (e.g. the C++ code might allow multiple types).

p2.aValue = dict(b = 3.14)

does throw as the value doesn't match for an int type.

Copy link
Contributor

Choose a reason for hiding this comment

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

```python
p2.aValue = PSet(b=double(3.14))

does not throw. I think that is expected for a PSetTemplate since the code explicitly states the type and we assume that if you do that you know what you intended (e.g. the C++ code might allow multiple types).

Ok, makes sense. Would it be worth of adding such test anyway to demonstrate the behavior in that case?

@cmsbuild
Copy link
Contributor

+code-checks

Logs: https://cmssdt.cern.ch/SDT/code-checks/cms-sw-PR-44002/38924

  • This PR adds an extra 36KB to repository

@cmsbuild
Copy link
Contributor

Pull request #44002 was updated. @Dr15Jones, @cmsbuild, @smuzaffar, @makortel can you please check and sign again.

@Dr15Jones
Copy link
Contributor Author

please test

@cmsbuild
Copy link
Contributor

-1

Failed Tests: UnitTests
Summary: https://cmssdt.cern.ch/SDT/jenkins-artifacts/pull-request-integration/PR-fd2edc/37535/summary.html
COMMIT: 016d0c5
CMSSW: CMSSW_14_1_X_2024-02-16-1100/el8_amd64_gcc12
User test area: For local testing, you can use /cvmfs/cms-ci.cern.ch/week0/cms-sw/cmssw/44002/37535/install.sh to create a dev area with all the needed externals and cmssw changes.

The following merge commits were also included on top of IB + this PR after doing git cms-merge-topic:

You can see more details here:
https://cmssdt.cern.ch/SDT/jenkins-artifacts/pull-request-integration/PR-fd2edc/37535/git-recent-commits.json
https://cmssdt.cern.ch/SDT/jenkins-artifacts/pull-request-integration/PR-fd2edc/37535/git-merge-result

Unit Tests

I found 2 errors in the following unit tests:

---> test TestFWCoreParameterSetDriver had ERRORS
---> test testFWCoreParameterSetEdmConfigDump had ERRORS

Comparison Summary

Summary:

  • You potentially added 98 lines to the logs
  • Reco comparison results: 49 differences found in the comparisons
  • DQMHistoTests: Total files compared: 48
  • DQMHistoTests: Total histograms compared: 3248554
  • DQMHistoTests: Total failures: 6
  • DQMHistoTests: Total nulls: 0
  • DQMHistoTests: Total successes: 3248526
  • DQMHistoTests: Total skipped: 22
  • DQMHistoTests: Total Missing objects: 0
  • DQMHistoSizes: Histogram memory added: 0.0 KiB( 47 files compared)
  • Checked 200 log files, 161 edm output root files, 48 DQM output files
  • TriggerResults: no differences found

Extended code to also allow PSetTemplate in a cms.allowed statement.
@Dr15Jones
Copy link
Contributor Author

please test

@cmsbuild
Copy link
Contributor

+code-checks

Logs: https://cmssdt.cern.ch/SDT/code-checks/cms-sw-PR-44002/38937

@cmsbuild
Copy link
Contributor

Pull request #44002 was updated. @Dr15Jones, @smuzaffar, @makortel can you please check and sign again.

@cmsbuild
Copy link
Contributor

+1

Summary: https://cmssdt.cern.ch/SDT/jenkins-artifacts/pull-request-integration/PR-fd2edc/37550/summary.html
COMMIT: 04b0d48
CMSSW: CMSSW_14_1_X_2024-02-19-1100/el8_amd64_gcc12
User test area: For local testing, you can use /cvmfs/cms-ci.cern.ch/week1/cms-sw/cmssw/44002/37550/install.sh to create a dev area with all the needed externals and cmssw changes.

Comparison Summary

Summary:

@makortel
Copy link
Contributor

+core

@cmsbuild
Copy link
Contributor

This pull request is fully signed and it will be integrated in one of the next master IBs (tests are also fine). This pull request will now be reviewed by the release team before it's merged. @sextonkennedy, @rappoccio, @antoniovilela (and backports should be raised in the release meeting by the corresponding L2)

@antoniovilela
Copy link
Contributor

+1

@cmsbuild cmsbuild merged commit 306f63b into cms-sw:master Feb 21, 2024
11 checks passed
@Dr15Jones Dr15Jones deleted the allowedWithDict branch February 21, 2024 19:40
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.

4 participants