Class: OodCore::Job::Adapters::Flux::Batch Private

Inherits:
Object
  • Object
show all
Defined in:
lib/ood_core/job/adapters/flux/batch.rb

Overview

This class is part of a private API. You should avoid using this class if possible, as it may be removed or be changed in the future.

Object used for simplified communication with Flux: runs the flux CLI, locally or over ssh on a submit host, and parses its JSON.

Written in the compact form, like the LSF and SGE adapters' batch.rb, so this file never reopens class Flux. It is required from inside the Flux class body, after the class exists.

Defined Under Namespace

Classes: Error

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(bin: nil, bin_overrides: {}, submit_host: "", strict_host_checking: true, flux_uri: nil) ⇒ Batch

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Returns a new instance of Batch.



40
41
42
43
44
45
46
# File 'lib/ood_core/job/adapters/flux/batch.rb', line 40

def initialize(bin: nil, bin_overrides: {}, submit_host: "", strict_host_checking: true, flux_uri: nil)
  @bin                  = Pathname.new(bin.to_s)
  @bin_overrides        = bin_overrides
  @submit_host          = submit_host.to_s
  @strict_host_checking = strict_host_checking
  @flux_uri             = flux_uri && flux_uri.to_s
end

Instance Attribute Details

#bin ⇒ Pathname? (readonly)

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

The path to the Flux client installation binaries

Returns:

  • (Pathname, nil)


16
17
18
# File 'lib/ood_core/job/adapters/flux/batch.rb', line 16

def bin
  @bin
end

#bin_overrides ⇒ Object (readonly)

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Optional overrides for Flux client executables

Examples:

{'flux' => '/usr/local/bin/flux'}


22
23
24
# File 'lib/ood_core/job/adapters/flux/batch.rb', line 22

def bin_overrides
  @bin_overrides
end

#flux_uri ⇒ String? (readonly)

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

URI of the Flux instance, or nil for the system instance

Returns:

  • (String, nil)


34
35
36
# File 'lib/ood_core/job/adapters/flux/batch.rb', line 34

def flux_uri
  @flux_uri
end

#strict_host_checking ⇒ Bool (readonly)

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Whether to use strict host checking when ssh to submit_host

Returns:

  • (Bool)


30
31
32
# File 'lib/ood_core/job/adapters/flux/batch.rb', line 30

def strict_host_checking
  @strict_host_checking
end

#submit_host ⇒ String (readonly)

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

The login node where commands are run via ssh

Returns:

  • (String)


26
27
28
# File 'lib/ood_core/job/adapters/flux/batch.rb', line 26

def submit_host
  @submit_host
end

Instance Method Details

#delete_job(id) ⇒ Object

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.



82
83
84
# File 'lib/ood_core/job/adapters/flux/batch.rb', line 82

def delete_job(id)
  call("cancel", id.to_s)
end

#get_job(id) ⇒ Hash

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Get the json description of one job

Parameters:

  • id (#to_s) —

    the job id

Returns:

  • (Hash) —

    the job, with symbol keys



60
61
62
63
# File 'lib/ood_core/job/adapters/flux/batch.rb', line 60

def get_job(id)
  out = call("jobs", "--json", id.to_s)
  parse_jobs(out).first
end

#get_jobs(owner: nil) ⇒ Array<Hash>

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Get the json descriptions of active jobs

Parameters:

  • owner (#to_s, nil) (defaults to: nil) —

    limit to this user; nil means all users

Returns:

  • (Array<Hash>) —

    the jobs, with symbol keys



68
69
70
71
72
# File 'lib/ood_core/job/adapters/flux/batch.rb', line 68

def get_jobs(owner: nil)
  args = owner.nil? ? ["-A"] : ["-u", owner.to_s]
  out = call("jobs", "--json", *args)
  parse_jobs(out)
end

#hold_job(id) ⇒ Object

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.



74
75
76
# File 'lib/ood_core/job/adapters/flux/batch.rb', line 74

def hold_job(id)
  call("job", "urgency", id.to_s, "hold")
end

#release_job(id) ⇒ Object

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.



78
79
80
# File 'lib/ood_core/job/adapters/flux/batch.rb', line 78

def release_job(id)
  call("job", "urgency", id.to_s, "default")
end

#submit_string(str, args: []) ⇒ String

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Submit a batch script on stdin

Parameters:

  • str (#to_s) —

    the script content

  • args (Array<#to_s>) (defaults to: []) —

    arguments to flux batch

Returns:

  • (String) —

    the job id, in decimal



52
53
54
55
# File 'lib/ood_core/job/adapters/flux/batch.rb', line 52

def submit_string(str, args: [])
  out = call("batch", *args, stdin: str.to_s)
  OodCore::Job::Adapters::Flux::JobId.to_decimal(out)
end