Expand description
Configuration-driven scientific workflow execution.
An ordinary application defines registered task::basic::ScientificModel
implementations, writes study.json, config/state.json, and the central
config/parameters.json, then calls run with the project root. Workflow infers task
instances, phase membership, identities, output paths, progress boundaries,
recording lifecycle, and execution mechanics.
§Ordinary use
use std::path::Path;
fn main() -> Result<(), scientific_workflow::WorkflowError> {
scientific_workflow::run(Path::new("."))
}A model carries its stable manifest key at its implementation:
use serde::Deserialize;
use scientific_workflow::prelude::basic::*;
#[derive(Deserialize)]
struct Constants { initial: u64, steps: u64 }
struct Model { state: SystemState, target_iteration: u64 }
#[scientific_workflow::model("example")]
impl ScientificModel for Model {
type Constants = Constants;
fn initialize(constants: Constants, schema: &SystemStateSchema) -> TaskResult<Self> {
let mut state = schema.create_empty_state(StateTime::from_iteration(0));
state.initialize_payload("population", constants.initial)?;
state.initialize_payload("cumulative_births", 0_u64)?;
Ok(Self {
state,
target_iteration: constants.steps,
})
}
fn state(&self) -> &SystemState { &self.state }
fn is_complete(&self) -> bool {
self.state.time().iteration() >= self.target_iteration
}
fn target_iteration(&self) -> Option<u64> { Some(self.target_iteration) }
fn step(&mut self) -> TaskResult {
let (population, cumulative_births) = self
.state
.borrow_payloads_mut::<(u64, u64)>(
("population", "cumulative_births"),
)?;
*population += 1;
*cumulative_births += 1;
self.state.advance_time(None)?;
Ok(())
}
}§Ownership boundaries
configalone reads and parses project JSON and supplies typed model constants.studycomposes parsed declarations, state semantics, and compiled model registrations into immutable, output-free intent.runtimeconsumes a completed Study and owns active execution/output.taskowns the model contract and automatic observation boundaries.stateowns canonical scientific state and schema.observationowns scientific observation meaning, not persistence mechanics.persistenceowns automatic durable output and verified reading.uiowns automatic terminal presentation of Runtime facts.errorowns complete-workflow Study/Runtime error composition.
The crate-level run facade performs the sole ordinary transition from
project root to Study to Runtime. Study is the ultimate coordinator of
declared intent; runtime is the ultimate coordinator of active execution.
Advanced integrations use each module’s advanced scope. prelude only
aggregates those module-owned APIs and crate conveniences.
Persistence write construction and output allocation are internal and are not available to model authors.
This crate is pre-1.0 test software and may make coordinated API changes.
Re-exports§
pub use error::basic::WorkflowError;
Modules§
- config
- Central parsing and resolution of declarative Workflow project parameters.
- error
- Complete-workflow error composition.
- observation
- Application-defined scientific observation.
- persistence
- Automatic durable model recordings and program workspaces.
- prelude
- Centrally aggregated import scopes.
- runtime
- Execution of a completely validated immutable study.
- state
- Template-defined scientific state and ordered in-memory state collections.
- study
- Effect-free compilation of project declarations into executable scientific intent.
- task
- Generic application workloads behind one uniform runtime definition.
- ui
- Automatic presentation of runtime-owned execution progress.
Functions§
- run
- Loads, preflights, and executes the Workflow project rooted at
project_root.
Attribute Macros§
- model
- Registers one
ScientificModelimplementation under a stable manifest key.