-
Notifications
You must be signed in to change notification settings - Fork 205
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
make delattr aware of environment variables in ModuleLoadEnvironment #4784
base: 5.0.x
Are you sure you want to change the base?
Conversation
easybuild/tools/modules.py
Outdated
|
||
name = self._unmangle_env_var_name(name) | ||
del self.__dict__['_env_vars'][name] | ||
try: | ||
self.__dict__['_env_vars'][name].log.warning( |
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.
huh, is this really correct?
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.
also, maybe we use deprecated here instead, so we could easier find this in the future and remove it for EB 6?
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.
depends on your definition of correct 🙂 I'm just using the log handle on the attribute being deleted because ModuleLoadEnvironment
does not have any. I could add one as well.
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.
The resulting log looks the same anyway:
== 2025-03-03 19:32:36,517 modules.py:345 WARNING Please use ModuleLoadEnvironment.remove() instead of 'delattr' to remove environment variable: ACLOCAL_PATH
== 2025-03-03 19:32:36,517 modules.py:345 WARNING Please use ModuleLoadEnvironment.remove() instead of 'delattr' to remove environment variable: CLASSPATH
== 2025-03-03 19:32:36,517 modules.py:345 WARNING Please use ModuleLoadEnvironment.remove() instead of 'delattr' to remove environment variable: CMAKE_LIBRARY_PATH
== 2025-03-03 19:32:36,517 modules.py:345 WARNING Please use ModuleLoadEnvironment.remove() instead of 'delattr' to remove environment variable: CMAKE_PREFIX_PATH
== 2025-03-03 19:32:36,517 modules.py:345 WARNING Please use ModuleLoadEnvironment.remove() instead of 'delattr' to remove environment variable: GI_TYPELIB_PATH
== 2025-03-03 19:32:36,517 modules.py:345 WARNING Please use ModuleLoadEnvironment.remove() instead of 'delattr' to remove environment variable: LD_LIBRARY_PATH
== 2025-03-03 19:32:36,517 modules.py:345 WARNING Please use ModuleLoadEnvironment.remove() instead of 'delattr' to remove environment variable: LIBRARY_PATH
== 2025-03-03 19:32:36,517 modules.py:345 WARNING Please use ModuleLoadEnvironment.remove() instead of 'delattr' to remove environment variable: MANPATH
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.
made it less ugly in cc9d03f
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.
There is this method specialization you added that does the mapping to delete environment variables. I assumed this PR was added in case people are using delattr in their custom easyblocks, and that shouldn't break with 5.0.x, but don't we want to remove this function down the line once everyone has properly switches to .remove?
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.
that is the issue with delattr
, you cannot remove it. So what is added in this PR has to stay, which is ok. We just warn that .remove()
is the better option, but it is not illegal to use delattr
.
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.
on second thought, there is no point in this warning, using delattr
is perfectly fine
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.
updated the description of this PR and the docstring of delattr
in ModuleLoadEnvironment
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.
@Micket ping, can we get this merged please? all tests are green now
easybuild/tools/modules.py
Outdated
return True | ||
|
||
name = self._unmangle_env_var_name(name) | ||
self._log.warning( |
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.
Shouldn't that rather be a log.deprecation
instead of "just" a warning?
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.
We cannot deprecated a builtin like delattr
, that only makes sense for things that we could remove from the code. Anyhow, it is not wrong to use it in ModuleLoadEnvironment
, so I'm removing that warning altogether to avoid confusion.
There are two ways to remove attributes from
ModuleLoadEnvironment
:ModuleLoadEnvironment.remove("ENV_VAR")
will ignore missing attributesdelattr(ModuleLoadEnvironment, "ENV_VAR")
will error on missing attributes