https://github.com/slinkyproject/slurm-client
OpenAPI Golang client library for Slurm REST API. A Slinky project.
https://github.com/slinkyproject/slurm-client
golang openapi openapi-client openapi-codegen rest-client schedmd slinky slurm slurm-workload-manager
Last synced: 14 days ago
JSON representation
OpenAPI Golang client library for Slurm REST API. A Slinky project.
- Host: GitHub
- URL: https://github.com/slinkyproject/slurm-client
- Owner: SlinkyProject
- Created: 2024-11-01T20:20:45.000Z (about 1 year ago)
- Default Branch: main
- Last Pushed: 2025-12-04T20:46:39.000Z (about 2 months ago)
- Last Synced: 2025-12-08T04:51:49.617Z (about 2 months ago)
- Topics: golang, openapi, openapi-client, openapi-codegen, rest-client, schedmd, slinky, slurm, slurm-workload-manager
- Language: Go
- Homepage: https://slinky.ai/
- Size: 1.13 MB
- Stars: 18
- Watchers: 4
- Forks: 2
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
- License: LICENSES/Apache-2.0.txt
Awesome Lists containing this project
README
# Slurm Client
[OpenAPI] Golang client library for [Slurm REST API][rest-api]. A [Slinky]
project.
## Table of Contents
- [Slurm Client](#slurm-client)
- [Table of Contents](#table-of-contents)
- [Overview](#overview)
- [Features](#features)
- [Limitations](#limitations)
- [Installation](#installation)
- [Usage](#usage)
- [Create](#create)
- [Delete](#delete)
- [Get](#get)
- [List](#list)
- [Update](#update)
- [Upgrades](#upgrades)
- [0.X Releases](#0x-releases)
- [Support and Development](#support-and-development)
- [License](#license)
## Overview
This repository provides generated [slurmrestd][rest-api] endpoints for Golang
clients, and client wrapper library inspired by the [controller-runtime] client
for Kubernetes.
## Features
- **Multiple Slurm Versions**: can interact with multiple versions of Slurm.
- **Caching**: client-side caching mechanism to reduce number of server calls.
## Limitations
Currently, the client wrapper implements a limited amount of Slurm endpoints,
specifically only Node and Job endpoints. The number of implemented endpoints
may expand in the future, by request or community efforts.
- **Slurm Version**: >=
[24.05](https://www.schedmd.com/slurm-version-24-05-0-is-now-available/)
## Installation
```bash
go get -v github.com/SlinkyProject/slurm-client
```
### Usage
Create a Slurm client handle.
```golang
config := &client.Config{
Server: "http://:6820",
AuthToken: "<`auth/jwt` token>",
}
slurmClient, err := client.NewClient(config)
if err != nil {
return err
}
```
Start Slurm client cache.
```golang
ctx := context.Background()
go slurmClient.Start(ctx)
```
#### Create
Create Slurm resources via client handle.
```golang
// Create job via V0044 endpoint
jobInfo := &types.V0044JobInfo{}
req := v0044.V0044JobSubmitReq{
Job: &v0044.V0044JobDescMsg{
CurrentWorkingDirectory: ptr.To("/tmp"),
Environment: &v0044.V0044StringArray{
"PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin",
},
Script: ptr.To("#!/usr/bin/env bash\nsleep 30"),
},
}
if err := slurmClient.Create(ctx, jobInfo, req); err != nil {
return err
}
```
```golang
// Create job via V0043 endpoint
jobInfo := &types.V0043JobInfo{}
req := v0043.V0043JobSubmitReq{
Job: &v0043.V0043JobDescMsg{
CurrentWorkingDirectory: ptr.To("/tmp"),
Environment: &v0043.V0043StringArray{
"PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin",
},
Script: ptr.To("#!/usr/bin/env bash\nsleep 30"),
},
}
if err := slurmClient.Create(ctx, jobInfo, req); err != nil {
return err
}
```
#### Delete
Delete Slurm resource via client handle.
```golang
// Delete job via V0044 endpoint
jobInfo := &types.V0044JobInfo{
V0044JobInfo: v0044.V0044JobInfo{
JobId: ptr.To("1"),
},
}
if err := slurmClient.Delete(ctx, jobInfo); err != nil {
return err
}
```
```golang
// Delete job via V0043 endpoint
jobInfo := &types.V0043JobInfo{
V0043JobInfo: v0043.V0043JobInfo{
JobId: ptr.To("1"),
},
}
if err := slurmClient.Delete(ctx, jobInfo); err != nil {
return err
}
```
#### Get
Get Slurm resource via client handle.
```golang
// Fetch node via V0044 endpoint
node := &types.V0044Node{}
key := object.ObjectKey("node-0")
if err := slurmClient.Get(ctx, key, node); err != nil {
return err
}
```
```golang
// Fetch node via V0043 endpoint
node := &types.V0043Node{}
key := object.ObjectKey("node-0")
if err := slurmClient.Get(ctx, key, node); err != nil {
return err
}
```
#### List
List Slurm resources via client handle.
```golang
// Fetch list of nodes via V0044 endpoint
nodeList := &types.V0044NodeList{}
if err := slurmClient.List(ctx, nodeList); err != nil {
return err
}
```
```golang
// Fetch list of nodes via V0043 endpoint
nodeList := &types.V0043NodeList{}
if err := slurmClient.List(ctx, nodeList); err != nil {
return err
}
```
#### Update
Update Slurm resource via client handle.
```golang
// Update job via V0044 endpoint
jobInfo := &types.V0044JobInfo{}
req := &v0044.V0044JobDescMsg{
Comment: ptr.To("updated comment")
}
if err := slurmClient.Update(ctx, jobInfo, req); err != nil {
return err
}
```
```golang
// Update job via V0043 endpoint
jobInfo := &types.V0043JobInfo{}
req := &v0043.V0043JobDescMsg{
Comment: ptr.To("updated comment")
}
if err := slurmClient.Update(ctx, jobInfo, req); err != nil {
return err
}
```
## Upgrades
```bash
go get -u github.com/SlinkyProject/slurm-client
```
### 0.X Releases
The source tree may evolve more aggressively during these release versions, so
upgrades may require updated paths in addition to the version.
## Support and Development
Feature requests, code contributions, and bug reports are welcome!
Github/Gitlab submitted issues and PRs/MRs are handled on a best effort basis.
The SchedMD official issue tracker is at .
To schedule a demo or simply to reach out, please
[contact SchedMD][contact-schedmd].
## License
Copyright (C) SchedMD LLC.
Licensed under the
[Apache License, Version 2.0](http://www.apache.org/licenses/LICENSE-2.0) you
may not use project except in compliance with the license.
Unless required by applicable law or agreed to in writing, software distributed
under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR
CONDITIONS OF ANY KIND, either express or implied. See the License for the
specific language governing permissions and limitations under the License.
[contact-schedmd]: https://www.schedmd.com/slurm-resources/contact-schedmd/
[controller-runtime]: https://github.com/kubernetes-sigs/controller-runtime
[openapi]: https://www.openapis.org/
[rest-api]: https://slurm.schedmd.com/rest_api.html
[slinky]: https://slinky.ai/