-
Notifications
You must be signed in to change notification settings - Fork 121
Fix ClusterShell NodeSet import #682
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
Conversation
|
All contributors have signed the CLA ✍️ ✅ |
|
I have read the CLA Document and I hereby sign the CLA |
|
recheck |
64f5095 to
b151f63
Compare
|
In what environment did you get this attribute error? Can you please provide the exception backtrace? |
|
Environment: I see this behavior when RacksDB is disabled and patched RacksDB imports to make it optional. How to Reproduce:
Trace: |
|
OK, I see! I wrote a simple reproducer: $ cat main.py
import ClusterShell
print(ClusterShell)
print(ClusterShell.NodeSet)
print(ClusterShell.NodeSet.NodeSet)
$ python3 main.py
<module 'ClusterShell' from '/…/.venv/lib/python3.12/site-packages/ClusterShell/__init__.py'>
Traceback (most recent call last):
File "/…/main.py", line 3, in <module>
print(ClusterShell.NodeSet)
^^^^^^^^^^^^^^^^^^^^
AttributeError: module 'ClusterShell' has no attribute 'NodeSet'
$ cat pre.py
from ClusterShell.NodeSet import NodeSet
$ sed -i '1s/^/import pre\n/' main.py
$ python3 main.py
<module 'ClusterShell' from '/…/.venv/lib/python3.12/site-packages/ClusterShell/__init__.py'>
<module 'ClusterShell.NodeSet' from '/…/.venv/lib/python3.12/site-packages/ClusterShell/NodeSet.py'>
<class 'ClusterShell.NodeSet.NodeSet'>Indeed, the bug is hidden by RacksDB which imports NodeSet correctly. That explains why I never met the bug in CI and in supported installations. Thank you @faganihajizada for reporting! |
|
Thanks @rezib If you are fine, I am planning to submit another PR to update RacksDB imports to make it optional. |
The module was incorrectly imported as 'import ClusterShell' which doesn't expose NodeSet as a direct attribute. This causes AttributeError when trying to access ClusterShell.NodeSet.NodeSet(). Changed to import NodeSet directly from ClusterShell.NodeSet module and updated the usage accordingly throughout the codebase. This fixes the error when viewing jobs on a specific node in the web UI. Signed-off-by: Rémi Palancher <[email protected]>
b151f63 to
2bd9919
Compare
I'm fine with it! |
Summary
The current code uses import ClusterShell followed by ClusterShell.NodeSet.NodeSet(), which causes an AttributeError because the ClusterShell module doesn't expose NodeSet as a direct attribute when imported this way.
This bug prevents users from viewing jobs filtered by a specific node in the web UI.
examples: https://github.com/cea-hpc/clustershell/blob/master/doc/examples/check_nodes.py
Solution
Changed to import NodeSet directly:
This fix has been applied to:
Test