Skip to content

Commit f5e0d85

Browse files
jmchiltonmvdbeek
authored andcommitted
Add a slurm_init command.
It should allow simplify the documentation for using SLURM, allow for auto-testing the documentation, and having a fixed location to expect the slurm library by default could allow us to auto pick it up if it is available.
1 parent 671a135 commit f5e0d85

1 file changed

Lines changed: 34 additions & 0 deletions

File tree

planemo/commands/cmd_slurm_init.py

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
"""Module describing the planemo ``slurm_init`` command."""
2+
3+
import shutil
4+
import tempfile
5+
6+
import click
7+
8+
from planemo.cli import command_function
9+
from planemo.io import info, shell, untar_to
10+
11+
SLRUM_DRMAA_VERSION = "1.1.4"
12+
DOWNLOAD_URL = f"https://github.com/natefoo/slurm-drmaa/releases/download/{SLRUM_DRMAA_VERSION}/slurm-drmaa-{SLRUM_DRMAA_VERSION}.tar.gz"
13+
14+
15+
@click.command("slurm_init")
16+
@command_function
17+
def cli(ctx, **kwds):
18+
"""Initialize a copy of the SLURM DRMAA library."""
19+
dest = f"{ctx.workspace}/libdrmaa.so"
20+
tempdir = tempfile.mkdtemp()
21+
tar_args = ["-zxf", "-", "--strip-components=1"]
22+
try:
23+
# This used to show the wget command (and in fact use wget), it doesn't anymore but
24+
# this should be restored. The point is to show developers what is happening and how to do it.
25+
untar_to(DOWNLOAD_URL, tar_args=tar_args, dest_dir=tempdir)
26+
shell(["mkdir", "dest"], cwd=tempdir)
27+
shell(["./autogen.sh"], cwd=tempdir)
28+
shell(["./configure", f"--prefix={tempdir}/dist"], cwd=tempdir)
29+
shell(["make"], cwd=tempdir)
30+
shell(["make install"], cwd=tempdir)
31+
shutil.move(f"{tempdir}/dist/lib/libdrmaa.so", dest)
32+
info(f"SLURM DRMAA library initialized successfully and copied to {dest}.")
33+
finally:
34+
shutil.rmtree(tempdir)

0 commit comments

Comments
 (0)