batch_mode_batch_workspace_interface/
calculate_unseen.rs

1// ---------------- [ File: batch-mode-batch-workspace-interface/src/calculate_unseen.rs ]
2crate::ix!();
3
4pub trait CalculateUnseenInputs<T> {
5    fn calculate_unseen_inputs(
6        &self, 
7        inputs: &[T], 
8        expected_content_type: &ExpectedContentType
9    ) -> Vec<T>;
10}
11
12impl<W,T> CalculateUnseenInputs<T> for W 
13where W: FindSimilarTargetPath + GetTargetDir,
14      T: GetTargetPathForAIExpansionFromSeed + Clone + Debug + Display + Named,
15{
16    /// Internal helper. Identifies newly seen tokens.
17    fn calculate_unseen_inputs(
18        &self, 
19        inputs:                &[T], 
20        expected_content_type: &ExpectedContentType
21
22    ) -> Vec<T> {
23        let target_dir = self.get_target_dir();
24        trace!("In target_dir={}, calculating unseen inputs:", target_dir.display());
25        let mut unseen: Vec<T> = Vec::new();
26        for tok in inputs {
27            let target_path = tok.target_path_for_ai_json_expansion_from_seed(
28                &target_dir,
29                expected_content_type
30            );
31            trace!("target_path={:?} for token={}", target_path, tok);
32            if !target_path.exists() {
33                if let Some(similar_path) = self.find_similar_target_path(&target_path) {
34                    warn!(
35                        "Skipping token '{}': target path '{}' is similar to existing '{}'.",
36                        tok.name(),
37                        target_path.display(),
38                        similar_path.display()
39                    );
40                    // Skip this token
41                    continue;
42                }
43                unseen.push(tok.clone());
44            }
45        }
46        info!("Unseen input tokens calculated: {:#?}",unseen);
47        unseen
48    }
49}
50
51// tests for this are in batch-mode-batch-workspace