Metadata-Version: 2.1
Name: pyslurmutils
Version: 0.1.0rc2
Summary: SLURM utilities for Python
Home-page: https://gitlab.esrf.fr/workflow/pyslurmutils/
Author: ESRF
Author-email: wout.de_nolf@esrf.fr
License: MIT
Project-URL: Source, https://gitlab.esrf.fr/workflow/pyslurmutils/
Project-URL: Documentation, https://pyslurmutils.readthedocs.io/
Project-URL: Tracker, https://gitlab.esrf.fr/workflow/pyslurmutils/issues/
Classifier: Intended Audience :: Science/Research
Classifier: License :: OSI Approved :: MIT License
Classifier: Programming Language :: Python :: 3
Requires-Python: >=3.7
Description-Content-Type: text/markdown
Provides-Extra: test
Provides-Extra: dev
Provides-Extra: doc
License-File: LICENSE.md

# pyslurmutils

SLURM utilities for Python.

## Demo

Get an access token on rnice

```bash
export SLURM_TOKEN=$(scontrol token lifespan=3600)
export SLURM_URL=...
export SLURM_USER=...
```

Run any of the example scripts

```bash
python3 scripts/examples.py
```

Run the tests (CI or locally)

```bash
python3 -m pytest .
```

When `SLURM_TOKEN`, `SLURM_URL` or `SLURM_USER` is missing it will mock
the SLURM clients.

## Execute a python function on SLURM

Execute a function on SLURM with an API similar to python's `concurrent.futures`

```python
from pyslurmutils.concurrent.futures import SlurmRestExecutor

with SlurmRestExecutor(
    url,
    user_name,
    token,
    log_directory=log_directory,  # for log files
    data_directory=data_directory,  # TCP when not provided
    pre_script="source /etc/profile\nmodule load ewoks",  # load environment
    python_cmd="python",
) as pool:

    future = pool.submit(sum, [1, 1])
    assert future.result() == 2
```
