# 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="/path/to/log", # for log files
data_directory="/path/to/data", # TCP when not provided
pre_script="module load ewoks", # load environment
python_cmd="python",
) as pool:
future = pool.submit(sum, [1, 1])
assert future.result() == 2
```
Raw data
{
"_id": null,
"home_page": "https://gitlab.esrf.fr/workflow/pyslurmutils/",
"name": "pyslurmutils",
"maintainer": "",
"docs_url": null,
"requires_python": ">=3.7",
"maintainer_email": "",
"keywords": "",
"author": "ESRF",
"author_email": "wout.de_nolf@esrf.fr",
"download_url": "https://files.pythonhosted.org/packages/d7/a4/9f226eab1c6fd54698793e49fb66550dc2c7a784689f8e25340f158f39e8/pyslurmutils-0.1.2.tar.gz",
"platform": null,
"description": "# pyslurmutils\n\nSLURM utilities for Python.\n\n## Demo\n\nGet an access token on rnice\n\n```bash\nexport SLURM_TOKEN=$(scontrol token lifespan=3600)\nexport SLURM_URL=...\nexport SLURM_USER=...\n```\n\nRun any of the example scripts\n\n```bash\npython3 scripts/examples.py\n```\n\nRun the tests (CI or locally)\n\n```bash\npython3 -m pytest .\n```\n\nWhen `SLURM_TOKEN`, `SLURM_URL` or `SLURM_USER` is missing it will mock\nthe SLURM clients.\n\n## Execute a python function on SLURM\n\nExecute a function on SLURM with an API similar to python's `concurrent.futures`\n\n```python\nfrom pyslurmutils.concurrent.futures import SlurmRestExecutor\n\nwith SlurmRestExecutor(\n url,\n user_name,\n token,\n log_directory=\"/path/to/log\", # for log files\n data_directory=\"/path/to/data\", # TCP when not provided\n pre_script=\"module load ewoks\", # load environment\n python_cmd=\"python\",\n) as pool:\n\n future = pool.submit(sum, [1, 1])\n assert future.result() == 2\n```\n",
"bugtrack_url": null,
"license": "MIT",
"summary": "SLURM utilities for Python",
"version": "0.1.2",
"project_urls": {
"Documentation": "https://pyslurmutils.readthedocs.io/",
"Homepage": "https://gitlab.esrf.fr/workflow/pyslurmutils/",
"Source": "https://gitlab.esrf.fr/workflow/pyslurmutils/",
"Tracker": "https://gitlab.esrf.fr/workflow/pyslurmutils/issues/"
},
"split_keywords": [],
"urls": [
{
"comment_text": "",
"digests": {
"blake2b_256": "d7a49f226eab1c6fd54698793e49fb66550dc2c7a784689f8e25340f158f39e8",
"md5": "26576312244a5b3c9c7898ea712eabb8",
"sha256": "c5e5b9c73e18334ec124fe0ab0de84082baed650cf2a8e4a2018ddefb52313bf"
},
"downloads": -1,
"filename": "pyslurmutils-0.1.2.tar.gz",
"has_sig": false,
"md5_digest": "26576312244a5b3c9c7898ea712eabb8",
"packagetype": "sdist",
"python_version": "source",
"requires_python": ">=3.7",
"size": 20326,
"upload_time": "2023-11-28T23:36:15",
"upload_time_iso_8601": "2023-11-28T23:36:15.734690Z",
"url": "https://files.pythonhosted.org/packages/d7/a4/9f226eab1c6fd54698793e49fb66550dc2c7a784689f8e25340f158f39e8/pyslurmutils-0.1.2.tar.gz",
"yanked": false,
"yanked_reason": null
}
],
"upload_time": "2023-11-28 23:36:15",
"github": false,
"gitlab": false,
"bitbucket": false,
"codeberg": false,
"lcname": "pyslurmutils"
}