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

[py2py3] More job runtime places to encode pickledarguments to bytes #10766

Merged
merged 1 commit into from
Aug 21, 2021

Conversation

amaltaro
Copy link
Contributor

@amaltaro amaltaro commented Aug 20, 2021

Fixes #10647

Status

ready

Description

For workflows that have been created while ReqMgr2 was still running in Python2 (< July 2021), the CMSSW pickledarguments can be of string type, thus failing to be pickled loaded.

This patch will encode those native strings to bytes, if running with a Python3 interpreter.

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

YES (it should!)

Related PRs

Complement to: #10648

External dependencies / deployment changes

None

@cmsdmwmbot
Copy link

Jenkins results:

  • Python2 Unit tests: succeeded
  • Python3 Unit tests: succeeded
  • Python2 Pylint check: failed
    • 9 warnings and errors that must be fixed
    • 4 warnings
    • 47 comments to review
  • Python3 Pylint check: failed
    • 9 warnings and errors that must be fixed
    • 4 warnings
    • 59 comments to review
  • Pylint py3k check: succeeded
  • Pycodestyle check: succeeded
    • 38 comments to review

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

Copy link
Member

@mapellidario mapellidario left a comment

Choose a reason for hiding this comment

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

Hello! I have to trust your knowledge here, @amaltaro. From a quick look it seems that pickledarguments is only set as

        self.data.application.configuration.pickledarguments = pickle.dumps(args, protocol=0)

and pickle.dumps() return bytes. I have to assume that we may be loading this self.data.application.configuration from a different place (maybe directly from some file?) where pickledarguments ends up being a unicode string.

In any case, I like the approach of converting it back to right type as late as possible, when needed. Approved!

Comment on lines +392 to +394
pklArgs = encodeUnicodeToBytesConditional(stepSection.application.configuration.pickledarguments,
condition=PY3)
args = pickle.loads(pklArgs)
Copy link
Member

Choose a reason for hiding this comment

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

I like that you are trying to fix only what breaks, but pickle.loads() expects the data to be of type bytes both in py2 and py3, so we could avoid using the conditional here. but do not worry, we should not have problem!

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, I wanted to be as conservative as possible. At least in central production, I can confirm that that attribute comes as bytes (since we migrated services to Py3).
Okay, I'm not going to update this patch then (otherwise I have to re-run my tests). But we better leave it as unresolved for future reference. Thanks!

@amaltaro
Copy link
Contributor Author

amaltaro commented Aug 20, 2021

And you are correct, Dario. We do load this from a file (in couchdb). If you look at this workflow from 2020:
https://cmsweb-testbed.cern.ch/reqmgr2/config?name=amaltaro_SC_LumiMask_PhEDEx_Agent130_Val_200210_134601_2823

one can see this stringification:

amaltaro_SC_LumiMask_PhEDEx_Agent130_Val_200210_134601_2823.tasks.DigiFullPU_2021PU.tree.children.NanoFull_2021PUMergeNANOEDMAODSIMoutput.steps.cmsRun1.application.configuration.pickledarguments = '(dp0
S'mergeNANO'
p1
I01
s.'

which is exactly what was breaking.
Luckily, we spotted it before production, damage would have been huge!!!

@amaltaro
Copy link
Contributor Author

Tests with Py3 WMAgent went well.

@amaltaro amaltaro merged commit 7c7d9dc into dmwm:master Aug 21, 2021
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.

Python3 ReqMgr2 fails to set pickledarguments during assignment
3 participants