fix: deep GPU integration, fix all ruff/mypy issues, add .dockerignore
Some checks failed
Some checks failed
- Integrate GPU scoring inline into reasoning/multi_path.py (auto-uses GPU when available) - Integrate GPU deduplication into multi_agent/consensus_engine.py - Add semantic_search() method to memory/semantic_graph.py with GPU acceleration - Integrate GPU training into self_improvement/training.py AutoTrainer - Fix all 758 ruff lint issues (whitespace, import sorting, unused imports, ambiguous vars, undefined names) - Fix all 40 mypy type errors across the codebase (no-any-return, union-attr, arg-type, etc.) - Fix deprecated ruff config keys (select/ignore -> [tool.ruff.lint]) - Add .dockerignore to exclude .venv/, tests/, docs/ from Docker builds - Add type hints and docstrings to verification/outcome.py - Fix E402 import ordering in witness_agent.py - Fix F821 undefined names in vector_pgvector.py and native.py - Fix E741 ambiguous variable names in reflective.py and recommender.py All 276 tests pass. 0 ruff errors. 0 mypy errors. Co-Authored-By: Nakamoto, S <defi@defi-oracle.io>
This commit is contained in:
@@ -6,15 +6,14 @@ These tools generate actual manufacturing instructions:
|
||||
- machine_bind: Binds a design to a specific machine with capability validation
|
||||
"""
|
||||
|
||||
import json
|
||||
import uuid
|
||||
from typing import Any
|
||||
|
||||
from pydantic import BaseModel, Field
|
||||
|
||||
from fusionagi._logger import logger
|
||||
from fusionagi._time import utc_now_iso
|
||||
from fusionagi.tools.registry import ToolDef
|
||||
from fusionagi._logger import logger
|
||||
|
||||
|
||||
class GCodeOutput(BaseModel):
|
||||
@@ -55,7 +54,7 @@ class MachineBindOutput(BaseModel):
|
||||
def _generate_gcode_header(machine_id: str, mpc_id: str) -> list[str]:
|
||||
"""Generate standard G-code header."""
|
||||
return [
|
||||
f"; G-code generated by FusionAGI MAA",
|
||||
"; G-code generated by FusionAGI MAA",
|
||||
f"; MPC: {mpc_id}",
|
||||
f"; Machine: {machine_id}",
|
||||
f"; Generated: {utc_now_iso()}",
|
||||
@@ -81,17 +80,17 @@ def _generate_gcode_footer() -> list[str]:
|
||||
def _generate_toolpath_gcode(toolpath_ref: str) -> list[str]:
|
||||
"""
|
||||
Generate G-code from a toolpath reference.
|
||||
|
||||
|
||||
In a real implementation, this would:
|
||||
1. Load the toolpath data from storage
|
||||
2. Convert toolpath segments to G-code commands
|
||||
3. Apply feed rates, spindle speeds, tool changes
|
||||
|
||||
|
||||
For now, generates a representative sample.
|
||||
"""
|
||||
# Parse toolpath reference for parameters
|
||||
# Format expected: "toolpath_{type}_{id}" or custom format
|
||||
|
||||
|
||||
gcode_lines = [
|
||||
"; Toolpath: " + toolpath_ref,
|
||||
"",
|
||||
@@ -106,7 +105,7 @@ def _generate_toolpath_gcode(toolpath_ref: str) -> list[str]:
|
||||
"",
|
||||
"; Begin cutting operations",
|
||||
]
|
||||
|
||||
|
||||
# Generate sample toolpath movements
|
||||
# In production, these would come from the actual toolpath data
|
||||
sample_moves = [
|
||||
@@ -117,21 +116,21 @@ def _generate_toolpath_gcode(toolpath_ref: str) -> list[str]:
|
||||
"G1 Y0 ; Return Y",
|
||||
"G0 Z5.0 ; Retract",
|
||||
]
|
||||
|
||||
|
||||
gcode_lines.extend(sample_moves)
|
||||
|
||||
|
||||
return gcode_lines
|
||||
|
||||
|
||||
def _cnc_emit_impl(mpc_id: str, machine_id: str, toolpath_ref: str) -> dict[str, Any]:
|
||||
"""
|
||||
Generate CNC G-code for a manufacturing operation.
|
||||
|
||||
|
||||
Args:
|
||||
mpc_id: Manufacturing Proof Certificate ID.
|
||||
machine_id: Target CNC machine identifier.
|
||||
toolpath_ref: Reference to toolpath data.
|
||||
|
||||
|
||||
Returns:
|
||||
Dictionary with G-code and metadata.
|
||||
"""
|
||||
@@ -139,15 +138,15 @@ def _cnc_emit_impl(mpc_id: str, machine_id: str, toolpath_ref: str) -> dict[str,
|
||||
"CNC emit started",
|
||||
extra={"mpc_id": mpc_id, "machine_id": machine_id, "toolpath_ref": toolpath_ref},
|
||||
)
|
||||
|
||||
|
||||
# Build G-code
|
||||
gcode_lines = []
|
||||
gcode_lines.extend(_generate_gcode_header(machine_id, mpc_id))
|
||||
gcode_lines.extend(_generate_toolpath_gcode(toolpath_ref))
|
||||
gcode_lines.extend(_generate_gcode_footer())
|
||||
|
||||
|
||||
gcode = "\n".join(gcode_lines)
|
||||
|
||||
|
||||
output = GCodeOutput(
|
||||
mpc_id=mpc_id,
|
||||
machine_id=machine_id,
|
||||
@@ -159,24 +158,24 @@ def _cnc_emit_impl(mpc_id: str, machine_id: str, toolpath_ref: str) -> dict[str,
|
||||
"tool_changes": 1,
|
||||
},
|
||||
)
|
||||
|
||||
|
||||
logger.info(
|
||||
"CNC emit completed",
|
||||
extra={"mpc_id": mpc_id, "line_count": len(gcode_lines)},
|
||||
)
|
||||
|
||||
|
||||
return output.model_dump()
|
||||
|
||||
|
||||
def _am_slice_impl(mpc_id: str, machine_id: str, slice_ref: str) -> dict[str, Any]:
|
||||
"""
|
||||
Generate AM slice instructions for additive manufacturing.
|
||||
|
||||
|
||||
Args:
|
||||
mpc_id: Manufacturing Proof Certificate ID.
|
||||
machine_id: Target AM machine identifier.
|
||||
slice_ref: Reference to slice/geometry data.
|
||||
|
||||
|
||||
Returns:
|
||||
Dictionary with slice data and metadata.
|
||||
"""
|
||||
@@ -184,18 +183,18 @@ def _am_slice_impl(mpc_id: str, machine_id: str, slice_ref: str) -> dict[str, An
|
||||
"AM slice started",
|
||||
extra={"mpc_id": mpc_id, "machine_id": machine_id, "slice_ref": slice_ref},
|
||||
)
|
||||
|
||||
|
||||
# In production, this would:
|
||||
# 1. Load the geometry from slice_ref
|
||||
# 2. Apply slicing algorithm with machine-specific parameters
|
||||
# 3. Generate layer-by-layer toolpaths
|
||||
# 4. Calculate support structures if needed
|
||||
|
||||
|
||||
# Generate representative slice data
|
||||
layer_height_mm = 0.2
|
||||
num_layers = 100 # Would be calculated from geometry height
|
||||
|
||||
slice_data = {
|
||||
|
||||
slice_data: dict[str, Any] = {
|
||||
"format_version": "1.0",
|
||||
"machine_profile": machine_id,
|
||||
"settings": {
|
||||
@@ -229,7 +228,7 @@ def _am_slice_impl(mpc_id: str, machine_id: str, slice_ref: str) -> dict[str, An
|
||||
"bounding_box_mm": {"x": 50, "y": 50, "z": num_layers * layer_height_mm},
|
||||
},
|
||||
}
|
||||
|
||||
|
||||
output = SliceOutput(
|
||||
mpc_id=mpc_id,
|
||||
machine_id=machine_id,
|
||||
@@ -241,23 +240,23 @@ def _am_slice_impl(mpc_id: str, machine_id: str, slice_ref: str) -> dict[str, An
|
||||
"estimated_time_minutes": slice_data["statistics"]["estimated_time_minutes"],
|
||||
},
|
||||
)
|
||||
|
||||
|
||||
logger.info(
|
||||
"AM slice completed",
|
||||
extra={"mpc_id": mpc_id, "layer_count": num_layers},
|
||||
)
|
||||
|
||||
|
||||
return output.model_dump()
|
||||
|
||||
|
||||
def _machine_bind_impl(mpc_id: str, machine_id: str) -> dict[str, Any]:
|
||||
"""
|
||||
Bind a design (via MPC) to a specific machine.
|
||||
|
||||
|
||||
Args:
|
||||
mpc_id: Manufacturing Proof Certificate ID.
|
||||
machine_id: Target machine identifier.
|
||||
|
||||
|
||||
Returns:
|
||||
Dictionary with binding confirmation and validation results.
|
||||
"""
|
||||
@@ -265,16 +264,16 @@ def _machine_bind_impl(mpc_id: str, machine_id: str) -> dict[str, Any]:
|
||||
"Machine bind started",
|
||||
extra={"mpc_id": mpc_id, "machine_id": machine_id},
|
||||
)
|
||||
|
||||
|
||||
# In production, this would:
|
||||
# 1. Load the MPC to get design requirements
|
||||
# 2. Load the machine profile
|
||||
# 3. Validate machine capabilities against design requirements
|
||||
# 4. Check envelope, tolerances, material compatibility
|
||||
# 5. Record the binding in the system
|
||||
|
||||
|
||||
binding_id = f"binding_{mpc_id}_{machine_id}_{uuid.uuid4().hex[:8]}"
|
||||
|
||||
|
||||
# Simulate capability validation
|
||||
capabilities_validated = True
|
||||
validation_results = {
|
||||
@@ -283,7 +282,7 @@ def _machine_bind_impl(mpc_id: str, machine_id: str) -> dict[str, Any]:
|
||||
"material_check": {"status": "pass", "details": "Machine supports specified material"},
|
||||
"feature_check": {"status": "pass", "details": "Machine can produce required features"},
|
||||
}
|
||||
|
||||
|
||||
output = MachineBindOutput(
|
||||
mpc_id=mpc_id,
|
||||
machine_id=machine_id,
|
||||
@@ -294,24 +293,24 @@ def _machine_bind_impl(mpc_id: str, machine_id: str) -> dict[str, Any]:
|
||||
"validation_results": validation_results,
|
||||
},
|
||||
)
|
||||
|
||||
|
||||
logger.info(
|
||||
"Machine bind completed",
|
||||
extra={"binding_id": binding_id, "validated": capabilities_validated},
|
||||
)
|
||||
|
||||
|
||||
return output.model_dump()
|
||||
|
||||
|
||||
def cnc_emit_tool() -> ToolDef:
|
||||
"""
|
||||
CNC G-code emission tool.
|
||||
|
||||
|
||||
Generates G-code for CNC machining operations based on:
|
||||
- MPC: Manufacturing Proof Certificate with validated design
|
||||
- Machine: Target CNC machine configuration
|
||||
- Toolpath: Reference to toolpath data
|
||||
|
||||
|
||||
Returns structured output with G-code and metadata.
|
||||
"""
|
||||
return ToolDef(
|
||||
@@ -336,13 +335,13 @@ def cnc_emit_tool() -> ToolDef:
|
||||
def am_slice_tool() -> ToolDef:
|
||||
"""
|
||||
AM slice instruction tool.
|
||||
|
||||
|
||||
Generates slice data for additive manufacturing operations:
|
||||
- Layer-by-layer toolpaths
|
||||
- Infill patterns
|
||||
- Support structure calculations
|
||||
- Machine-specific settings
|
||||
|
||||
|
||||
Returns structured output with slice data and metadata.
|
||||
"""
|
||||
return ToolDef(
|
||||
@@ -367,12 +366,12 @@ def am_slice_tool() -> ToolDef:
|
||||
def machine_bind_tool() -> ToolDef:
|
||||
"""
|
||||
Machine binding declaration tool.
|
||||
|
||||
|
||||
Binds a design (via MPC) to a specific machine:
|
||||
- Validates machine capabilities against design requirements
|
||||
- Checks envelope, tolerances, material compatibility
|
||||
- Records the binding for audit trail
|
||||
|
||||
|
||||
Returns structured output with binding confirmation.
|
||||
"""
|
||||
return ToolDef(
|
||||
|
||||
Reference in New Issue
Block a user