Skip to content

Commit 3dd08be

Browse files
committed
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 b29be9a commit 3dd08be

1 file changed

Lines changed: 35 additions & 0 deletions

File tree

planemo/commands/cmd_slurm_init.py

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

0 commit comments

Comments
 (0)