-
Notifications
You must be signed in to change notification settings - Fork 129
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
Feature request: Python interface #671
Comments
I have looked a bit and I found |
Maybe https://lmodule.readthedocs.io/en/latest/index.html is of interest to you (I've never used it, I just know of it's existence). |
Thanks for the link. I did a quick look at the implementation and I do not really like it. The interface goes through the shell script so it can still fail in the Github CI interface and it only provides with simple I am investigating |
I'll discuss this with Robert, but feel free make a PR and thanks for your input |
Thanks, the first part is in #673, I'll need some feedback there of how it should be exported most generally. After that I could make the python interface management, to be included in this project or a one of the third-party ones like |
Description
There are a few issues that create friction between Python and Lmod:
subprocess.Popen
do not persist between commandsThese factors make it hard to chain python/shell commands with pushed/poped Lmod module environment
Proposal
Provide a simple Python interface that can call Lmod functions directly. A minimum interface could be:
module list
module load
module unload/purge
The introspection commands could be direct calls to the Lmod interface with some basic output conversion. The main part is how the load/unload interface can look like. Here a
Lmod
class would carry anenv
dictionary with all the Lmod native environment operations likeprepend_path
chained accordingly. Then when requested, these can be evaluated through Lua or equivalent to have the plain python dictionary that can be fed throughsubprocess
Considerations
module getenv
andmodule getscripts
(exporting the environment variable and executed scripts respectively for a given loaded environment) can be provided on the Lmod side, this would simplify writing this interfaceswig
supports making bindings for both languages. That could make such interfaces available to many more other languages as wellThe text was updated successfully, but these errors were encountered: