3 releases
0.1.2 | May 5, 2024 |
---|---|
0.1.1 | May 5, 2024 |
0.1.0 | May 5, 2024 |
#6 in #slurm
63 downloads per month
210KB
4.5K
SLoC
slurm-spank-compat-rs
Rust bindings for writing Slurm SPANK plugins
compat
- 20.11
- 21.08
- 22.05
- 23.02
- 23.11
Thanks
- Forked from slurm-spank-rs
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"
tracing = "0.1.37"
slurm-spank-compat = "0.1"
Dependencies
~5.5–8.5MB
~145K SLoC