Class: OodCore::Job::Adapter Abstract

Inherits:
Object
  • Object
show all
Defined in:
lib/ood_core/job/adapter.rb

Overview

This class is abstract.

A class that handles the communication with a resource manager for submitting/statusing/holding/deleting jobs

Instance Method Summary collapse

Instance Method Details

#delete(id) ⇒ void

This method is abstract.

Subclass is expected to implement #delete

This method returns an undefined value.

Delete the submitted job

Parameters:

  • id (#to_s)

    the id of the job

Raises:

  • (NotImplementedError)

    if subclass did not define #delete



95
96
97
# File 'lib/ood_core/job/adapter.rb', line 95

def delete(id)
  raise NotImplementedError, "subclass did not define #delete"
end

#hold(id) ⇒ void

This method is abstract.

Subclass is expected to implement #hold

This method returns an undefined value.

Put the submitted job on hold

Parameters:

  • id (#to_s)

    the id of the job

Raises:

  • (NotImplementedError)

    if subclass did not define #hold



77
78
79
# File 'lib/ood_core/job/adapter.rb', line 77

def hold(id)
  raise NotImplementedError, "subclass did not define #hold"
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



58
59
60
# File 'lib/ood_core/job/adapter.rb', line 58

def info(id)
  raise NotImplementedError, "subclass did not define #info"
end

#info_allArray<Info>

This method is abstract.

Subclass is expected to implement #info_all

Retrieve info for all jobs from the resource manager

Returns:

  • (Array<Info>)

    information describing submitted jobs

Raises:

  • (NotImplementedError)

    if subclass did not define #info_all



40
41
42
# File 'lib/ood_core/job/adapter.rb', line 40

def info_all
  raise NotImplementedError, "subclass did not define #info_all"
end

#info_where_owner(owner) ⇒ 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



48
49
50
51
# File 'lib/ood_core/job/adapter.rb', line 48

def info_where_owner(owner)
  owner = Array.wrap(owner).map(&:to_s)
  info_all.select { |info| owner.include? info.job_owner }
end

#release(id) ⇒ void

This method is abstract.

Subclass is expected to implement #release

This method returns an undefined value.

Release the job that is on hold

Parameters:

  • id (#to_s)

    the id of the job

Raises:

  • (NotImplementedError)

    if subclass did not define #release



86
87
88
# File 'lib/ood_core/job/adapter.rb', line 86

def release(id)
  raise NotImplementedError, "subclass did not define #release"
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



68
69
70
# File 'lib/ood_core/job/adapter.rb', line 68

def status(id)
  raise NotImplementedError, "subclass did not define #status"
end

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

This method is abstract.

Subclass is expected to implement #submit

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:

  • (NotImplementedError)

    if subclass did not define #submit



32
33
34
# File 'lib/ood_core/job/adapter.rb', line 32

def submit(script, after: [], afterok: [], afternotok: [], afterany: [])
  raise NotImplementedError, "subclass did not define #submit"
end