slurmconv

package
v1.0.0-alpha1 Latest Latest
Warning

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

Go to latest
Published: Nov 13, 2026 License: Apache-2.0 Imports: 6 Imported by: 0 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Index

Constants

This section is empty.

Variables

View Source
var InputTypes = []string{"STRING", "INTEGER", "FLOAT", "BOOLEAN", "FILE", "FILE_LIST", "DIRECTORY"}

InputTypes are the template input types a run section can reference.

Functions

func Diff

func Diff(original, rendered string) string

Diff is a unified line diff with two lines of context; empty when the texts match.

func ParseWallTime

func ParseWallTime(v string) (int64, error)

ParseWallTime converts any sbatch --time form to whole minutes, rounding seconds up.

func Placeholder

func Placeholder(name, typ string) string

Placeholder is the pongo2 expression a run section uses for an input of the given type.

func Render

func Render(c *Conversion) string

Render writes the conversion back out as an sbatch script, in the order Airavata writes directives.

func ShortFlag

func ShortFlag(long string) (string, bool)

ShortFlag returns the single-letter form of a long option, if sbatch has one.

Types

type AppliedInput

type AppliedInput struct {
	Name        string `json:"name"`
	Type        string `json:"type"`
	Description string `json:"description,omitempty"`
	Default     string `json:"default"`
	Occurrences int    `json:"occurrences"`
	Placeholder string `json:"placeholder"`
	Note        string `json:"note,omitempty"`
}

func ApplyInputs

func ApplyInputs(c *Conversion, in []InputSuggestion) ([]AppliedInput, error)

ApplyInputs turns hard-coded literals of the original body into template inputs, replacing any earlier application.

type ArrayRange

type ArrayRange struct {
	Start int `json:"start"`
	End   int `json:"end"`
	Step  int `json:"step"`
}

type ArraySpec

type ArraySpec struct {
	Raw    string       `json:"raw"`
	Ranges []ArrayRange `json:"ranges"`
	Limit  int          `json:"limit,omitempty"`
}

ArraySpec is a parsed --array value.

func (*ArraySpec) Indices

func (a *ArraySpec) Indices() []int

Indices expands the ranges in order.

type Container

type Container struct {
	Runtime string `json:"runtime"`
	Image   string `json:"image"`
	Command string `json:"command,omitempty"`
	Line    int    `json:"line"`
}

type Conversion

type Conversion struct {
	JobConfig    JobConfig             `json:"jobConfig"`
	Partition    string                `json:"partition,omitempty"`
	RunSection   string                `json:"runSection"`
	Shebang      string                `json:"shebang,omitempty"`
	Mapped       []Option              `json:"mapped"`
	Replaced     []Option              `json:"replaced"`
	Unsupported  []Option              `json:"unsupported"`
	Array        *ArraySpec            `json:"array,omitempty"`
	Dependencies []Dependency          `json:"dependencies,omitempty"`
	Software     []SoftwareRequirement `json:"software,omitempty"`
	Containers   []Container           `json:"containers,omitempty"`
	Registrable  bool                  `json:"registrable"`
	Problems     []string              `json:"problems,omitempty"`
	Notes        []string              `json:"notes,omitempty"`
	// contains filtered or unexported fields
}

func Convert

func Convert(s *Script) *Conversion

Convert maps a parsed script onto the Airavata deployment model.

func (*Conversion) Segments

func (c *Conversion) Segments() []Segment

Segments returns the run section split into literal text and input references.

type Dependency

type Dependency struct {
	Type   string   `json:"type"`
	JobIDs []string `json:"jobIds,omitempty"`
	AnyOf  bool     `json:"anyOf,omitempty"`
}

Dependency is one clause of --dependency; AnyOf is set when clauses are joined with '?'.

type InputSuggestion

type InputSuggestion struct {
	Name        string `json:"name"`
	Type        string `json:"type"`
	Literal     string `json:"literal"`
	Description string `json:"description,omitempty"`
}

type JobConfig

type JobConfig struct {
	WallTimeMinutes int64   `json:"wallTimeMinutes"`
	Allocation      string  `json:"allocation"`
	Cpus            *int32  `json:"cpus,omitempty"`
	Nodes           *int32  `json:"nodes,omitempty"`
	Ntasks          *int32  `json:"ntasks,omitempty"`
	NtasksPerNode   *int32  `json:"ntasksPerNode,omitempty"`
	CpusPerTask     *int32  `json:"cpusPerTask,omitempty"`
	Gpus            *int32  `json:"gpus,omitempty"`
	GpusPerNode     *int32  `json:"gpusPerNode,omitempty"`
	Mem             *string `json:"mem,omitempty"`
	MemPerCpu       *string `json:"memPerCpu,omitempty"`
	MemPerGpu       *string `json:"memPerGpu,omitempty"`
	CpusPerGpu      *string `json:"cpusPerGpu,omitempty"`
	Gres            *string `json:"gres,omitempty"`
	Constraints     *string `json:"constraints,omitempty"`
	Qos             *string `json:"qos,omitempty"`
}

JobConfig mirrors the API's batch job config fields.

type Option

type Option struct {
	Name     string `json:"name"`
	Value    string `json:"value,omitempty"`
	HasValue bool   `json:"hasValue"`
	Line     int    `json:"line"`
	Raw      string `json:"raw"`
	Flag     string `json:"flag"`
	Unknown  bool   `json:"unknown,omitempty"`
}

Option is one sbatch directive option, normalised to its long name.

type Script

type Script struct {
	Shebang string   `json:"shebang,omitempty"`
	Options []Option `json:"options"`
	Body    string   `json:"body"`
	// Ignored lists lines of #SBATCH directives after the first command, which sbatch ignores.
	Ignored []int `json:"ignored,omitempty"`
}

Script is a parsed sbatch script.

func Parse

func Parse(text string) (*Script, error)

Parse reads the #SBATCH directives of the leading comment block, the way sbatch does.

type Segment

type Segment struct {
	Text      string `json:"text,omitempty"`
	Input     string `json:"input,omitempty"`
	InputType string `json:"inputType,omitempty"`
}

Segment is a piece of the run section: literal shell text, or a reference to an input.

type SoftwareRequirement

type SoftwareRequirement struct {
	Manager string `json:"manager"`
	Name    string `json:"name"`
	Version string `json:"version,omitempty"`
	Line    int    `json:"line"`
}

Jump to

Keyboard shortcuts

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