slurm-client

module
v1.1.0-rc1 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Mar 12, 2026 License: Apache-2.0

README

Slurm Client

OpenAPI Golang client library for Slurm REST API. A Slinky project.

Table of Contents

Overview

This repository provides generated slurmrestd 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

Installation

go get -v github.com/SlinkyProject/slurm-client
Usage

Create a Slurm client handle.

config := &client.Config{
	Server:    "http://<host>:6820",
	AuthToken: "<`auth/jwt` token>",
}
slurmClient, err := client.NewClient(config)
if err != nil {
	return err
}

Start Slurm client cache.

ctx := context.Background()
go slurmClient.Start(ctx)
Create

Create Slurm resources via client handle.

// 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
}
// 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.

// 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
}
// 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.

// Fetch node via V0044 endpoint
node := &types.V0044Node{}
key := object.ObjectKey("node-0")
if err := slurmClient.Get(ctx, key, node); err != nil {
	return err
}
// 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.

// Fetch list of nodes via V0044 endpoint
nodeList := &types.V0044NodeList{}
if err := slurmClient.List(ctx, nodeList); err != nil {
	return err
}
// 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.

// 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
}
// 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

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 https://support.schedmd.com/.

To schedule a demo or simply to reach out, please contact SchedMD.

License

Copyright (C) SchedMD LLC.

Licensed under the Apache License, Version 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.

Directories

Path Synopsis
api
v0041
Package v0041 provides primitives to interact with the openapi HTTP API.
Package v0041 provides primitives to interact with the openapi HTTP API.
v0042
Package v0042 provides primitives to interact with the openapi HTTP API.
Package v0042 provides primitives to interact with the openapi HTTP API.
v0043
Package v0043 provides primitives to interact with the openapi HTTP API.
Package v0043 provides primitives to interact with the openapi HTTP API.
v0044
Package v0044 provides primitives to interact with the openapi HTTP API.
Package v0044 provides primitives to interact with the openapi HTTP API.
pkg

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL