-
Notifications
You must be signed in to change notification settings - Fork 107
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
Replace imp module by importlib #11530
Conversation
Jenkins results:
|
Jenkins results:
|
Jenkins results:
|
Jenkins results:
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@vkuznet Valentin, the python3 documentation suggests different replacements for imp.find_module
and imp.load_module
, see:
https://docs.python.org/3/library/imp.html#imp.load_module
Can you please clarify why you implemented these with importlib.machinery
instead of importlib.utils
?
Alan, I made changes as close to original implementation as possible. Here are different ways of doing module loading:
The Python documentation does not explicitly says which method is better (even though it provides examples of |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hi @vkuznet
Thanks for this PR. I was about to ask the same question as Alan did. And to me the third implementation you were suggesting looks the best. Talking about this one:
- using importlib.util implementation
cfgBaseName = os.path.basename(configPath).replace(".py", "") spec = importlib.util.spec_from_file_location(cfgBaseName, configPath) module = importlib.util.module_from_spec(spec)
@amaltaro , @todor-ivanov could you please clarify how we should move forward with this PR. Neither of you explicitly said let's change the fix to use |
@vkuznet Valentin, my preference goes towards I do have a concern though, instead of importing the whole importlib, should we actually import only what's going to be used, thus:
? |
Alan, the import lib has only one machiner.py module therefore
is equivalent to
In both cases they provide identical content, e.g.:
vs
|
Sorry, I guess I wasn't clear enough in my previous message. What I wanted to say is that, if only the machinery module is used in a WMCore module, ideally we should change the import from:
to
From what I read, the lack of this change will not affect memory footprint though. So we can just leave it for another day as well. |
Alan, I rather prefer to keep the code this way as it clears what it is doing in placed which have been changed, i.e. the prefix of |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sounds good to me, Valentin!
Given that we are addressing the final bits for an upcoming production deployment, let's merge it only after upgrading services in CMSWEB production.
Fixes #11434
Status
ready
Description
Replace
import imp
occurrences withimport importlib
Is it backward compatible (if not, which system it affects?)
MAYBE
Related PRs
External dependencies / deployment changes