From 69a67694fa9d60a5fa23d7c5b1a866b570f92739 Mon Sep 17 00:00:00 2001 From: John Chilton Date: Thu, 19 Jun 2025 13:29:51 -0400 Subject: [PATCH 1/5] 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. --- planemo/commands/cmd_slurm_init.py | 38 ++++++++++++++++++++++++++++++ 1 file changed, 38 insertions(+) create mode 100644 planemo/commands/cmd_slurm_init.py diff --git a/planemo/commands/cmd_slurm_init.py b/planemo/commands/cmd_slurm_init.py new file mode 100644 index 000000000..3cf157760 --- /dev/null +++ b/planemo/commands/cmd_slurm_init.py @@ -0,0 +1,38 @@ +"""Module describing the planemo ``slurm_init`` command.""" + +import shutil +import tempfile + +import click + +from planemo.cli import command_function +from planemo.io import ( + info, + shell, + untar_to, +) + +SLRUM_DRMAA_VERSION = "1.1.4" +DOWNLOAD_URL = f"https://github.com/natefoo/slurm-drmaa/releases/download/{SLRUM_DRMAA_VERSION}/slurm-drmaa-{SLRUM_DRMAA_VERSION}.tar.gz" + + +@click.command("slurm_init") +@command_function +def cli(ctx, **kwds): + """Initialize a copy of the SLURM DRMAA library.""" + dest = f"{ctx.workspace}/libdrmaa.so" + tempdir = tempfile.mkdtemp() + tar_args = ["-zxf", "-", "--strip-components=1"] + try: + # This used to show the wget command (and in fact use wget), it doesn't anymore but + # this should be restored. The point is to show developers what is happening and how to do it. + untar_to(DOWNLOAD_URL, tar_args=tar_args, dest_dir=tempdir) + shell(["mkdir", "dest"], cwd=tempdir) + shell(["./autogen.sh"], cwd=tempdir) + shell(["./configure", f"--prefix={tempdir}/dist"], cwd=tempdir) + shell(["make"], cwd=tempdir) + shell(["make install"], cwd=tempdir) + shutil.move(f"{tempdir}/dist/lib/libdrmaa.so", dest) + info(f"SLURM DRMAA library initialized successfully and copied to {dest}.") + finally: + shutil.rmtree(tempdir) From 6d4d7bbcb6b047fac7a1e8317afb98e2712e91fe Mon Sep 17 00:00:00 2001 From: mvdbeek Date: Fri, 20 Jun 2025 10:09:19 +0200 Subject: [PATCH 2/5] Use latest SLURM_DRMAA 1.1.4 doesn't compile against slurm on anvil --- planemo/commands/cmd_slurm_init.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/planemo/commands/cmd_slurm_init.py b/planemo/commands/cmd_slurm_init.py index 3cf157760..62dba4be9 100644 --- a/planemo/commands/cmd_slurm_init.py +++ b/planemo/commands/cmd_slurm_init.py @@ -12,7 +12,7 @@ untar_to, ) -SLRUM_DRMAA_VERSION = "1.1.4" +SLRUM_DRMAA_VERSION = "1.1.5" DOWNLOAD_URL = f"https://github.com/natefoo/slurm-drmaa/releases/download/{SLRUM_DRMAA_VERSION}/slurm-drmaa-{SLRUM_DRMAA_VERSION}.tar.gz" From 83052cf6021d7e3f5dc0aafb16df588015f4b919 Mon Sep 17 00:00:00 2001 From: mvdbeek Date: Fri, 20 Jun 2025 10:14:49 +0200 Subject: [PATCH 3/5] Fix make install shell command --- planemo/commands/cmd_slurm_init.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/planemo/commands/cmd_slurm_init.py b/planemo/commands/cmd_slurm_init.py index 62dba4be9..d7da8a4c3 100644 --- a/planemo/commands/cmd_slurm_init.py +++ b/planemo/commands/cmd_slurm_init.py @@ -31,7 +31,7 @@ def cli(ctx, **kwds): shell(["./autogen.sh"], cwd=tempdir) shell(["./configure", f"--prefix={tempdir}/dist"], cwd=tempdir) shell(["make"], cwd=tempdir) - shell(["make install"], cwd=tempdir) + shell(["make", "install"], cwd=tempdir) shutil.move(f"{tempdir}/dist/lib/libdrmaa.so", dest) info(f"SLURM DRMAA library initialized successfully and copied to {dest}.") finally: From aa4f9b7e6f1ba11de654c347b2cc3afb82d3995e Mon Sep 17 00:00:00 2001 From: mvdbeek Date: Fri, 20 Jun 2025 11:13:32 +0200 Subject: [PATCH 4/5] Fix broken .so symlink --- planemo/commands/cmd_slurm_init.py | 22 +++++++++++++--------- 1 file changed, 13 insertions(+), 9 deletions(-) diff --git a/planemo/commands/cmd_slurm_init.py b/planemo/commands/cmd_slurm_init.py index d7da8a4c3..8d3fc3837 100644 --- a/planemo/commands/cmd_slurm_init.py +++ b/planemo/commands/cmd_slurm_init.py @@ -2,6 +2,7 @@ import shutil import tempfile +from pathlib import Path import click @@ -20,19 +21,22 @@ @command_function def cli(ctx, **kwds): """Initialize a copy of the SLURM DRMAA library.""" - dest = f"{ctx.workspace}/libdrmaa.so" - tempdir = tempfile.mkdtemp() + dest = Path(ctx.workspace) / "libdrmaa.so" + tempdir = Path(tempfile.mkdtemp()) tar_args = ["-zxf", "-", "--strip-components=1"] try: # This used to show the wget command (and in fact use wget), it doesn't anymore but # this should be restored. The point is to show developers what is happening and how to do it. - untar_to(DOWNLOAD_URL, tar_args=tar_args, dest_dir=tempdir) - shell(["mkdir", "dest"], cwd=tempdir) - shell(["./autogen.sh"], cwd=tempdir) - shell(["./configure", f"--prefix={tempdir}/dist"], cwd=tempdir) - shell(["make"], cwd=tempdir) - shell(["make", "install"], cwd=tempdir) - shutil.move(f"{tempdir}/dist/lib/libdrmaa.so", dest) + untar_to(DOWNLOAD_URL, tar_args=tar_args, dest_dir=str(tempdir)) + shell(["mkdir", "dest"], cwd=str(tempdir)) + shell(["./autogen.sh"], cwd=str(tempdir)) + shell(["./configure", f"--prefix={tempdir}/dist"], cwd=str(tempdir)) + shell(["make"], cwd=str(tempdir)) + shell(["make", "install"], cwd=str(tempdir)) + lib_path = tempdir / "dist" / "lib" / "libdrmaa.so" + link_target = lib_path.readlink() + target_file = tempdir / "dist" / "lib" / link_target + shutil.copy(target_file, dest) info(f"SLURM DRMAA library initialized successfully and copied to {dest}.") finally: shutil.rmtree(tempdir) From d9776ccee8221093685a0d6f7c208548e02462a7 Mon Sep 17 00:00:00 2001 From: mvdbeek Date: Fri, 20 Jun 2025 11:26:42 +0200 Subject: [PATCH 5/5] Drop trailing dot so I can copy-paste --- planemo/commands/cmd_slurm_init.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/planemo/commands/cmd_slurm_init.py b/planemo/commands/cmd_slurm_init.py index 8d3fc3837..bb02864aa 100644 --- a/planemo/commands/cmd_slurm_init.py +++ b/planemo/commands/cmd_slurm_init.py @@ -37,6 +37,6 @@ def cli(ctx, **kwds): link_target = lib_path.readlink() target_file = tempdir / "dist" / "lib" / link_target shutil.copy(target_file, dest) - info(f"SLURM DRMAA library initialized successfully and copied to {dest}.") + info(f"SLURM DRMAA library initialized successfully and copied to {dest}") finally: shutil.rmtree(tempdir)