#slurm #hpc #cluster #plugin #plugin-api #error-message #spank

slurm-spank

Safe Rust bindings to the Slurm SPANK API

6 releases

0.3.0 Apr 20, 2024
0.2.4 Oct 22, 2023
0.2.3 Mar 21, 2023

#10 in #slurm

Download history 15/week @ 2024-04-29 19/week @ 2024-07-08

313 downloads per month

MIT/Apache

100KB
2K SLoC

crates.io docs.rs

slurm-spank-rs

Rust bindings for writing Slurm SPANK plugins


lib.rs:

Rust bindings for writing Slurm SPANK Plugins

Introduction

This crate allows to write Slurm SPANK plugins using Rust. To learn more about capabilities available through SPANK please refer to the official SPANK documentation.

To create a SPANK plugin using this crate, you need to define a struct for which you implement the Plugin trait and to make it available as a SPANK plugin using the SPANK_PLUGIN! macro.

The methods of the Plugin trait correspond to the callbacks defined by the SPANK API such as init_post_opt, task_post_fork etc. These methods have a default implementation which means you only need to implement the callbacks relevant for your plugin.

Each callback method is passed a SpankHandle reference which allows to interact with Slurm through the SPANK API.

When returning an [Err] from a callback an error message will be displayed and/or logged by default, depending on the context. This behaviour may be overridden by the report_error method. A default Subscriber is also configured to facilitate the use of the tracing crate for logging and error reporting while using SPANK log facilities, such as in the example below. This can be overridden by the setup method.

Example: hello.so

The following example implements a simple hello world plugin. A more complete example is provided in the example directory of the repository which shows how to implement the same renice plugin that is given as an example of the C SPANK API in the Slurm SPANK documentation.

The following Cargo.toml can be used to build this example plugin

 [package]
 name = "slurm-spank-hello"
 version = "0.1.0"
 edition = "2021"

 [lib]
 crate-type = ["cdylib"]

 [dependencies]
 eyre = "0.6.8"
 slurm-spank = "0.3"
 tracing = "0.1.37"

Dependencies

~5.5–8.5MB
~147K SLoC