Class: Step::Scheduler
- Inherits:
-
Object
- Object
- Step::Scheduler
- Defined in:
- lib/rbbt/workflow/schedule.rb
Instance Attribute Summary collapse
-
#cpus ⇒ Object
Returns the value of attribute cpus.
-
#dep_jobs ⇒ Object
Returns the value of attribute dep_jobs.
-
#job_deps ⇒ Object
Returns the value of attribute job_deps.
-
#jobps ⇒ Object
Returns the value of attribute jobps.
-
#jobs ⇒ Object
Returns the value of attribute jobs.
Instance Method Summary collapse
-
#initialize(jobs, cpus) ⇒ Scheduler
constructor
A new instance of Scheduler.
- #next ⇒ Object
- #ready ⇒ Object
- #used ⇒ Object
Constructor Details
#initialize(jobs, cpus) ⇒ Scheduler
42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 |
# File 'lib/rbbt/workflow/schedule.rb', line 42 def initialize(jobs, cpus) @jobs = jobs @cpus = cpus @job_deps = {} with_deps = jobs.dup @dep_jobs = {} @job_deps = {} @jobps = {} @missing = Set.new while with_deps.any? job = with_deps.pop @jobps[job.path] = job @missing << job.path unless job.done? jdeps = job.dependencies jdeps += job.inputs.flatten.select{|i| Step === i} jdeps.reject!{|dep| dep.done? } @job_deps[job.path] = [] jdeps.each do |dep| #next if dep.done? @dep_jobs[dep.path] ||= [] @job_deps[job.path] << dep.path @dep_jobs[dep.path] << job.path with_deps << dep unless @job_deps.include? dep.path end end def ready @job_deps.select do |jobp,deps| (@missing & deps).empty? end.collect{|jobp,deps| jobp} end def used iii @dep_jobs @dep_jobs.select do |dep,jobs| iif [dep, @missing.to_a, jobs] (@missing & jobs).empty? end.keys end def next priorities = {} @jobs.each do |job| priorities[job.path] = 1 end @missing.each do |jobp| end ready.first end end |
Instance Attribute Details
#cpus ⇒ Object
Returns the value of attribute cpus.
41 42 43 |
# File 'lib/rbbt/workflow/schedule.rb', line 41 def cpus @cpus end |
#dep_jobs ⇒ Object
Returns the value of attribute dep_jobs.
41 42 43 |
# File 'lib/rbbt/workflow/schedule.rb', line 41 def dep_jobs @dep_jobs end |
#job_deps ⇒ Object
Returns the value of attribute job_deps.
41 42 43 |
# File 'lib/rbbt/workflow/schedule.rb', line 41 def job_deps @job_deps end |
#jobps ⇒ Object
Returns the value of attribute jobps.
41 42 43 |
# File 'lib/rbbt/workflow/schedule.rb', line 41 def jobps @jobps end |
#jobs ⇒ Object
Returns the value of attribute jobs.
41 42 43 |
# File 'lib/rbbt/workflow/schedule.rb', line 41 def jobs @jobs end |
Instance Method Details
#next ⇒ Object
86 87 88 89 90 91 92 93 94 95 96 |
# File 'lib/rbbt/workflow/schedule.rb', line 86 def next priorities = {} @jobs.each do |job| priorities[job.path] = 1 end @missing.each do |jobp| end ready.first end |
#ready ⇒ Object
72 73 74 75 76 |
# File 'lib/rbbt/workflow/schedule.rb', line 72 def ready @job_deps.select do |jobp,deps| (@missing & deps).empty? end.collect{|jobp,deps| jobp} end |
#used ⇒ Object
78 79 80 81 82 83 84 |
# File 'lib/rbbt/workflow/schedule.rb', line 78 def used iii @dep_jobs @dep_jobs.select do |dep,jobs| iif [dep, @missing.to_a, jobs] (@missing & jobs).empty? end.keys end |