Class: OodCore::Job::Adapters::CCQ

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

Overview

The adapter class for the Cloudy Cluster product CCQ.

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods inherited from OodCore::Job::Adapter

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

Constructor Details

#initialize(config) ⇒ CCQ

Returns a new instance of CCQ.



32
33
34
35
36
37
38
39
# File 'lib/ood_core/job/adapters/ccq.rb', line 32

def initialize(config)
  @image = config.fetch(:image, nil)
  @cloud = config.fetch(:cloud, gcp_provider)
  @scheduler = config.fetch(:scheduler, nil)
  @bin = config.fetch(:bin, '/opt/CloudyCluster/srv/CCQ')
  @bin_overrides = config.fetch(:bin_overrides, {})
  @jobid_regex = config.fetch(:jobid_regex, "job id is: (?<job_id>\\d+) you")
end

Instance Attribute Details

#binObject (readonly)

Returns the value of attribute bin.



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

def bin
  @bin
end

#bin_overridesObject (readonly)

Returns the value of attribute bin_overrides.



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

def bin_overrides
  @bin_overrides
end

#cloudObject (readonly)

Returns the value of attribute cloud.



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

def cloud
  @cloud
end

#imageObject (readonly)

Returns the value of attribute image.



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

def image
  @image
end

#jobid_regexObject (readonly)

Returns the value of attribute jobid_regex.



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

def jobid_regex
  @jobid_regex
end

#schedulerObject (readonly)

Returns the value of attribute scheduler.



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

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



127
128
129
# File 'lib/ood_core/job/adapters/ccq.rb', line 127

def delete(id)
  call("ccqdel", args: [id])
end

#directive_prefixObject



131
132
133
# File 'lib/ood_core/job/adapters/ccq.rb', line 131

def directive_prefix
  '#CC'
end

#hold(_) ⇒ void

This method returns an undefined value.

This adapter does not implement hold and will always raise

an exception.

Parameters:

  • id (#to_s)

    the id of the job

Raises:



111
112
113
# File 'lib/ood_core/job/adapters/ccq.rb', line 111

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



85
86
87
88
89
90
91
92
93
94
95
96
# File 'lib/ood_core/job/adapters/ccq.rb', line 85

def info(id)
  args = []
  args.concat ["-s", scheduler] unless scheduler.nil?
  args.concat ["-ji", id]

  stat_output = call("ccqstat", args: args)

  # WARNING: code path differs here than info_all because the output
  # from ccqstat -ji $JOBID is much more data than just the 4
  # columns that ccqstat gives.
  info_from_ccqstat_extended(stat_output)
end

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

Retrieve info for all jobs from the resource manager

Returns:

  • (Array<Info>)

    information describing submitted jobs



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

def info_all(attrs: nil)
  args = []
  args.concat ["-s", scheduler] unless scheduler.nil?

  stat_output = call("ccqstat", args: args)
  info_from_ccqstat(stat_output)
end

#release(_) ⇒ void

This method returns an undefined value.

This adapter does not implement release and will always raise

an exception.

Parameters:

  • id (#to_s)

    the id of the job

Raises:



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

def release(_)
  raise NotImplementedError, "subclass did not define #release"
end

#status(id) ⇒ Status

Retrieve job status from resource manager

Parameters:

  • id (#to_s)

    the id of the job

Returns:

See Also:



102
103
104
# File 'lib/ood_core/job/adapters/ccq.rb', line 102

def status(id)
  info(id).status
end

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

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

Parameters:

  • script (Script)

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

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

    not used

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

    not used

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

    not used

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

    not used

Returns:

  • (String)

    the job id returned after successfully submitting a job

See Also:



51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
# File 'lib/ood_core/job/adapters/ccq.rb', line 51

def submit(script, after: [], afterok: [], afternotok: [], afterany: [])
  script_file = make_script_file(script.content)
  args = []

  # cluster configuration args
  args.concat ["-s", scheduler] unless scheduler.nil?
  args.concat [image_arg, image] unless image.nil?

  args.concat ["-o", script.output_path.to_s] unless script.output_path.nil?
  args.concat ["-e", script.error_path.to_s] unless script.error_path.nil?
  args.concat ["-tl", seconds_to_duration(script.wall_time)] unless script.wall_time.nil?
  args.concat ["-js", script_file.path.to_s]

  args.concat script.native if script.native

  output = call("ccqsub", args: args)
  parse_job_id_from_ccqsub(output)
ensure
  script_file.close
end