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

argparse migration for cmsDriver and FWCore #43042

Merged
merged 7 commits into from
Oct 25, 2023

Conversation

kpedro88
Copy link
Contributor

PR description:

See #29338. optparse has been deprecated for many years. argparse offers many functionality improvements, including (relevant to this PR in particular):

  • better type enforcement
  • automatic handling of exclusive options
  • named positional arguments
  • automatic formatting of usage strings
  • automatic inclusion of default values in help messages
  • handling options with different numbers of allowed arguments

While I cannot personally take on migrating every script in CMSSW, at least our most-used common tools should reflect best practices.

In addition, in the course of doing this migration, I fixed various typos and a few stray python3 migration issues.

PR validation:

Ran each script to ensure it still works. Unit tests pass.

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:

Unlikely to be backported.

@cmsbuild
Copy link
Contributor

+code-checks

Logs: https://cmssdt.cern.ch/SDT/code-checks/cms-sw-PR-43042/37228

  • This PR adds an extra 72KB to repository

  • There are other open Pull requests which might conflict with changes you have proposed:

@cmsbuild
Copy link
Contributor

A new Pull Request was created by @kpedro88 (Kevin Pedro) for master.

It involves the following packages:

  • Configuration/Applications (operations)
  • FWCore/ParameterSet (core)
  • FWCore/PythonUtilities (core)
  • FWCore/Utilities (core)

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

cms-bot commands are listed here

from Configuration.Applications.Options import parser

options = parser.parse_args(items)
print(options)
Copy link
Contributor

Choose a reason for hiding this comment

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

was this just for debugging?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

yes, let me just rebase that right out of there...

@cmsbuild
Copy link
Contributor

+code-checks

Logs: https://cmssdt.cern.ch/SDT/code-checks/cms-sw-PR-43042/37231

  • This PR adds an extra 72KB to repository

  • There are other open Pull requests which might conflict with changes you have proposed:

@cmsbuild
Copy link
Contributor

Pull request #43042 was updated. @antoniovilela, @davidlange6, @Dr15Jones, @fabiocos, @makortel, @rappoccio, @smuzaffar, @cmsbuild can you please check and sign again.

@@ -4,15 +4,18 @@
# dictionaries or escape characters

from __future__ import print_function
Copy link
Contributor

Choose a reason for hiding this comment

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

could this line go away?

@@ -2,54 +2,55 @@

from __future__ import print_function
Copy link
Contributor

Choose a reason for hiding this comment

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

obsolete?

@@ -2,30 +2,27 @@

from __future__ import print_function
Copy link
Contributor

Choose a reason for hiding this comment

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

obsolete?

@@ -2,34 +2,34 @@

from __future__ import print_function
Copy link
Contributor

Choose a reason for hiding this comment

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

obsolete?

@@ -2,27 +2,25 @@

from __future__ import print_function
Copy link
Contributor

Choose a reason for hiding this comment

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

obsolete?

@@ -14,17 +13,6 @@ def run():
# after cleanup of all config parameters pass it to the ConfigBuilder
configBuilder = ConfigBuilder(options, with_output = True, with_input = True)

# Switch on any eras that have been specified. This is not required to create
Copy link
Contributor

Choose a reason for hiding this comment

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

Where did the era handling go? Or was this not actually needed?

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 was obsoleted by #39127.

@@ -2,21 +2,18 @@

from __future__ import print_function
Copy link
Contributor

Choose a reason for hiding this comment

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

obsolete?

@@ -2,11 +2,10 @@

from __future__ import print_function
Copy link
Contributor

Choose a reason for hiding this comment

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

obsolete?

@@ -1,6 +1,5 @@
#! /usr/bin/env python3
from __future__ import print_function
Copy link
Contributor

Choose a reason for hiding this comment

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

obsolete?

@Dr15Jones
Copy link
Contributor

I wouldn't have commented about the from __future__ line except you did remove it from one of the files.

@cmsbuild
Copy link
Contributor

+code-checks

Logs: https://cmssdt.cern.ch/SDT/code-checks/cms-sw-PR-43042/37238

  • This PR adds an extra 76KB to repository

  • There are other open Pull requests which might conflict with changes you have proposed:

@cmsbuild
Copy link
Contributor

+code-checks

Logs: https://cmssdt.cern.ch/SDT/code-checks/cms-sw-PR-43042/37262

  • This PR adds an extra 76KB to repository

  • There are other open Pull requests which might conflict with changes you have proposed:

@cmsbuild
Copy link
Contributor

Pull request #43042 was updated. @makortel, @smuzaffar, @Dr15Jones, @rappoccio, @davidlange6, @antoniovilela, @cmsbuild, @fabiocos can you please check and sign again.

@kpedro88
Copy link
Contributor Author

please test

@cmsbuild
Copy link
Contributor

+1

Summary: https://cmssdt.cern.ch/SDT/jenkins-artifacts/pull-request-integration/PR-84c5f6/35274/summary.html
COMMIT: d27742b
CMSSW: CMSSW_13_3_X_2023-10-18-2300/el8_amd64_gcc12
User test area: For local testing, you can use /cvmfs/cms-ci.cern.ch/week1/cms-sw/cmssw/43042/35274/install.sh to create a dev area with all the needed externals and cmssw changes.

Comparison Summary

Summary:

  • You potentially added 14 lines to the logs
  • Reco comparison results: 6 differences found in the comparisons
  • DQMHistoTests: Total files compared: 50
  • DQMHistoTests: Total histograms compared: 3357400
  • DQMHistoTests: Total failures: 3
  • DQMHistoTests: Total nulls: 0
  • DQMHistoTests: Total successes: 3357375
  • DQMHistoTests: Total skipped: 22
  • DQMHistoTests: Total Missing objects: 0
  • DQMHistoSizes: Histogram memory added: 0.0 KiB( 49 files compared)
  • Checked 214 log files, 167 edm output root files, 50 DQM output files
  • TriggerResults: no differences found

@makortel
Copy link
Contributor

+core

@antoniovilela
Copy link
Contributor

+1

@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 be automatically merged.

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.

5 participants