class Croupier::Task

Overview

A Task is an object that may generate output

It has a Proc which is executed when the task is run It can have zero or more inputs It has zero or more outputs Tasks are connected by dependencies, where one task's output is another's input

Included Modules

Defined in:

task.cr

Constructors

Instance Method Summary

Constructor Detail

def self.new(ctx : YAML::ParseContext, node : YAML::Nodes::Node) #

[View source]
def self.new(outputs : Array(String) = [] of String, inputs : Array(String) = [] of String, no_save : Bool = false, id : String | Nil = nil, always_run : Bool = false, mergeable : Bool = true, mutex : String | Nil = nil, master_task : Bool = false, &block : TaskProc) #

[View source]
def self.new(outputs : Array(String) = [] of String, inputs : Array(String) = [] of String, proc : TaskProc | Nil = nil, no_save : Bool = false, id : String | Nil = nil, always_run : Bool = false, mergeable : Bool = true, master_task : Bool = false) #

[View source]
def self.new(output : String | Nil = nil, inputs : Array(String) = [] of String, no_save : Bool = false, id : String | Nil = nil, always_run : Bool = false, mergeable : Bool = true, mutex : String | Nil = nil, master_task : Bool = false, &block : TaskProc) #

[View source]
def self.new(output : String | Nil = nil, inputs : Array(String) = [] of String, proc : TaskProc | Nil = nil, no_save : Bool = false, id : String | Nil = nil, always_run : Bool = false, mergeable : Bool = true, master_task : Bool = false) #

Create a task with zero or one outputs. Overload for convenience.


[View source]

Instance Method Detail

def always_run=(always_run : Bool) #

[View source]
def always_run? : Bool #

[View source]
def id : String #

[View source]
def id=(id : String) #

[View source]
def inputs : Set(String) #

The task's inputs: files, task ids or kv:// keys it depends on.

Treat as read-only while tasks are running: mutating it from task procs on parallel workers races and, even done safely, cannot affect the current run (wave planning happens before workers start). Use TaskManager.add_input, which is guarded and invalidates the caches a later run needs.


[View source]
def inputs=(inputs : Set(String)) #

The task's inputs: files, task ids or kv:// keys it depends on.

Treat as read-only while tasks are running: mutating it from task procs on parallel workers races and, even done safely, cannot affect the current run (wave planning happens before workers start). Use TaskManager.add_input, which is guarded and invalidates the caches a later run needs.


[View source]
def keys #

Under what keys should this task be registered with TaskManager


[View source]
def mark_dependency_fresh(input : String) #

Mark that a dependency (input) is known to be unchanged. Recomputes staleness considering ALL inputs together (thread-safe).


[View source]
def master_task=(master_task : Bool) #

[View source]
def master_task? : Bool #

[View source]
def merge(other : Task) #

Merge two tasks.

inputs and outputs are joined procs of the second task are added to the 1st


[View source]
def mergeable=(mergeable : Bool) #

[View source]
def mergeable? : Bool #

[View source]
def mutex : String | Nil #

[View source]
def mutex=(name : String | Nil) #

Setting a mutex also registers it: Task#run locks mutexes through the manager, and an unregistered one would fail at run time (long after the declaration that named it)


[View source]
def no_save=(no_save : Bool) #

[View source]
def no_save? : Bool #

[View source]
def outputs : Array(String) #

[View source]
def outputs=(outputs : Array(String)) #

[View source]
def outputs_changed=(outputs_changed : Bool) #

[View source]
def outputs_changed? : Bool #

[View source]
def procs : Array(TaskProc) #

[View source]
def procs=(procs : Array(TaskProc)) #

[View source]
def ready?(run_all = false) #

A task is ready if it is stale and not waiting for anything


[View source]
def run #

Executes the proc for the task


[View source]
def stale : Bool | Nil #

Tri-state staleness property: nil=unknown, true=stale, false=fresh.


[View source]
def stale=(value : Bool | Nil) #

[View source]
def stale? : Bool #

[View source]
def subtask_ids : Set(String) #

[View source]
def subtask_ids=(subtask_ids : Set(String)) #

[View source]
def to_s(io) #

[View source]
def waiting? : Bool #

Early-exit version of waiting_for.empty? used by ready?, so readiness checks stop at the first blocked input instead of building the whole array.


[View source]
def waiting_for #

All inputs that are not satisfied yet.


[View source]