scientific_workflow/
lib.rs1#![cfg_attr(feature = "macros", doc = include_str!("unit-authoring.md"))]
15#![deny(missing_docs, rustdoc::broken_intra_doc_links)]
16
17extern crate self as scientific_workflow;
18
19#[cfg(test)]
20#[cfg(feature = "runtime")]
21mod composition;
22#[cfg(feature = "runtime")]
23mod error;
24#[cfg(test)]
25#[cfg(feature = "runtime")]
26mod test_support;
27
28#[cfg(feature = "runtime")]
29pub mod config;
30#[cfg(feature = "runtime")]
31pub mod observation;
32#[cfg(feature = "runtime")]
33pub mod persistence;
34#[cfg(feature = "runtime")]
35pub mod prelude;
36#[cfg(feature = "runtime")]
37mod runtime;
38#[cfg(feature = "runtime")]
39pub use runtime::RuntimeError;
40#[cfg(feature = "runtime")]
41pub mod artifact;
42#[cfg(feature = "runtime")]
43pub mod campaign;
44#[cfg(feature = "runtime")]
45mod engine;
46#[cfg(feature = "runtime")]
47pub mod provenance;
48#[cfg(feature = "runtime")]
49pub mod registry;
50#[cfg(feature = "runtime")]
51pub mod seal;
52#[cfg(feature = "runtime")]
53pub mod state;
54#[cfg(feature = "runtime")]
55mod storage;
56#[cfg(feature = "runtime")]
57pub mod study;
58#[cfg(feature = "runtime")]
59pub mod task;
60#[cfg(feature = "runtime")]
61mod workspace;
62#[cfg(feature = "runtime")]
63pub use engine::RunHandle;
64
65#[cfg(feature = "runtime")]
66pub use error::WorkflowError;
67#[cfg(feature = "macros")]
68pub use scientific_workflow_macros::execution_unit;
69#[cfg(feature = "runtime")]
70pub use task::{
71 ExecutionUnit, InitializationContext, MemberCompletion, MemberView, SeedError, UnitResult,
72};
73
74#[cfg(feature = "runtime")]
81pub fn run(project_root: &std::path::Path) -> Result<(), WorkflowError> {
82 engine::application(project_root)
83}
84
85#[cfg(feature = "runtime")]
87pub fn check(input: &std::path::Path) -> Result<CheckReport, WorkflowError> {
88 if input.join("campaign.json").is_file() {
89 let plan = campaign::CampaignPlan::load(input)?;
90 plan.check()?;
91 return Ok(CheckReport {
92 kind: "campaign".into(),
93 studies: plan.studies().map(str::to_owned).collect(),
94 tasks: None,
95 threads: None,
96 });
97 }
98 let study = study::StudyPlan::load(input)?;
99 runtime::check_prerequisites(&study)?;
100 Ok(CheckReport {
101 kind: "study".into(),
102 studies: vec!["study".into()],
103 tasks: Some(study.plan_summary().phases().map(|p| p.tasks().len()).sum()),
104 threads: Some(study.threads()),
105 })
106}
107#[derive(Clone, Debug, serde::Serialize, serde::Deserialize)]
109#[cfg(feature = "runtime")]
110pub struct CheckReport {
111 pub kind: String,
113 pub studies: Vec<String>,
115 pub tasks: Option<usize>,
117 pub threads: Option<usize>,
119}
120
121#[cfg(feature = "runtime")]
123pub fn start(input: &std::path::Path) -> Result<RunHandle, WorkflowError> {
124 engine::start(input)
125}
126
127#[cfg(feature = "runtime")]
129pub fn open_run(
130 location: &artifact::StorageLocation,
131 id: &str,
132) -> std::io::Result<artifact::RunArchive> {
133 artifact::RunArchive::open(location, id)
134}
135
136#[doc(hidden)]
141#[cfg(feature = "runtime")]
142pub mod __private {
143 pub use crate::task::ExecutionUnitRegistration;
144 pub use inventory;
145}
146
147#[cfg(feature = "runtime")]
150pub fn seal_run(
151 location: &artifact::StorageLocation,
152 id: &str,
153 workspace: &std::path::Path,
154 reproducer: Option<&dyn seal::ReproductionRunner>,
155) -> std::io::Result<seal::SealReport> {
156 seal::execute(location, id, workspace, reproducer)
157}
158
159#[cfg(feature = "runtime")]
162pub fn reproduce_run(
163 location: &artifact::StorageLocation,
164 id: &str,
165 workspace: &std::path::Path,
166) -> std::io::Result<seal::ReproductionEvidence> {
167 use seal::ReproductionRunner;
168 engine::CapturedReproducer {
169 workspace: workspace.into(),
170 }
171 .reproduce(&open_run(location, id)?)
172}
173
174#[cfg(feature = "runtime")]
176pub fn seal_run_with_reproduction(
177 location: &artifact::StorageLocation,
178 id: &str,
179 workspace: &std::path::Path,
180) -> std::io::Result<seal::SealReport> {
181 let runner = engine::CapturedReproducer {
182 workspace: workspace.join("reproduction-check"),
183 };
184 seal::execute(location, id, workspace, Some(&runner))
185}
186
187#[cfg(feature = "client")]
189pub mod client;
190#[cfg(feature = "protocol")]
192pub mod protocol;
193#[cfg(feature = "client")]
194pub use client::RunClient;
195#[cfg(feature = "python")]
196mod python;