Skip to content

Commit 4b464a8

Browse files
committed
ci: fix python lint env and resolve ontology clippy regressions
1 parent 52564f6 commit 4b464a8

4 files changed

Lines changed: 30 additions & 29 deletions

File tree

.github/workflows/python-bindings.yml

Lines changed: 16 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -42,9 +42,6 @@ jobs:
4242
with:
4343
enable-cache: true
4444

45-
- name: Install dependencies
46-
run: uv pip install --system black ruff mypy
47-
4845
- name: Setup virtual environment
4946
working-directory: crates/terraphim_automata_py
5047
run: |
@@ -55,6 +52,7 @@ jobs:
5552
else
5653
source .venv/bin/activate
5754
fi
55+
uv pip install black ruff mypy
5856
5957
- name: Fix Black formatting
6058
working-directory: crates/terraphim_automata_py
@@ -64,16 +62,28 @@ jobs:
6462
else
6563
source .venv/bin/activate
6664
fi
67-
uv run black python/
65+
black python/
6866
continue-on-error: false
6967

7068
- name: Lint with Ruff
7169
working-directory: crates/terraphim_automata_py
72-
run: ruff check python/
70+
run: |
71+
if [[ "$RUNNER_OS" == "Windows" ]]; then
72+
source .venv/Scripts/activate
73+
else
74+
source .venv/bin/activate
75+
fi
76+
ruff check python/
7377
7478
- name: Type check with mypy
7579
working-directory: crates/terraphim_automata_py
76-
run: mypy python/terraphim_automata/ --ignore-missing-imports
80+
run: |
81+
if [[ "$RUNNER_OS" == "Windows" ]]; then
82+
source .venv/Scripts/activate
83+
else
84+
source .venv/bin/activate
85+
fi
86+
mypy python/terraphim_automata/ --ignore-missing-imports
7787
continue-on-error: true
7888

7989
test:

crates/terraphim_multi_agent/src/agents/ontology_agents.rs

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -182,10 +182,8 @@ If no match found, respond with:
182182
"normalized_prov": null,
183183
"normalized_score": null,
184184
"normalized_method": null
185-
}}"#,
186-
ontology_list,
187-
entity.raw_value,
188-
format!("{:?}", entity.entity_type)
185+
}}"#,
186+
ontology_list, entity.raw_value, entity.entity_type
189187
);
190188

191189
let request = LlmRequest::new(vec![
@@ -276,7 +274,7 @@ impl ReviewAgent {
276274
/// Review and improve low-confidence normalizations
277275
pub async fn review(
278276
&self,
279-
entities: &mut Vec<ExtractedEntity>,
277+
entities: &mut [ExtractedEntity],
280278
) -> MultiAgentResult<Vec<ExtractedEntity>> {
281279
let client = self.llm_client.write().await;
282280

@@ -292,7 +290,7 @@ impl ReviewAgent {
292290
.collect();
293291

294292
if low_confidence.is_empty() {
295-
return Ok(entities.clone());
293+
return Ok(entities.to_vec());
296294
}
297295

298296
let review_prompt = format!(
@@ -373,7 +371,7 @@ Respond with ONLY valid JSON array:
373371

374372
info!("Review complete for {} entities", entities.len());
375373

376-
Ok(entities.clone())
374+
Ok(entities.to_vec())
377375
}
378376
}
379377

crates/terraphim_multi_agent/src/workflows/ontology_workflow.rs

Lines changed: 6 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -144,16 +144,15 @@ impl OntologyWorkflow {
144144
pub async fn execute(&self, text: &str) -> MultiAgentResult<OntologyWorkflowResult> {
145145
let start_time = std::time::Instant::now();
146146
let total_tokens = 0u64;
147-
let extraction_iterations;
148-
let mut normalization_iterations;
147+
let extraction_iterations = 1;
148+
let mut normalization_iterations = 1;
149149
let mut review_triggered = false;
150150

151151
// Step 1: Lead agent routes to Extraction Agent
152152
log::info!("Starting Dynamic Ontology workflow with LeadWithSpecialists pattern");
153153

154154
// Step 2: Extraction Agent extracts entities and relationships
155155
let schema_signal = self.extract_entities(text).await?;
156-
extraction_iterations = 1;
157156
log::info!(
158157
"Extracted {} entities and {} relationships",
159158
schema_signal.entities.len(),
@@ -164,7 +163,6 @@ impl OntologyWorkflow {
164163
let mut grounded_entities = self
165164
.normalize_entities(schema_signal.entities.clone())
166165
.await?;
167-
normalization_iterations = 1;
168166
log::info!("Normalized {} entities", grounded_entities.len());
169167

170168
// Step 4: Coverage Agent checks ontology coverage
@@ -309,10 +307,8 @@ If no match found, respond with:
309307
"normalized_prov": null,
310308
"normalized_score": null,
311309
"normalized_method": null
312-
}}"#,
313-
ontology_list,
314-
entity.raw_value,
315-
format!("{:?}", entity.entity_type)
310+
}}"#,
311+
ontology_list, entity.raw_value, entity.entity_type
316312
);
317313

318314
let request = LlmRequest::new(vec![
@@ -367,7 +363,7 @@ If no match found, respond with:
367363
/// Review Agent: Review and improve low coverage
368364
async fn review_and_improve(
369365
&self,
370-
entities: &mut Vec<ExtractedEntity>,
366+
entities: &mut [ExtractedEntity],
371367
_coverage: &CoverageSignal,
372368
) -> MultiAgentResult<Vec<ExtractedEntity>> {
373369
let mut client = self.llm_client.write().await;
@@ -453,7 +449,7 @@ Respond with ONLY valid JSON array:
453449
}
454450
}
455451

456-
Ok(entities.clone())
452+
Ok(entities.to_vec())
457453
}
458454
}
459455

crates/terraphim_multi_agent/tests/ontology_integration_test.rs

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -71,10 +71,7 @@ mod tests {
7171
mod tests {
7272
// Stub tests when hgnc feature is not enabled
7373
#[test]
74-
fn test_hgnc_stub() {
75-
// HGNC tests require the hgnc feature
76-
assert!(true);
77-
}
74+
fn test_hgnc_stub() {}
7875
}
7976

8077
#[cfg(test)]
@@ -84,7 +81,7 @@ mod generic_tests {
8481
/// Test coverage signal calculation
8582
#[test]
8683
fn test_coverage_signal_calculation() {
87-
let entities = vec![
84+
let entities = [
8885
ExtractedEntity {
8986
entity_type: "cancer_diagnosis".to_string(),
9087
raw_value: "lung carcinoma".to_string(),
@@ -135,7 +132,7 @@ mod generic_tests {
135132
/// Test coverage above threshold
136133
#[test]
137134
fn test_coverage_above_threshold() {
138-
let entities = vec![
135+
let entities = [
139136
ExtractedEntity {
140137
entity_type: "cancer_diagnosis".to_string(),
141138
raw_value: "lung carcinoma".to_string(),

0 commit comments

Comments
 (0)