#slurm #plugin #hpc #cluster #spank


Safe Rust bindings to the Slurm SPANK API

4 releases

0.2.3 Mar 21, 2023
0.2.2 Mar 15, 2023
0.2.1 Mar 14, 2023
0.2.0 Mar 14, 2023

#6 in #slurm




Rust bindings for writing Slurm SPANK plugins


Rust bindings for writing Slurm SPANK Plugins


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 relevent 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 overriden 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 exemple below. This can be overriden 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

 name = "hello"
 version = "0.1.0"
 edition = "2021"

 crate-type = ["cdylib"]

 eyre = "0.6.8"
 slurm-spank = "0.2"
 tracing = "0.1.37"


~134K SLoC