Class: OodCore::Job::Factory
- Inherits:
-
Object
- Object
- OodCore::Job::Factory
- Defined in:
- lib/ood_core/job/factory.rb,
lib/ood_core/job/adapters/ccq.rb,
lib/ood_core/job/adapters/lsf.rb,
lib/ood_core/job/adapters/sge.rb,
lib/ood_core/job/adapters/slurm.rb,
lib/ood_core/job/adapters/pbspro.rb,
lib/ood_core/job/adapters/torque.rb,
lib/ood_core/job/adapters/systemd.rb,
lib/ood_core/job/adapters/kubernetes.rb,
lib/ood_core/job/adapters/linux_host.rb,
lib/ood_core/job/adapters/fujitsu_tcs.rb
Overview
A factory that builds job adapter objects from a configuration.
Class Method Summary collapse
-
.build(config) ⇒ Adapter
Build a job adapter from a configuration.
-
.build_ccq(config) ⇒ Object
Build the Cloudy Cluster adapter from a configuration.
-
.build_fujitsu_tcs(config) ⇒ Object
Build the Fujitsu TCS (Technical Computing Suite) adapter from a configuration.
- .build_kubernetes(config) ⇒ Object
-
.build_linux_host(config) ⇒ Object
Build the LinuxHost adapter from a configuration.
-
.build_lsf(config) ⇒ Object
Build the Lsf adapter from a configuration.
-
.build_pbspro(config) ⇒ Object
Build the PBS Pro adapter from a configuration.
-
.build_sge(config) ⇒ Object
Build the Sun Grid Engine adapter from a configuration.
-
.build_slurm(config) ⇒ Object
Build the Slurm adapter from a configuration.
-
.build_systemd(config) ⇒ Object
Build the LinuxSystemd adapter from a configuration.
-
.build_torque(config) ⇒ Object
Build the Torque adapter from a configuration.
Class Method Details
.build(config) ⇒ Adapter
Build a job adapter from a configuration
16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 |
# 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_ccq(config) ⇒ Object
Build the Cloudy Cluster adapter from a configuration
17 18 19 |
# File 'lib/ood_core/job/adapters/ccq.rb', line 17 def self.build_ccq(config) Adapters::CCQ.new(config.to_h.symbolize_keys) end |
.build_fujitsu_tcs(config) ⇒ Object
Build the Fujitsu TCS (Technical Computing Suite) adapter from a configuration
16 17 18 19 20 21 22 23 |
# File 'lib/ood_core/job/adapters/fujitsu_tcs.rb', line 16 def self.build_fujitsu_tcs(config) c = config.to_h.symbolize_keys bin = c.fetch(:bin, nil) bin_overrides = c.fetch(:bin_overrides, {}) working_dir = c.fetch(:working_dir, nil) fujitsu_tcs = Adapters::Fujitsu_TCS::Batch.new(bin: bin, bin_overrides: bin_overrides, working_dir: working_dir) Adapters::Fujitsu_TCS.new(fujitsu_tcs: fujitsu_tcs) end |
.build_kubernetes(config) ⇒ Object
9 10 11 12 |
# 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_linux_host(config) ⇒ Object
Build the LinuxHost adapter from a configuration
23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 |
# 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_lsf(config) ⇒ Object
Build the Lsf adapter from a configuration
18 19 20 21 |
# 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_pbspro(config) ⇒ Object
Build the PBS Pro adapter from a configuration
19 20 21 22 23 24 25 26 27 28 29 |
# 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_sge(config) ⇒ Object
Build the Sun Grid Engine adapter from a configuration
18 19 20 21 |
# 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_slurm(config) ⇒ Object
Build the Slurm adapter from a configuration
20 21 22 23 24 25 26 27 28 29 30 |
# File 'lib/ood_core/job/adapters/slurm.rb', line 20 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_systemd(config) ⇒ Object
Build the LinuxSystemd adapter from a configuration
18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 |
# File 'lib/ood_core/job/adapters/systemd.rb', line 18 def self.build_systemd(config) c = config.to_h.symbolize_keys debug = c.fetch(:debug, false) max_timeout = c.fetch(:max_timeout, nil) ssh_hosts = c.fetch(:ssh_hosts, [c[:submit_host]]) strict_host_checking = c.fetch(:strict_host_checking, true) submit_host = c[:submit_host] Adapters::LinuxSystemd.new( ssh_hosts: ssh_hosts, launcher: Adapters::LinuxSystemd::Launcher.new( debug: debug, max_timeout: max_timeout, ssh_hosts: ssh_hosts, strict_host_checking: strict_host_checking, submit_host: submit_host, ) ) end |
.build_torque(config) ⇒ Object
Build the Torque adapter from a configuration
17 18 19 20 21 22 23 24 25 26 |
# 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 |