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

Python (standard library) implementation of update pileup object script #11872

Merged
merged 1 commit into from
Jan 23, 2024

Conversation

vkuznet
Copy link
Contributor

@vkuznet vkuznet commented Jan 22, 2024

Fixes #11867

Status

ready

Description

A new replacement of Alan's WMCore/pycurl based Python script introduced in #11868

This script is based on Python standard library and does not require any third party or WMCore dependencies. It uses the MSPileup REST API to fetch all of the pileup documents, update each of them with data provided via a JSON file, then update those documents back in MSPileup (through a PUT http call).

Is it backward compatible (if not, which system it affects?)

YES

Related PRs

#11868

External dependencies / deployment changes

@vkuznet vkuznet requested a review from amaltaro January 22, 2024 21:27
@vkuznet vkuznet self-assigned this Jan 22, 2024
@cmsdmwmbot
Copy link

Jenkins results:

  • Python3 Unit tests: failed
    • 1 new failures
    • 1 changes in unstable tests
  • Python3 Pylint check: failed
    • 6 warnings and errors that must be fixed
    • 6 comments to review
  • Pylint py3k check: succeeded
  • Pycodestyle check: succeeded
    • 1 comments to review

Details at https://cmssdt.cern.ch/dmwm-jenkins/view/All/job/DMWM-WMCore-PR-test/14779/artifact/artifacts/PullRequestReport.html

@cmsdmwmbot
Copy link

Jenkins results:

  • Python3 Unit tests: failed
    • 1 new failures
    • 1 changes in unstable tests
  • Python3 Pylint check: failed
    • 6 warnings and errors that must be fixed
    • 6 comments to review
  • Pylint py3k check: succeeded
  • Pycodestyle check: succeeded
    • 1 comments to review

Details at https://cmssdt.cern.ch/dmwm-jenkins/view/All/job/DMWM-WMCore-PR-test/14780/artifact/artifacts/PullRequestReport.html

Copy link
Contributor

@amaltaro amaltaro left a comment

Choose a reason for hiding this comment

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

Thank you for providing this script, Valentin. In addition to the comments made along the code, I forgot to mention that we could have adopted the standard print function statements instead of logging, given that it has no dependency in any other WMCore library. If you still want to change that, please go ahead.

bin/adhoc-scripts/updatePileupObjects.py Outdated Show resolved Hide resolved
bin/adhoc-scripts/updatePileupObjects.py Outdated Show resolved Hide resolved
bin/adhoc-scripts/updatePileupObjects.py Outdated Show resolved Hide resolved
bin/adhoc-scripts/updatePileupObjects.py Outdated Show resolved Hide resolved
bin/adhoc-scripts/updatePileupObjects.py Outdated Show resolved Hide resolved
bin/adhoc-scripts/updatePileupObjects.py Outdated Show resolved Hide resolved
bin/adhoc-scripts/updatePileupObjects.py Outdated Show resolved Hide resolved
bin/adhoc-scripts/updatePileupObjects.py Outdated Show resolved Hide resolved
bin/adhoc-scripts/updatePileupObjects.py Outdated Show resolved Hide resolved
bin/adhoc-scripts/updatePileupObjects.py Outdated Show resolved Hide resolved
@cmsdmwmbot
Copy link

Jenkins results:

  • Python3 Unit tests: succeeded
    • 1 changes in unstable tests
  • Python3 Pylint check: failed
    • 3 warnings and errors that must be fixed
    • 1 warnings
    • 7 comments to review
  • Pylint py3k check: succeeded
  • Pycodestyle check: succeeded
    • 1 comments to review

Details at https://cmssdt.cern.ch/dmwm-jenkins/view/All/job/DMWM-WMCore-PR-test/14781/artifact/artifacts/PullRequestReport.html

@cmsdmwmbot
Copy link

Jenkins results:

  • Python3 Unit tests: succeeded
    • 1 changes in unstable tests
  • Python3 Pylint check: succeeded
    • 1 warnings
    • 5 comments to review
  • Pylint py3k check: succeeded
  • Pycodestyle check: succeeded
    • 1 comments to review

Details at https://cmssdt.cern.ch/dmwm-jenkins/view/All/job/DMWM-WMCore-PR-test/14782/artifact/artifacts/PullRequestReport.html

@cmsdmwmbot
Copy link

Jenkins results:

  • Python3 Unit tests: succeeded
    • 1 tests no longer failing
    • 1 changes in unstable tests
  • Python3 Pylint check: succeeded
    • 1 warnings
    • 2 comments to review
  • Pylint py3k check: succeeded
  • Pycodestyle check: succeeded

Details at https://cmssdt.cern.ch/dmwm-jenkins/view/All/job/DMWM-WMCore-PR-test/14783/artifact/artifacts/PullRequestReport.html

@vkuznet vkuznet requested a review from amaltaro January 23, 2024 14:56
Copy link
Contributor

@amaltaro amaltaro left a comment

Choose a reason for hiding this comment

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

@vkuznet Valentin, these changes look good to me. Before we merge it, I would ask you to:
a) squash all the commits into a single commit
b) test updating one pileup document against your dev k8s cluster (or testbed)

Once you are happy with these tests, we can get it merged. Thanks

@cmsdmwmbot
Copy link

Jenkins results:

  • Python3 Unit tests: succeeded
    • 1 tests no longer failing
    • 1 changes in unstable tests
  • Python3 Pylint check: succeeded
    • 1 warnings
    • 2 comments to review
  • Pylint py3k check: succeeded
  • Pycodestyle check: succeeded

Details at https://cmssdt.cern.ch/dmwm-jenkins/view/All/job/DMWM-WMCore-PR-test/14784/artifact/artifacts/PullRequestReport.html

@vkuznet
Copy link
Contributor Author

vkuznet commented Jan 23, 2024

Alan, I made an additional change to properly encode passed json data, please review last commit f846361

All other commits are squashed. And, with my last fix I was able to update testbed docs. For that I used the following document located at /tmp/update.json

{"lastUpdateTime": 1706028000}

and I call the script as following:

bin/adhoc-scripts/updatePileupObjects.py --fin=/tmp/update.json --url https://cmsweb-testbed.cern.ch

I inspected the logger output and it dumped that all documents were updated. I fetched new docs from testbed via curl call to https://cmsweb-testbed.cern.ch/ms-pileup/data/pileup and saw that all lastUpdateTime values were updated. Doing this I didn't modified any other fields in docs and only triggered update whose update time was set by MSPileyp code.

Said that, I can squash last commit after your additional review. It was required since otherwise we were passing dict objects rather the actual json. It it caused http error which I posted in this gist.

Moreover, I realized that this script can be used used ONLY for static change applied to all documents. In other words, if we want to add transition records this script will not be helpful as transition record need a customName equal to pileup name according to your gist section 2. In order to use this script we'll need to add additional code to read record, take its pileup name, and create transition record with it.

@cmsdmwmbot
Copy link

Jenkins results:

  • Python3 Unit tests: succeeded
    • 1 tests no longer failing
    • 1 changes in unstable tests
  • Python3 Pylint check: succeeded
    • 1 warnings
    • 2 comments to review
  • Pylint py3k check: succeeded
  • Pycodestyle check: succeeded

Details at https://cmssdt.cern.ch/dmwm-jenkins/view/All/job/DMWM-WMCore-PR-test/14785/artifact/artifacts/PullRequestReport.html

@amaltaro
Copy link
Contributor

Looks good to me. Please squash the last 2 commits into a single one.

For the transition record, we can update this script once it becomes necessary. Potentially we don't even need to push upstream the transition logic.

@vkuznet
Copy link
Contributor Author

vkuznet commented Jan 23, 2024

squashing is done

@cmsdmwmbot
Copy link

Jenkins results:

  • Python3 Unit tests: failed
    • 1 new failures
    • 1 changes in unstable tests
  • Python3 Pylint check: succeeded
    • 1 warnings
    • 2 comments to review
  • Pylint py3k check: succeeded
  • Pycodestyle check: succeeded

Details at https://cmssdt.cern.ch/dmwm-jenkins/view/All/job/DMWM-WMCore-PR-test/14786/artifact/artifacts/PullRequestReport.html

@amaltaro
Copy link
Contributor

Thanks Valentin.

@amaltaro amaltaro merged commit d14d0d9 into dmwm:master Jan 23, 2024
2 of 4 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Create new script for adjusting Pileup documents in MongoDB
3 participants