pub mod create_job;
pub mod step_dependency_graph;
pub mod step_param_space;
use std::collections::HashMap;
use indexmap::IndexMap;
use openjd_expr::format_string::FormatString;
use openjd_expr::symbol_table::SerializedSymbolTable;
use openjd_expr::ExprValue;
use openjd_expr::RangeExpr;
use serde::{Deserialize, Serialize};
use crate::types::{EndOfLine, FileType};
use crate::template::RangeConstraint;
use crate::types::JobParameterType;
#[derive(Debug, Clone, Serialize)]
#[serde(rename_all = "camelCase")]
pub struct Job {
pub name: String,
pub description: Option<String>,
pub extensions: Option<Vec<crate::types::ModelExtension>>,
pub parameters: IndexMap<String, JobParameter>,
pub steps: Vec<Step>,
pub job_environments: Option<Vec<Environment>>,
}
#[derive(Debug, Clone, Serialize)]
#[serde(rename_all = "camelCase")]
pub struct JobParameter {
pub name: String,
pub param_type: JobParameterType,
pub value: ExprValue,
}
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(rename_all = "camelCase")]
pub struct Step {
pub name: String,
pub description: Option<String>,
pub script: StepScript,
pub step_environments: Option<Vec<Environment>>,
pub parameter_space: Option<StepParameterSpace>,
pub host_requirements: Option<HostRequirements>,
pub dependencies: Option<Vec<StepDependency>>,
#[serde(rename = "resolvedSymTab", skip_serializing_if = "Option::is_none")]
pub resolved_symtab: Option<SerializedSymbolTable>,
}
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(rename_all = "camelCase")]
pub struct StepScript {
pub let_bindings: Option<Vec<String>>,
pub actions: StepActions,
pub embedded_files: Option<Vec<EmbeddedFile>>,
}
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(rename_all = "camelCase")]
pub struct StepActions {
pub on_run: Action,
}
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(rename_all = "camelCase")]
pub struct Action {
pub command: FormatString,
pub args: Option<Vec<FormatString>>,
pub timeout: Option<FormatString>,
pub cancelation: Option<CancelationMode>,
}
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(rename_all = "camelCase")]
pub struct Environment {
pub name: String,
pub description: Option<String>,
pub script: Option<EnvironmentScript>,
pub variables: Option<HashMap<String, FormatString>>,
#[serde(rename = "resolvedSymTab", skip_serializing_if = "Option::is_none")]
pub resolved_symtab: Option<SerializedSymbolTable>,
}
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(rename_all = "camelCase")]
pub struct EnvironmentScript {
pub let_bindings: Option<Vec<String>>,
pub actions: EnvironmentActions,
pub embedded_files: Option<Vec<EmbeddedFile>>,
}
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(rename_all = "camelCase")]
pub struct EnvironmentActions {
pub on_enter: Option<Action>,
pub on_exit: Option<Action>,
}
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(rename_all = "camelCase")]
pub struct EmbeddedFile {
pub name: String,
#[serde(alias = "type")]
pub file_type: FileType,
pub filename: Option<FormatString>,
pub data: Option<FormatString>,
pub runnable: Option<bool>,
pub end_of_line: Option<EndOfLine>,
}
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(tag = "mode", rename_all = "SCREAMING_SNAKE_CASE", deny_unknown_fields)]
pub enum CancelationMode {
Terminate,
#[serde(rename_all = "camelCase")]
NotifyThenTerminate {
notify_period_in_seconds: Option<FormatString>,
},
}
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(rename_all = "camelCase")]
pub struct StepParameterSpace {
pub task_parameter_definitions: IndexMap<String, TaskParameter>,
pub combination: Option<String>,
}
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(rename_all = "camelCase")]
pub enum TaskParameter {
Int {
range: TaskParamRange<i64>,
chunks: Option<ResolvedChunks>,
},
Float {
range: Vec<f64>,
},
String {
range: Vec<String>,
},
Path {
range: Vec<String>,
},
ChunkInt {
range: TaskParamRange<i64>,
chunks: ResolvedChunks,
},
}
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(
rename_all = "camelCase",
bound(deserialize = "T: serde::de::DeserializeOwned")
)]
pub enum TaskParamRange<T: Serialize> {
List(Vec<T>),
RangeExpr(RangeExpr),
}
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(rename_all = "camelCase")]
pub struct ResolvedChunks {
pub default_task_count: usize,
pub target_runtime_seconds: Option<usize>,
pub range_constraint: RangeConstraint,
}
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(rename_all = "camelCase")]
pub struct HostRequirements {
pub amounts: Option<Vec<AmountRequirement>>,
pub attributes: Option<Vec<AttributeRequirement>>,
}
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(rename_all = "camelCase")]
pub struct AmountRequirement {
pub name: String,
pub min: Option<f64>,
pub max: Option<f64>,
}
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(rename_all = "camelCase")]
pub struct AttributeRequirement {
pub name: String,
pub any_of: Option<Vec<String>>,
pub all_of: Option<Vec<String>>,
}
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(rename_all = "camelCase")]
pub struct StepDependency {
pub depends_on: String,
}