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: GetTargetPathForAIExpansion + 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
24        let target_dir = self.get_target_dir();
25
26        trace!("In target_dir={}, calculating unseen inputs:", target_dir.display());
27
28        let mut unseen: Vec<T> = Vec::new();
29
30        for tok in inputs {
31
32            let target_path = tok.target_path_for_ai_json_expansion(
33                &target_dir,
34                expected_content_type
35            );
36
37            trace!("target_path={:?} for token={}", target_path, tok);
38
39            if !target_path.exists() {
40
41                if let Some(similar_path) = self.find_similar_target_path(&target_path) {
42
43                    warn!(
44                        "Skipping token '{}': target path '{}' is similar to existing '{}'.",
45                        tok.name(),
46                        target_path.display(),
47                        similar_path.display()
48                    );
49
50                    // Skip this token
51                    continue;
52                }
53
54                unseen.push(tok.clone());
55            }
56        }
57
58        info!("Unseen input tokens calculated: {:#?}",unseen);
59
60        unseen
61    }
62}
63
64// tests for this are in batch-mode-batch-workspace