-
Notifications
You must be signed in to change notification settings - Fork 122
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
json output #30
Comments
Lmod like TCL/C modules and the tcl pure version supports the -t (or --terse) option. So you can do: module -t avail I know that Easybuild is using the -t option to parse the output of all the module systems they support. |
It can also cause problems with very very long paths? |
What do you mean that module -t spider doesn't do anything different? Is it the same as module spider or is it the same as module -t avail? |
a no, my mistake. It works as it is supposed to do. It's |
I have fixed "module show " to set the error core if the module doesn't exist. I am looking at "module -t spider " issue. The new version is pushed to the HEAD. |
Fixed |
If you are using |
well, we need something to check if a module is there, even if it's hidden. I think |
@wpoely86: we can only use |
Lmod now supports |
@rtmclay: only with |
--show_hidden works without --terse. As for underscores vs. dashes see issue #34 It is just in this case as a replacement for |
closing this issue. |
The new Am I correct when assuming it's available since v5.7.5? |
You are correct. The |
hey folks! Sorry for commenting on an old issue. It does look like -t adds "terse" that makes me press enter to read on the screen - what if I want to save a list to file (e.g., either as a list or json?) I can't find a way to do that with lmod - it looks like the other modules supports it cea-hpc/modules#303 |
I think that depends on your pager settings? For me it just outputs everything to the screen. My pager is set to 'less'. |
But should it? If I am creating a tool that needs to parse the output for a user how does relying on pager settings (where most use less) help me? Can I change it on the fly for one command? |
I guess we could add a json output so that Try it with |
Lmod checks what stderr is connected to. If it is a tty then the pager is used. If it a file then it bypasses the pager setting.
works fine. |
That works! However as a user I'd never guess to try that. |
Maybe you can advise? I'm trying to add a command to run via ssh to just get a listing of modules on a cluster. If I remember correctly the way "module" or"ml" is invoked is kind of strange, e.g., it works when I login but not when I ssh. res = self.ssh.execute("/bin/bash -l ml -t spider > modules.txt") or more simply from bash: $ ssh <server> ml -t spider
bash: ml: command not found
$ ssh <server> module load -t spider
bash: module: command not found
$ ssh <server> /bin/bash -l module load -t spider
stty: standard input: Inappropriate ioctl for device
Lmod is automatically replacing "intel/19.0.4" with "gcc/10.2.1".
Due to MODULEPATH changes, the following have been reloaded:
1) mvapich2/2.3
/bin/bash: module: No such file or directory Could you give any pointers? Any standard library that I could at least add to the path would work! Thank you! |
This is a problem with bash and how it is setup. Are you stuck with bash? You would be better off using zsh because zsh doesn't have the problems of bash. You can read about my suggestion to patch bash here: https://lmod.readthedocs.io/en/latest/030_installing.html?highlight=patching#interactive-non-login-shells The issue is that depending on how your bash is build, it does or does not do a full interactive login when running "ssh host command" or not. That is the remote bash shell that is started on the server bypasses /etc/profile or /etc/bashrc. You should test if it starts your personal startup scripts by adding echo statements in both your ~/.profile and ~/.bashrc and do a "ssh host command" and see what happens. If you can't patch bash or change shells to zsh then the best I can recommend is to run shell scripts on the remote host that do run a login shell so that the module command is defined. |
I could personally use zsh, but the average cluster user is going to have bash (and a few csh). And I'd suspect most bash installs on HPC aren't custom builds (and likely have the default bash build). Indeed with the last example (with -l to prompt a login shell) it looks like something with modules is loaded, but it still reports not being able to find the command. That's actually a good idea - my tool has a small cache of scripts on the host, so I'll try running the command there. Will update after I try! |
Worked! |
tunel-apps/tunel@99d8bbb#diff-58840dbb8fd7c275c1be61f998c832a7a857b6ee58d6b190068b39602fa42873 Feels like a bit of a hack, but then again, so is everything in HPC, and I'm happy to have a hack over nothing at all. Thanks for your help today! |
@vsoch you could also directly call python output of Lmod?
|
Oh that's interesting output! It indeed starts with the list, but also ends with a set of what looks like envars?
The risk here would be if someone didn't install lmod to that exact path (I lucked out that the node I was on did). |
The python code goes to stdout, the list goes to stderr. |
It would be cool if you could do something like
module -o json avail
. (replace json with your favorite data-interchange format). It would make parsing output of Lmod a lot easier by third party tools like Easybuild.I see that the spider already has support of json, xml, ... so with my very limited knowledge about Lmod, I don't think this can be very hard?
The text was updated successfully, but these errors were encountered: