class OodCore::Job::Factory
A factory that builds job adapter objects from a configuration.
Public Class Methods
Build a job adapter from a configuration @param config [#to_h] configuration describing job adapter @option config [#to_s] :adapter The job adapter to use @raise [AdapterNotSpecified] if no adapter is specified @raise [AdapterNotFound] if the specified adapter does not exist @return [Adapter] the job adapter object
# File lib/ood_core/job/factory.rb, line 16 def build(config) c = config.to_h.symbolize_keys adapter = c.fetch(:adapter) { raise AdapterNotSpecified, "job configuration does not specify adapter" }.to_s path_to_adapter = "ood_core/job/adapters/#{adapter}" begin require path_to_adapter rescue Gem::LoadError => e raise Gem::LoadError, "Specified '#{adapter}' for job adapter, but the gem is not loaded." rescue LoadError => e raise LoadError, "Could not load '#{adapter}'. Make sure that the job adapter in the configuration file is valid." end adapter_method = "build_#{adapter}" unless respond_to?(adapter_method) raise AdapterNotFound, "job configuration specifies nonexistent #{adapter} adapter" end send(adapter_method, c) end
Build the Cloudy Cluster
adapter from a configuration @param config [#to_h] the configuration for job adapter @option config [Object] :image (nil) The default VM image to use @option config [Object] :cloud (gcp) The cloud provider being used [gcp,aws] @option config [Object] :scheduler (nil) The name of the scheduler to use @option config [Object] :sge_root (nil) Path to SGE root, note that @option config [#to_h] :bin (nil) Path to CC client binaries @option config [#to_h] :bin_overrides ({}) Optional overrides to CC client executables
# File lib/ood_core/job/adapters/ccq.rb, line 17 def self.build_ccq(config) Adapters::CCQ.new(config.to_h.symbolize_keys) end
# File lib/ood_core/job/adapters/kubernetes.rb, line 9 def self.build_kubernetes(config) batch = Adapters::Kubernetes::Batch.new(config.to_h.symbolize_keys) Adapters::Kubernetes.new(batch) end
Build the LinuxHost adapter from a configuration @param config [#to_h] the configuration for job adapter @option config [Object] :contain (false) Pass `–contain` flag to Singularity; allows overriding bind mounts in singularity.conf @option config [Object] :debug (false) Use the adapter in a debug mode @option config [Object] :max_timeout (nil) The longest 'wall_clock' permissible @option config [Object] :singularity_bin ('/usr/bin/singularity') The path to the Singularity executable @option config [Object] :singularity_bindpath ('/etc,/media,/mnt,/opt,/srv,/usr,/var,/users') A comma delimited list of paths to bind between the host and the guest @option config [Object] :singularity_image The path to the Singularity image to use @option config [Object] :ssh_hosts (nil) The list of permissable hosts, defaults to :submit_host @option config [Object] :strict_host_checking (true) Set to false to disable strict host checking and updating the known_hosts file @option config [Object] :submit_host The SSH target to connect to, may be the head of a round-robin @option config [Object] :tmux_bin ('/usr/bin/tmux') The path to the Tmux executable
# File lib/ood_core/job/adapters/linux_host.rb, line 23 def self.build_linux_host(config) c = config.to_h.symbolize_keys contain = c.fetch(:contain, false) debug = c.fetch(:debug, false) max_timeout = c.fetch(:max_timeout, nil) singularity_bin = c.fetch(:singularity_bin, '/usr/bin/singularity') singularity_bindpath = c.fetch(:singularity_bindpath, '/etc,/media,/mnt,/opt,/srv,/usr,/var,/users') singularity_image = c[:singularity_image] ssh_hosts = c.fetch(:ssh_hosts, [c[:submit_host]]) strict_host_checking = c.fetch(:strict_host_checking, true) submit_host = c[:submit_host] tmux_bin = c.fetch(:tmux_bin, '/usr/bin/tmux') Adapters::LinuxHost.new( ssh_hosts: ssh_hosts, launcher: Adapters::LinuxHost::Launcher.new( contain: contain, debug: debug, max_timeout: max_timeout, singularity_bin: singularity_bin, singularity_bindpath: singularity_bindpath, # '/etc,/media,/mnt,/opt,/srv,/usr,/var,/users', singularity_image: singularity_image, ssh_hosts: ssh_hosts, strict_host_checking: strict_host_checking, submit_host: submit_host, tmux_bin: tmux_bin, ) ) end
Build the Lsf adapter from a configuration @param config [#to_h] the configuration for job adapter @option config [#to_s] :bindir ('') Path to lsf client bin dir @option config [#to_s] :libdir ('') Path to lsf client lib dir @option config [#to_s] :envdir ('') Path to lsf client conf dir @option config [#to_s] :serverdir ('') Path to lsf client etc dir @option config [#to_s] :cluster ('') name of cluster, if in multi-cluster mode @option config [#to_h] :bin_overrides ({}) Optional overrides to LSF client executables @option config [#to_s] :submit_host ('') Host to submit commands to
# File lib/ood_core/job/adapters/lsf.rb, line 18 def self.build_lsf(config) batch = Adapters::Lsf::Batch.new(config.to_h.symbolize_keys) Adapters::Lsf.new(batch: batch) end
Build the PBS Pro adapter from a configuration @param config [#to_h] the configuration for job adapter @option config [Object] :host (nil) The batch server host @option config [Object] :submit_host (“”) The login node where the job is submitted @option config [Object] :strict_host_checking (true) Whether to use strict host checking when ssh to submit_host @option config [Object] :exec (nil) Path to PBS Pro executables @option config [Object] :qstat_factor (nil) Deciding factor on how to
call qstat for a user
@option config [#to_h] :bin_overrides ({}) Optional overrides to PBS Pro client executables
# File lib/ood_core/job/adapters/pbspro.rb, line 19 def self.build_pbspro(config) c = config.to_h.compact.symbolize_keys host = c.fetch(:host, nil) submit_host = c.fetch(:submit_host, "") strict_host_checking = c.fetch(:strict_host_checking, true) pbs_exec = c.fetch(:exec, nil) qstat_factor = c.fetch(:qstat_factor, nil) bin_overrides = c.fetch(:bin_overrides, {}) pbspro = Adapters::PBSPro::Batch.new(host: host, submit_host: submit_host, strict_host_checking: strict_host_checking, pbs_exec: pbs_exec, bin_overrides: bin_overrides) Adapters::PBSPro.new(pbspro: pbspro, qstat_factor: qstat_factor) end
Build the Sun Grid Engine adapter from a configuration @param config [#to_h] the configuration for job adapter @option config [Object] :cluster (nil) The cluster to communicate with @option config [Object] :conf (nil) Path to the SGE conf @option config [Object] :bin (nil) Path to SGE client binaries @option config [Object] :sge_root (nil) Path to SGE root, note that @option config [#to_h] :bin_overrides ({}) Optional overrides to SGE client executables
this may be nil, but must be set to use the DRMAA API, and there is a severe performance penalty calling Sge#info without using DRMAA.
# File lib/ood_core/job/adapters/sge.rb, line 18 def self.build_sge(config) batch = Adapters::Sge::Batch.new(config.to_h.symbolize_keys) Adapters::Sge.new(batch: batch) end
Build the Slurm adapter from a configuration @param config [#to_h] the configuration for job adapter @option config [Object] :cluster (nil) The cluster to communicate with @option config [Object] :conf (nil) Path to the slurm conf @option config [Object] :bin (nil) Path to slurm client binaries @option config [#to_h] :bin_overrides ({}) Optional overrides to Slurm client executables @option config [Object] :submit_host (“”) Submit job on login node via ssh @option config [Object] :strict_host_checking (true) Whether to use strict host checking when ssh to submit_host
# File lib/ood_core/job/adapters/slurm.rb, line 19 def self.build_slurm(config) c = config.to_h.symbolize_keys cluster = c.fetch(:cluster, nil) conf = c.fetch(:conf, nil) bin = c.fetch(:bin, nil) bin_overrides = c.fetch(:bin_overrides, {}) submit_host = c.fetch(:submit_host, "") strict_host_checking = c.fetch(:strict_host_checking, true) slurm = Adapters::Slurm::Batch.new(cluster: cluster, conf: conf, bin: bin, bin_overrides: bin_overrides, submit_host: submit_host, strict_host_checking: strict_host_checking) Adapters::Slurm.new(slurm: slurm) end
Build the Torque adapter from a configuration @param config [#to_h] the configuration for job adapter @option config [#to_s] :host The batch server host @option config [#to_s] :submit_host The login node to submit the job via ssh @option config [#to_s] :lib ('') Path to torque client libraries @option config [#to_s] :bin ('') Path to torque client binaries @option config [#to_h] :custom_bin ({}) Optional overrides to Torque client executables
# File lib/ood_core/job/adapters/torque.rb, line 17 def self.build_torque(config) c = config.to_h.symbolize_keys host = c.fetch(:host) { raise ArgumentError, "No host specified. Missing argument: host" }.to_s submit_host = c.fetch(:submit_host, "").to_s lib = c.fetch(:lib, "").to_s bin = c.fetch(:bin, "").to_s custom_bin = c.fetch(:custom_bin, {}) pbs = Adapters::Torque::Batch.new(host: host, submit_host: submit_host, lib: lib, bin: bin, custom_bin: custom_bin) Adapters::Torque.new(pbs: pbs) end