Module: Libis::Workflow::Base::Run
Overview
Base module for all workflow runs. It is created by an associated workflow when the workflow is executed.
This module lacks the implementation for the data attributes. It functions as an interface that describes the common functionality regardless of the storage implementation. These attributes require some implementation:
-
start_date: [Time] the timestamp of the execution of the run
-
job: [Object] a reference to the Job this Run belongs to
-
id: [String] (Optional) a unique run number
Note that ::Libis::Workflow::Base::WorkItem is a parent module and therefore requires implementation of the attributes of that module too.
A simple in-memory implementation can be found in ::Libis::Workflow::Run
Instance Attribute Summary collapse
-
#action ⇒ Object
Returns the value of attribute action.
-
#tasks ⇒ Object
Returns the value of attribute tasks.
Instance Method Summary collapse
- #logger ⇒ Object
- #name ⇒ Object
- #namepath ⇒ Object
- #names ⇒ Object
-
#run(action = :run) ⇒ Object
Execute the workflow.
- #work_dir ⇒ Object
- #workflow ⇒ Object
Methods included from WorkItem
#add_item, #each, #get_item_list, #get_items, #get_parent, #get_root, #get_run, #label, #label=, #labelpath, #labels, #name=, #save, #save!, #size, #to_filename, #to_s
Methods included from Logging
Methods included from Status
#check_status, #compare_status, #set_status, #status, #status_label, #status_progress, #status_text
Instance Attribute Details
#action ⇒ Object
Returns the value of attribute action.
26 27 28 |
# File 'lib/libis/workflow/base/run.rb', line 26 def action @action end |
#tasks ⇒ Object
Returns the value of attribute tasks.
26 27 28 |
# File 'lib/libis/workflow/base/run.rb', line 26 def tasks @tasks end |
Instance Method Details
#logger ⇒ Object
51 52 53 |
# File 'lib/libis/workflow/base/run.rb', line 51 def logger self.properties['logger'] || self.job.logger rescue ::Libis::Workflow::Config.logger end |
#name ⇒ Object
35 36 37 |
# File 'lib/libis/workflow/base/run.rb', line 35 def name self.job.run_name(self.start_date) end |
#namepath ⇒ Object
43 44 45 |
# File 'lib/libis/workflow/base/run.rb', line 43 def namepath self.name end |
#names ⇒ Object
39 40 41 |
# File 'lib/libis/workflow/base/run.rb', line 39 def names Array.new end |
#run(action = :run) ⇒ Object
Execute the workflow.
The action parameter defines how the execution of the tasks will behave:
- With the default :run action each task will be executed regardsless how the task performed on the item
previously.
- When using the :retry action a task will not perform on an item if it was successful the last time. This
allows you to retry a run when an temporary error (e.g. asynchronous wait or halt) occured.
64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 |
# File 'lib/libis/workflow/base/run.rb', line 64 def run(action = :run) self.action = action unless action == :retry self.start_date = Time.now self. = workflow.prepare_input(self.) end self.tasks = workflow.tasks configure_tasks self. self.save! runner = Libis::Workflow::TaskRunner.new nil self.tasks.each do |task| runner << task end runner.run self end |
#work_dir ⇒ Object
28 29 30 31 32 33 |
# File 'lib/libis/workflow/base/run.rb', line 28 def work_dir # noinspection RubyResolve dir = File.join(Libis::Workflow::Config.workdir, self.name) FileUtils.mkpath dir unless Dir.exist?(dir) dir end |
#workflow ⇒ Object
47 48 49 |
# File 'lib/libis/workflow/base/run.rb', line 47 def workflow self.job.workflow end |