Class: OodCore::Job::Adapters::Coder

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

Overview

The adapter class for Coder.

Defined Under Namespace

Classes: Batch, CoderJobInfo

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods inherited from OodCore::Job::Adapter

#accounts, #cluster_info, #directive_prefix, #hold, #info_all_each, #info_historic, #info_where_owner, #info_where_owner_each, #job_name_illegal_chars, #nodes, #queues, #release, #sanitize_job_name, #supports_job_dependencies?

Constructor Details

#initialize(batch) ⇒ Coder

Returns a new instance of Coder.



48
49
50
# File 'lib/ood_core/job/adapters/coder.rb', line 48

def initialize(batch)
  @batch = batch
end

Instance Attribute Details

#batch ⇒ Object (readonly)

Returns the value of attribute batch.



47
48
49
# File 'lib/ood_core/job/adapters/coder.rb', line 47

def batch
  @batch
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



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

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

#info(id) ⇒ Info

This method is abstract.

Subclass is expected to implement #info

Retrieve job info from the resource manager

Parameters:

  • id (#to_s) —

    the id of the job

Returns:

  • (Info) —

    information describing submitted job

Raises:

  • (NotImplementedError) —

    if subclass did not define #info



108
109
110
111
112
# File 'lib/ood_core/job/adapters/coder.rb', line 108

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

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

This method is abstract.

Subclass is expected to implement #info_all

Retrieve info for all jobs from the resource manager

Parameters:

  • attrs (Array<symbol>) (defaults to: nil) —

    defaults to nil (and all attrs are provided) This array specifies only attrs you want, in addition to id and status. If an array, the Info object that is returned to you is not guarenteed to have a value for any attr besides the ones specified and id and status.

    For certain adapters this may speed up the response since adapters can get by without populating the entire Info object

Returns:

  • (Array<Info>) —

    information describing submitted jobs

Raises:

  • (NotImplementedError) —

    if subclass did not define #info_all



92
93
94
# File 'lib/ood_core/job/adapters/coder.rb', line 92

def info_all(attrs: nil)
  []
end

#status(id) ⇒ Status

This method is abstract.

Subclass is expected to implement #status

Note:

Optimized slightly over retrieving complete job information from server

Retrieve job status from resource manager

Parameters:

  • id (#to_s) —

    the id of the job

Returns:

Raises:

  • (NotImplementedError) —

    if subclass did not define #status



120
121
122
# File 'lib/ood_core/job/adapters/coder.rb', line 120

def status(id)
  info(id)["job"]["status"]
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



73
74
75
76
77
78
79
# File 'lib/ood_core/job/adapters/coder.rb', line 73

def submit(script, after: [], afterok: [], afternotok: [], afterany: [])
  raise ArgumentError, 'Must specify the script' if script.nil?
  validate_native(script, Hash, required: true)
  batch.submit(script)
rescue Batch::Error => e
  raise JobAdapterError, e.message
end

#supports_job_arrays? ⇒ Boolean

Whether the adapter supports job arrays

Returns:

  • (Boolean) —
    • assumes true; but can be overridden by adapters that explicitly do not


99
100
101
# File 'lib/ood_core/job/adapters/coder.rb', line 99

def supports_job_arrays?
  false
end