use std::sync::Arc;
use antecedent_core::{
Diagnostic, DiagnosticKind, DiagnosticSeverity, KernelSelection, ParallelTaskSpec,
PhysicalExecutionPlanRecord,
};
#[must_use]
pub fn mark_python_callback_plan(
mut record: PhysicalExecutionPlanRecord,
region: &str,
) -> (PhysicalExecutionPlanRecord, Diagnostic) {
record.worker_threads = 0;
record.task_schedule =
Arc::from([ParallelTaskSpec { dimension: Arc::from("serial"), units: 1 }]);
record.expected_python_crossings = record.expected_python_crossings.saturating_add(1);
let mut kernels = record.kernels.as_ref().to_vec();
kernels.push((Arc::from(format!("python.callback.{region}")), KernelSelection::Scalar));
record.kernels = Arc::from(kernels);
let diagnostic = Diagnostic::new(
"exec.python_callback_serial",
DiagnosticKind::Execution,
DiagnosticSeverity::Info,
format!("Python callback region `{region}` forced serial execution"),
);
(record, diagnostic)
}