Contents
Rule
Reactive Rule
Base R6 class for reactive production rules.
Details
Rule
Rules use a two-phase input model for performance:
- planning/scheduling phase (
inputs(),bind(),requirements()) works withResourceSpecobjects, not loaded resource payloads; - execution phase (
run()) receives materialized input values loaded by the execution engine worker just-in-time.
This avoids repeated scheduler-side loading of large resources (for example GWAS summary statistics) and reduces data copying across async workers.
Practical guidance:
- keep
requirements()based onoutput.specand bound specs/metadata; - if
bind()needs cached metadata (e.g. genome build), preferstore$load.meta()over fullstore$load(); - reserve heavy data access for
run().
Public fields
name — Character. Rule name.
Methods
Public methods
Rule$new()Rule$matches()Rule$inputs()Rule$bind()Rule$requirements()Rule$run()Rule$print()Rule$clone()
Method new()
Create a Rule base class
Usage
Rule$new(name)
Arguments
name — Character; rule name
Method matches()
Check if the rule can produce an output
Usage
Rule$matches(output.spec)
Arguments
output.spec — ResourceSpec
Returns
Logical
Method inputs()
Build inputs for an output
Usage
Rule$inputs(output.spec)
Arguments
output.spec — ResourceSpec
Returns
Named list of inputs (ResourceSpec or NULL)
Method bind()
Bind derived inputs.
Usage
Rule$bind(inputs, store, output.spec = NULL)
Arguments
inputs — Named list of inputs.
store — ResourceStore.
output.spec — Output specification being prepared.
Returns
Named list of inputs.
Method requirements()
Compute requirements
Usage
Rule$requirements(output.spec, inputs)
Arguments
output.spec — ResourceSpec
inputs — Named list of bound input specifications.
Returns
Named list with cores and memory (GiB, gibibytes -- the same unit as
ExecutionEngine$max.memory and workspace$config$max.memory). A value strictly
between 0 and 1 is rejected at task-ready time as an almost-certain unit error.
Method run()
Execute the rule
Usage
Rule$run(output.spec, inputs, logger = pg.logger())
Arguments
output.spec — ResourceSpec
inputs — Named list of materialized resource values loaded by the
execution engine worker.
logger — PolyGeniusLogger
Returns
List with data, meta, logs
Method print()
Print rule summary
Usage
Rule$print(...)
Arguments
... — Unused
Method clone()
The objects of this class are cloneable with this method.
Usage
Rule$clone(deep = FALSE)
Arguments
deep — Whether to make a deep clone.
See Also
Other engine-core:
ExecutionEngine,
ExecutionScheduler,
ResourceResolver(),
ResourceSpec,
ResourceSpecSet(),
RuleRegistry,
TaskExecutor(),
execute(),
resources.factory,
resources.type