Expand description
§Atento Core - Workflow Automation Engine
Atento Core is a powerful Rust library for defining and executing sequential workflow automation with multi-interpreter support, robust error handling, and advanced variable passing capabilities.
§Key Features
- Multi-Interpreter Support: Execute scripts in Bash, Batch,
PowerShell, Pwsh, and Python - Sequential Execution: Guaranteed step order with dependency management
- Variable Passing: Global parameters and step-to-step output chaining
- Type Safety: Strongly typed parameters (string, int, float, bool, datetime)
- Cross-Platform: Works reliably on Linux, macOS, and Windows
- Secure Execution: Temporary file isolation and proper permission handling
§Quick Start
use atento_core;
fn main() -> Result<(), Box<dyn std::error::Error>> {
// Run a workflow from a YAML file
atento_core::run("workflow.yaml")?;
Ok(())
}§Workflow Structure
Workflows are defined in YAML format with the following structure:
name: "Example Workflow"
timeout: 300 # Global timeout in seconds
parameters:
project_name:
type: string
value: "my-project"
build_number:
type: int
value: 42
steps:
setup:
name: "Setup Environment"
type: script::bash # Interpreter: bash, batch, powershell, pwsh, python
timeout: 60
script: |
echo "Setting up {{ inputs.project }}"
echo "BUILD_DIR=/tmp/build-{{ inputs.build_num }}"
inputs:
project:
ref: parameters.project_name
build_num:
ref: parameters.build_number
outputs:
build_directory:
pattern: "BUILD_DIR=(.*)"
build:
name: "Build Project"
type: script::python
script: |
import os
build_dir = "{{ inputs.build_dir }}"
print(f"Building in {build_dir}")
print("BUILD_SUCCESS=true")
inputs:
build_dir:
ref: steps.setup.outputs.build_directory
outputs:
status:
pattern: "BUILD_SUCCESS=(.*)"
results:
build_status:
ref: steps.build.outputs.status
workspace:
ref: steps.setup.outputs.build_directory§Supported Interpreters
| Type | Description | Platform |
|---|---|---|
script::bash | Bash shell scripts | Unix/Linux/macOS |
script::batch | Windows batch files | Windows |
script::powershell | PowerShell (Windows) | Windows |
script::pwsh | PowerShell Core | Cross-platform |
script::python | Python scripts | Cross-platform |
§Variable Substitution
Use {{ inputs.variable_name }} syntax in scripts to substitute input values:
script: |
echo "Processing {{ inputs.filename }} in {{ inputs.directory }}"
cp "{{ inputs.source }}" "{{ inputs.destination }}"§Output Extraction
Capture values from command output using regex patterns with capture groups:
outputs:
version:
pattern: "Version: ([0-9]+\.[0-9]+\.[0-9]+)"
status:
pattern: "Status: (SUCCESS|FAILED)"§Error Handling
The library provides comprehensive error handling for:
- File I/O operations
- YAML parsing errors
- Workflow validation failures
- Script execution timeouts
- Type conversion errors
- Unresolved variable references
§Example Usage
// Load and validate a workflow
let yaml_content = std::fs::read_to_string(“workflow.yaml”)?;
let workflow: Workflow = serde_yaml::from_str(&yaml_content)?;
// Validate the workflow structure
workflow.validate()?;
// Execute the workflow
let result = workflow.run()?;
// Serialize results to JSON
let json_output = serde_json::to_string_pretty(&result)?;
println!(“{}”, json_output);
§Ok::<(), Box>(())
Structs§
Enums§
- Atento
Error - The main error type for the Atento workflow engine.
- Data
Type - Represents the data type of a parameter, input, or output value.
Functions§
- run
- Runs a workflow from a YAML file.
Type Aliases§
- Result
- Type alias for Results using
AtentoError