MCPcopy Index your code
hub / github.com/SlinkyProject/slurm-client

github.com/SlinkyProject/slurm-client @v1.2.0

Chat with this repo
repository ↗ · DeepWiki ↗ · release v1.2.0 ↗ · + Follow
6,069 symbols 12,674 edges 172 files 4,455 documented · 73% updated 2d ago★ 33
What it actually does AI analysis from the code graph — generated when you open this
loading…
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.

Extension points exported contracts — how you extend this code

Reader (Interface)
Reader knows how to read and list Slurm objects. [7 implementers]
pkg/client/interfaces.go
Object (Interface)
(no doc) [28 implementers]
pkg/object/object.go
Writer (Interface)
Writer knows how to create, delete, and update Slurm objects. [5 implementers]
pkg/client/interfaces.go
ObjectList (Interface)
(no doc) [28 implementers]
pkg/object/object.go
Client (Interface)
Client knows how to perform CRUD operations on Slurm objects. [5 implementers]
pkg/client/interfaces.go
Informers (Interface)
Informers knows how to create or fetch informers for different Objects. It's safe to call GetInformer from multiple thre [5 …
pkg/client/interfaces.go
Informer (Interface)
Informer - informer allows you interact with the underlying informer. [2 implementers]
pkg/client/interfaces.go

Core symbols most depended-on inside this repo

Get
called by 575
pkg/client/interfaces.go
Run
called by 333
pkg/client/interfaces.go
NewClient
called by 247
pkg/client/api/v0045/interceptor/interceptor.go
NewClient
called by 247
pkg/client/api/v0044/interceptor/interceptor.go
NewClient
called by 232
pkg/client/api/v0043/interceptor/interceptor.go
NewClient
called by 217
pkg/client/api/v0042/interceptor/interceptor.go
NewFakeClient
called by 103
pkg/client/api/v0045/fake/client.go
NewFakeClient
called by 103
pkg/client/api/v0044/fake/client.go

Shape

Method 3,685
Struct 1,048
Function 1,009
TypeAlias 260
Interface 58
FuncType 9

Languages

Go100%

Modules by API surface

api/v0045/slurm.gen.go1,102 symbols
api/v0044/slurm.gen.go977 symbols
api/v0043/slurm.gen.go918 symbols
api/v0042/slurm.gen.go874 symbols
pkg/client/api/v0045/fake/client.go101 symbols
pkg/client/api/v0045/interceptor/interceptor.go98 symbols
pkg/client/api/v0045/interceptor/interceptor_test.go96 symbols
pkg/client/api/v0044/fake/client.go93 symbols
pkg/client/api/v0044/interceptor/interceptor.go90 symbols
pkg/client/api/v0044/interceptor/interceptor_test.go88 symbols
pkg/client/api/v0043/fake/client.go86 symbols
pkg/client/api/v0043/interceptor/interceptor.go83 symbols

For agents

$ claude mcp add slurm-client \
  -- python -m otcore.mcp_server <graph>

⬇ download graph artifact

Ask about this repo answers extend the page