Hello everyone,
I don't really know how to put this, but I'm recently trying to improve myself in coding and making tools. I was mostly doing a lot of bash things because it was the easiest way. But I know I should review my habits to be more portable.
This was my first year working on a cluster environment (SLURM), and I think I still don't get all the concepts behind it. I was fine with just doing simple "sbatch", "srun" or "sarray" command, but I would like to understand more about how it works.
A concrete example : I want to create a python script that call a tool (minimap2) installed on our cluster. This tool can only be used after a "module load" of the appropriate module (in that case bioinfo/minimap2-2.5).
So I was giving a shot with subprocess.call
and subprocess.run
(from which I understood they were sort of the same but not from the same python version ?) to perfom that module load.
But it kept failing, and I could'nt find anything about it on the net. I feel like I'm doing something abberant...
I'm not even sure if what I am trying to do is relevant (slurm module load from within python ?). Can anyone correct me and maybe explain what I'm doing wrong ? Maybe if you have any website or book to recommand to understand better this topic. I feel very nooby, but I still want to improve.
Thanks for your help, sorry if not a proper Biostar question,
Roxane
Below are all good answers but I wonder why it shouldn't be possible to use exec() to do this.
EDIT: After a quick search, I found the doc for the module command which has this (which is not quite what I was thinking about but still uses exec()):