Class: OodCore::Job::Adapters::Sge

Inherits:
OodCore::Job::Adapter show all
Defined in:
lib/ood_core/job/adapters/sge.rb

Overview

The adpater class for Grid Engine (GE) flavors like Sun Grid Engine.

Defined Under Namespace

Classes: Batch, Error, Helper

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods inherited from OodCore::Job::Adapter

#accounts, #cluster_info, #info_all_each, #info_where_owner_each, #job_name_illegal_chars, #nodes, #queues, #sanitize_job_name, #supports_job_arrays?

Constructor Details

#initialize(batch:) ⇒ Sge

Returns a new instance of Sge.

Parameters:



57
58
59
60
# File 'lib/ood_core/job/adapters/sge.rb', line 57

def initialize(batch:)
  @batch = batch
  @helper = Sge::Helper.new
end

Instance Attribute Details

#binPathname (readonly)

The path to the Sun Grid Engine client installation binaries

Examples:

For Sun Grid Engine 8.0.1

my_batch.bin.to_s #=> "/u/systems/UGE8.0.1vm/bin/lx-amd64/

Returns:

  • (Pathname)

    path to SGE binaries



50
51
52
# File 'lib/ood_core/job/adapters/sge.rb', line 50

def bin
  @bin
end

#clusterString? (readonly)

The cluster of the Sun Grid Engine batch server

Examples:

UCLA’s hoffman2 cluster

my_batch.cluster #=> "hoffman2"

Returns:

  • (String, nil)

    the cluster name



38
39
40
# File 'lib/ood_core/job/adapters/sge.rb', line 38

def cluster
  @cluster
end

#confPathname? (readonly)

The path to the Sun Grid Engine configuration file

Examples:

For Sun Grid Engine 8.0.1

my_batch.conf.to_s #=> "/u/systems/UGE8.0.1vm/h2.conf

Returns:

  • (Pathname, nil)

    path to gridengine conf



44
45
46
# File 'lib/ood_core/job/adapters/sge.rb', line 44

def conf
  @conf
end

Instance Method Details

#delete(id) ⇒ void

This method returns an undefined value.

Delete the submitted job

Parameters:

  • id (#to_s)

    the id of the job

Raises:



157
158
159
160
161
# File 'lib/ood_core/job/adapters/sge.rb', line 157

def delete(id)
  @batch.delete(id.to_s)
rescue Batch::Error => e
  raise JobAdapterError, e.message
end

#directive_prefixObject



163
164
165
# File 'lib/ood_core/job/adapters/sge.rb', line 163

def directive_prefix
  '#$'
end

#hold(id) ⇒ void

This method returns an undefined value.

Put the submitted job on hold

Parameters:

  • id (#to_s)

    the id of the job

Raises:



137
138
139
140
141
# File 'lib/ood_core/job/adapters/sge.rb', line 137

def hold(id)
  @batch.hold(id.to_s)
rescue Batch::Error => e
  raise JobAdapterError, e.message
end

#info(id) ⇒ Info

Retrieve job info from the resource manager

Parameters:

  • id (#to_s)

    the id of the job

Returns:

  • (Info)

    information describing submitted job

Raises:



117
118
119
120
121
# File 'lib/ood_core/job/adapters/sge.rb', line 117

def info(id)
  @batch.get_info_enqueued_job(id)
rescue Batch::Error => e
  raise JobAdapterError, e.message
end

#info_all(attrs: nil) ⇒ Array<Info>

Retrieve info for all jobs from the resource manager

Returns:

  • (Array<Info>)

    information describing submitted jobs



95
96
97
98
99
# File 'lib/ood_core/job/adapters/sge.rb', line 95

def info_all(attrs: nil)
  @batch.get_all(owner: '*')
rescue Batch::Error => e
  raise JobAdapterError, e.message
end

#info_where_owner(owner, attrs: nil) ⇒ Array<Info>

Retrieve info for all jobs for a given owner or owners from the resource manager

Parameters:

  • owner (#to_s, Array<#to_s>)

    the owner(s) of the jobs

Returns:

  • (Array<Info>)

    information describing submitted jobs

Raises:



106
107
108
109
110
111
# File 'lib/ood_core/job/adapters/sge.rb', line 106

def info_where_owner(owner, attrs: nil)
  owner = Array.wrap(owner).map(&:to_s).join(',')
  @batch.get_all(owner: owner)
rescue Batch::Error => e
  raise JobAdapterError, e.message
end

#release(id) ⇒ void

This method returns an undefined value.

Release the job that is on hold

Parameters:

  • id (#to_s)

    the id of the job

Raises:



147
148
149
150
151
# File 'lib/ood_core/job/adapters/sge.rb', line 147

def release(id)
  @batch.release(id.to_s)
rescue Batch::Error => e
  raise JobAdapterError, e.message
end

#status(id) ⇒ Status

Retrieve job status from resource manager

Parameters:

  • id (#to_s)

    the id of the job

Returns:

Raises:

  • (JobAdapterError)

    if something goes wrong getting the status of a job



127
128
129
130
131
# File 'lib/ood_core/job/adapters/sge.rb', line 127

def status(id)
  info(id).status
rescue Batch::Error => e
  raise JobAdapterError, e.message
end

#submit(script, after: [], afterok: [], afternotok: [], afterany: []) ⇒ String

Submit a job with the attributes defined in the job template instance

Examples:

Submit job template to cluster

solver_id = job_adapter.submit(solver_script)
#=> "1234.server"

Submit job that depends on previous job

post_id = job_adapter.submit(
  post_script,
  afterok: solver_id
)
#=> "1235.server"

Parameters:

  • script (Script)

    script object that describes the script and attributes for the submitted job

  • after (#to_s, Array<#to_s>) (defaults to: [])

    this job may be scheduled for execution at any point after dependent jobs have started execution

  • afterok (#to_s, Array<#to_s>) (defaults to: [])

    this job may be scheduled for execution only after dependent jobs have terminated with no errors

  • afternotok (#to_s, Array<#to_s>) (defaults to: [])

    this job may be scheduled for execution only after dependent jobs have terminated with errors

  • afterany (#to_s, Array<#to_s>) (defaults to: [])

    this job may be scheduled for execution after dependent jobs have terminated

Returns:

  • (String)

    the job id returned after successfully submitting a job

Raises:



84
85
86
87
88
89
90
91
# File 'lib/ood_core/job/adapters/sge.rb', line 84

def submit(script, after: [], afterok: [], afternotok: [], afterany: [])
  # SGE supports jod dependencies on job completion
  args = @helper.batch_submit_args(script, after: after, afterok: afterok, afternotok: afternotok, afterany: afterany)

  @batch.submit(script.content, args)
rescue Batch::Error => e
  raise JobAdapterError, e.message
end