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

remove access to bare ROOT objects in HLTFiltersDQMonitor #40426

Merged
merged 4 commits into from Jan 7, 2023

Conversation

missirol
Copy link
Contributor

@missirol missirol commented Jan 4, 2023

PR description:

This PR updates the plugin HLTFiltersDQMonitor in order not to access bare ROOT objects via the methods of DQM's MonitorElement. It potentially solves #40419.

A unit test is also added, along with other small technical updates to HLTFiltersDQMonitor.

The PR contains the following changes, in order.

Merely technical. No changes expected in the outputs of PR tests, except for the partial renaming of one MonitorElement in HLTFiltersDQMonitor here:

-  std::replace(hltMenuName.begin(), hltMenuName.end(), '.', '_');
+  std::replace(hltMenuName.begin(), hltMenuName.end(), '.', 'p');

PR validation:

The new unit test often reproduced the error in #40419 when using 4 or more threads(==streams) without the cpp changes in this PR. Once the latter are included, the same test consistently passed.

If this PR is a backport, please specify the original PR and why you need to backport that PR. If this PR will be backported, please specify to which release cycle the backport is meant for:

TBD. This is a bugfix, and backports might be needed.

@cmsbuild
Copy link
Contributor

cmsbuild commented Jan 4, 2023

+code-checks

Logs: https://cmssdt.cern.ch/SDT/code-checks/cms-sw-PR-40426/33558

  • This PR adds an extra 36KB to repository

@cmsbuild
Copy link
Contributor

cmsbuild commented Jan 4, 2023

A new Pull Request was created by @missirol (Marino Missiroli) for master.

It involves the following packages:

  • DQMOffline/Trigger (dqm)

@emanueleusai, @ahmad3213, @cmsbuild, @syuvivida, @pmandrik, @micsucmed, @rvenditti can you please review it and eventually sign? Thanks.
@mtosi, @Fedespring, @HuguesBrun, @jhgoh, @trocino, @cericeci, @rociovilar this is something you requested to watch as well.
@perrotta, @dpiparo, @rappoccio you are the release manager for this.

cms-bot commands are listed here

@missirol
Copy link
Contributor Author

missirol commented Jan 4, 2023

type bugfix

Copy link
Contributor

@makortel makortel left a comment

Choose a reason for hiding this comment

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

Thanks @missirol! I had one comment for a (repeated) pattern that caught my eye already in the earlier code.

Comment on lines 319 to 323
if (binIndexMap_.find(iPathName) == binIndexMap_.end()) {
throw cms::Exception("HLTFiltersDQMonitorInvalidBinLabel")
<< "invalid key for bin-index map (name of Path bin in MonitorElement of HLT Menu): \"" << iPathName << "\"";
}
auto const ibin = binIndexMap_[iPathName];
Copy link
Contributor

Choose a reason for hiding this comment

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

The following would be more efficient

Suggested change
if (binIndexMap_.find(iPathName) == binIndexMap_.end()) {
throw cms::Exception("HLTFiltersDQMonitorInvalidBinLabel")
<< "invalid key for bin-index map (name of Path bin in MonitorElement of HLT Menu): \"" << iPathName << "\"";
}
auto const ibin = binIndexMap_[iPathName];
auto const foundBin = binIndexMap_.find(iPathName);
if (foundBin == binIndexMap_.end()) {
throw cms::Exception("HLTFiltersDQMonitorInvalidBinLabel")
<< "invalid key for bin-index map (name of Path bin in MonitorElement of HLT Menu): \"" << iPathName << "\"";
}
auto const ibin = *foundBin;

by avoiding a second search (even if it has a constant cost on average).

}
auto const& dsetPathNames(hltConfigProvider_.datasetContent(idset));
MonitorElement* const meDatasetProf = meDatasetMap_[meDatasetName];
Copy link
Contributor

Choose a reason for hiding this comment

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

Also here storing the returned iterator from meDatasetMap_.find(meDatasetName) in a variable and de-referencing it would be more efficient.

throw cms::Exception("HLTFiltersDQMonitorInvalidBinLabel")
<< "invalid key for bin-index map (name of Path bin in MonitorElement of Dataset): \"" << ibinKey << "\"";
}
auto const ibin = binIndexMap_[ibinKey];
Copy link
Contributor

Choose a reason for hiding this comment

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

Also here storing the returned iterator from binIndexMap_.find(ibinKey) in a variable and de-referencing it would be more efficient.

continue;
}

MonitorElement* const mePathProf = mePathMap_[mePathName];
Copy link
Contributor

Choose a reason for hiding this comment

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

Also here storing the returned iterator from mePathMap_.find(mePathName) in a variable and de-referencing it would be more efficient.

<< "invalid key for bin-index map (name of Module bin in MonitorElement of Path): \"" << ibinKey
<< "\"";
}
auto const ibin = binIndexMap_[ibinKey];
Copy link
Contributor

Choose a reason for hiding this comment

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

Also here storing the returned iterator from binIndexMap_.find(ibinKey) in a variable and de-referencing it would be more efficient.

@missirol
Copy link
Contributor Author

missirol commented Jan 4, 2023

I had one comment for a (repeated) pattern that caught my eye already in the earlier code.

Thanks for the review! Added in ed5f69b.

@cmsbuild
Copy link
Contributor

cmsbuild commented Jan 4, 2023

+code-checks

Logs: https://cmssdt.cern.ch/SDT/code-checks/cms-sw-PR-40426/33560

  • This PR adds an extra 36KB to repository

@cmsbuild
Copy link
Contributor

cmsbuild commented Jan 4, 2023

Pull request #40426 was updated. @emanueleusai, @ahmad3213, @cmsbuild, @syuvivida, @pmandrik, @micsucmed, @rvenditti can you please check and sign again.

Comment on lines +3 to +12
## CLI parser
import argparse
import sys

parser = argparse.ArgumentParser(
prog = 'cmsRun '+sys.argv[0]+' --',
description = 'Configuration file to test of the HLTFiltersDQMonitor plugin.',
formatter_class = argparse.ArgumentDefaultsHelpFormatter
)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Just for completeness: this argparse configuration was ~copied from

import argparse
import sys
parser = argparse.ArgumentParser(prog=sys.argv[0], description='Test SwitchProducer in Task.')
parser.add_argument("--disableTest2", help="Disable test2 SwitchProducer case", action="store_true")
parser.add_argument("--input", help="Read input file from a previous step of this same configuration", action="store_true")
parser.add_argument("--conditionalTask", help="Use ConditionalTask instead of Task", action="store_true")
argv = sys.argv[:]
if '--' in argv:
argv.remove("--")
args, unknown = parser.parse_known_args(argv)

I was wondering if there are cases where VarParsing has advantages (or, is recommended) wrt argparse.

The only hiccup I encountered with this argparse was with

cmsRun DQMOffline/Trigger/test/testHLTFiltersDQMonitor_cfg.py -- -h

which I naively expected to work, but leads to an error [1] (didn't figure out the solution).

[1]

----- Begin Fatal Exception 04-Jan-2023 19:08:48 CET-----------------------
An exception of category 'ConfigFileReadError' occurred while
   [0] Processing the python configuration file named DQMOffline/Trigger/test/testHLTFiltersDQMonitor_cfg.py
Exception Message:
 unknown python problem occurred.
SystemExit: 0

At:
  /cvmfs/cms-ib.cern.ch/sw/x86_64/week0/el8_amd64_gcc11/external/python3/3.9.14-76a14295dd5255228210eb596893b98c/lib/python3.9/argparse.py(2569): exit
  /cvmfs/cms-ib.cern.ch/sw/x86_64/week0/el8_amd64_gcc11/external/python3/3.9.14-76a14295dd5255228210eb596893b98c/lib/python3.9/argparse.py(1100): __call__
  /cvmfs/cms-ib.cern.ch/sw/x86_64/week0/el8_amd64_gcc11/external/python3/3.9.14-76a14295dd5255228210eb596893b98c/lib/python3.9/argparse.py(1935): take_action
  /cvmfs/cms-ib.cern.ch/sw/x86_64/week0/el8_amd64_gcc11/external/python3/3.9.14-76a14295dd5255228210eb596893b98c/lib/python3.9/argparse.py(2007): consume_optional
  /cvmfs/cms-ib.cern.ch/sw/x86_64/week0/el8_amd64_gcc11/external/python3/3.9.14-76a14295dd5255228210eb596893b98c/lib/python3.9/argparse.py(2067): _parse_known_args
  /cvmfs/cms-ib.cern.ch/sw/x86_64/week0/el8_amd64_gcc11/external/python3/3.9.14-76a14295dd5255228210eb596893b98c/lib/python3.9/argparse.py(1861): parse_known_args
  DQMOffline/Trigger/test/testHLTFiltersDQMonitor_cfg.py(37): <module>

----- End Fatal Exception -------------------------------------------------

Copy link
Contributor

Choose a reason for hiding this comment

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

Just for completeness: this argparse configuration was ~copied from

For future reference the use of argparse is also described in
https://twiki.cern.ch/twiki/bin/view/CMSPublic/SWGuideAboutPythonConfigFile#argparse

The only hiccup I encountered with this argparse was with

cmsRun DQMOffline/Trigger/test/testHLTFiltersDQMonitor_cfg.py -- -h

which I naively expected to work, but leads to an error [1]

Hah, interesting. It seems that sys.exit(0) gets communicated as a thrown exception by PyBind11 in the C++ side, which framework then reports as shown (the printout from -h is there, although in a slightly confusing way). It is not immediately clear to me if we should do something about it, so a specific issue might be worth it.

As for VarParsing vs argparse, core does not have a specific recommendation. First has longer history within CMSSW (and not really developed further), and the latter comes from python's standard library.

@missirol
Copy link
Contributor Author

missirol commented Jan 4, 2023

please test

@cmsbuild
Copy link
Contributor

cmsbuild commented Jan 5, 2023

+1

Summary: https://cmssdt.cern.ch/SDT/jenkins-artifacts/pull-request-integration/PR-45ee1a/29799/summary.html
COMMIT: ed5f69b
CMSSW: CMSSW_13_0_X_2023-01-04-1100/el8_amd64_gcc11
User test area: For local testing, you can use /cvmfs/cms-ci.cern.ch/week0/cms-sw/cmssw/40426/29799/install.sh to create a dev area with all the needed externals and cmssw changes.

Comparison Summary

Summary:

  • No significant changes to the logs found
  • Reco comparison results: 2 differences found in the comparisons
  • DQMHistoTests: Total files compared: 49
  • DQMHistoTests: Total histograms compared: 3555746
  • DQMHistoTests: Total failures: 0
  • DQMHistoTests: Total nulls: 0
  • DQMHistoTests: Total successes: 3555724
  • DQMHistoTests: Total skipped: 22
  • DQMHistoTests: Total Missing objects: 0
  • DQMHistoSizes: Histogram memory added: 0.0 KiB( 48 files compared)
  • Checked 211 log files, 162 edm output root files, 49 DQM output files
  • TriggerResults: no differences found

@missirol
Copy link
Contributor Author

missirol commented Jan 5, 2023

The only real differences in PR-test outputs are in wfs 4.22 and 1000.0:
https://tinyurl.com/2hbtcqk3
https://tinyurl.com/2ged6ygk

This is just due to the renaming of one histogram, which is expected because of this change
https://github.com/cms-sw/cmssw/pull/40426/files#diff-d18b6560ad84d60fede0b40acdb7a9022333a5ec673dd87452d74d78b707fc66L141-R151
(Comparing old and new histograms, one can see that the bin contents are the same.)

Overall, things look okay (I don't have other updates planned for this PR).

@cms-sw/dqm-l2, please prioritise the review of this PR, since it is a bugfix.

@emanueleusai
Copy link
Member

+1

  • technical PR

@cmsbuild
Copy link
Contributor

cmsbuild commented Jan 7, 2023

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. @perrotta, @dpiparo, @rappoccio (and backports should be raised in the release meeting by the corresponding L2)

@perrotta
Copy link
Contributor

perrotta commented Jan 7, 2023

+1

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

5 participants