Private
Public Access
fixing formatting
This commit is contained in:
+2
-3
@@ -46,10 +46,9 @@ MODEL_PRICING = [
|
|||||||
|
|
||||||
def estimate_cost(model: str, input_tokens: int, output_tokens: int) -> float:
|
def estimate_cost(model: str, input_tokens: int, output_tokens: int) -> float:
|
||||||
"""
|
"""
|
||||||
|
|
||||||
|
|
||||||
Estimate the cost of a model call based on input and output tokens.
|
Estimate the cost of a model call based on input and output tokens.
|
||||||
Returns the total cost in USD.
|
Returns the total cost in USD.
|
||||||
|
|
||||||
[C: src/gui_2.py:App._render_mma_track_summary, src/gui_2.py:App._render_mma_usage_section, src/gui_2.py:App._render_token_budget_panel, tests/test_cost_tracker.py:test_estimate_cost]
|
[C: src/gui_2.py:App._render_mma_track_summary, src/gui_2.py:App._render_mma_usage_section, src/gui_2.py:App._render_token_budget_panel, tests/test_cost_tracker.py:test_estimate_cost]
|
||||||
"""
|
"""
|
||||||
if not model:
|
if not model:
|
||||||
@@ -60,5 +59,5 @@ def estimate_cost(model: str, input_tokens: int, output_tokens: int) -> float:
|
|||||||
input_cost = (input_tokens / 1_000_000) * rates["input_per_mtok"]
|
input_cost = (input_tokens / 1_000_000) * rates["input_per_mtok"]
|
||||||
output_cost = (output_tokens / 1_000_000) * rates["output_per_mtok"]
|
output_cost = (output_tokens / 1_000_000) * rates["output_per_mtok"]
|
||||||
return input_cost + output_cost
|
return input_cost + output_cost
|
||||||
|
|
||||||
return 0.0
|
return 0.0
|
||||||
|
|
||||||
@@ -32,16 +32,12 @@ from src.performance_monitor import get_monitor
|
|||||||
|
|
||||||
class TrackDAG:
|
class TrackDAG:
|
||||||
"""
|
"""
|
||||||
|
|
||||||
|
|
||||||
Manages a Directed Acyclic Graph of implementation tickets.
|
Manages a Directed Acyclic Graph of implementation tickets.
|
||||||
Provides methods for dependency resolution, cycle detection, and topological sorting.
|
Provides methods for dependency resolution, cycle detection, and topological sorting.
|
||||||
"""
|
"""
|
||||||
|
|
||||||
def __init__(self, tickets: List[Ticket]) -> None:
|
def __init__(self, tickets: List[Ticket]) -> None:
|
||||||
"""
|
"""
|
||||||
|
|
||||||
|
|
||||||
Initializes the TrackDAG with a list of Ticket objects.
|
Initializes the TrackDAG with a list of Ticket objects.
|
||||||
Args:
|
Args:
|
||||||
tickets: A list of Ticket instances defining the graph nodes and edges.
|
tickets: A list of Ticket instances defining the graph nodes and edges.
|
||||||
@@ -52,8 +48,6 @@ class TrackDAG:
|
|||||||
|
|
||||||
def cascade_blocks(self) -> None:
|
def cascade_blocks(self) -> None:
|
||||||
"""
|
"""
|
||||||
|
|
||||||
|
|
||||||
Transitively marks `todo` tickets as `blocked` if any dependency is `blocked`.
|
Transitively marks `todo` tickets as `blocked` if any dependency is `blocked`.
|
||||||
Propagates 'blocked' status from initially blocked nodes to their dependents.
|
Propagates 'blocked' status from initially blocked nodes to their dependents.
|
||||||
[C: tests/test_perf_dag.py:test_dag_performance]
|
[C: tests/test_perf_dag.py:test_dag_performance]
|
||||||
@@ -90,8 +84,6 @@ class TrackDAG:
|
|||||||
|
|
||||||
def get_ready_tasks(self) -> List[Ticket]:
|
def get_ready_tasks(self) -> List[Ticket]:
|
||||||
"""
|
"""
|
||||||
|
|
||||||
|
|
||||||
Returns a list of tickets that are in 'todo' status and whose dependencies are all 'completed'.
|
Returns a list of tickets that are in 'todo' status and whose dependencies are all 'completed'.
|
||||||
Returns:
|
Returns:
|
||||||
A list of Ticket objects ready for execution.
|
A list of Ticket objects ready for execution.
|
||||||
@@ -105,8 +97,6 @@ class TrackDAG:
|
|||||||
|
|
||||||
def has_cycle(self) -> bool:
|
def has_cycle(self) -> bool:
|
||||||
"""
|
"""
|
||||||
|
|
||||||
|
|
||||||
Performs an iterative Depth-First Search to detect cycles in the dependency graph.
|
Performs an iterative Depth-First Search to detect cycles in the dependency graph.
|
||||||
Returns:
|
Returns:
|
||||||
True if a cycle is detected, False otherwise.
|
True if a cycle is detected, False otherwise.
|
||||||
@@ -139,8 +129,6 @@ class TrackDAG:
|
|||||||
|
|
||||||
def topological_sort(self) -> List[str]:
|
def topological_sort(self) -> List[str]:
|
||||||
"""
|
"""
|
||||||
|
|
||||||
|
|
||||||
Returns a list of ticket IDs in topological order (dependencies before dependents).
|
Returns a list of ticket IDs in topological order (dependencies before dependents).
|
||||||
Uses Kahn's algorithm for efficient O(V+E) sorting and cycle detection.
|
Uses Kahn's algorithm for efficient O(V+E) sorting and cycle detection.
|
||||||
Returns:
|
Returns:
|
||||||
@@ -176,16 +164,12 @@ class TrackDAG:
|
|||||||
|
|
||||||
class ExecutionEngine:
|
class ExecutionEngine:
|
||||||
"""
|
"""
|
||||||
|
|
||||||
|
|
||||||
A state machine that governs the progression of tasks within a TrackDAG.
|
A state machine that governs the progression of tasks within a TrackDAG.
|
||||||
Handles automatic queueing and manual task approval.
|
Handles automatic queueing and manual task approval.
|
||||||
"""
|
"""
|
||||||
|
|
||||||
def __init__(self, dag: TrackDAG, auto_queue: bool = False) -> None:
|
def __init__(self, dag: TrackDAG, auto_queue: bool = False) -> None:
|
||||||
"""
|
"""
|
||||||
|
|
||||||
|
|
||||||
Initializes the ExecutionEngine.
|
Initializes the ExecutionEngine.
|
||||||
Args:
|
Args:
|
||||||
dag: The TrackDAG instance to manage.
|
dag: The TrackDAG instance to manage.
|
||||||
@@ -197,8 +181,6 @@ class ExecutionEngine:
|
|||||||
|
|
||||||
def tick(self) -> List[Ticket]:
|
def tick(self) -> List[Ticket]:
|
||||||
"""
|
"""
|
||||||
|
|
||||||
|
|
||||||
Evaluates the DAG and returns a list of tasks that are currently 'ready' for execution.
|
Evaluates the DAG and returns a list of tasks that are currently 'ready' for execution.
|
||||||
If auto_queue is enabled, tasks without 'step_mode' will be marked as 'in_progress'.
|
If auto_queue is enabled, tasks without 'step_mode' will be marked as 'in_progress'.
|
||||||
Returns:
|
Returns:
|
||||||
@@ -212,8 +194,6 @@ class ExecutionEngine:
|
|||||||
|
|
||||||
def approve_task(self, task_id: str) -> None:
|
def approve_task(self, task_id: str) -> None:
|
||||||
"""
|
"""
|
||||||
|
|
||||||
|
|
||||||
Manually transitions a task from 'todo' to 'in_progress' if its dependencies are met.
|
Manually transitions a task from 'todo' to 'in_progress' if its dependencies are met.
|
||||||
Args:
|
Args:
|
||||||
task_id: The ID of the task to approve.
|
task_id: The ID of the task to approve.
|
||||||
@@ -225,8 +205,6 @@ class ExecutionEngine:
|
|||||||
|
|
||||||
def update_task_status(self, task_id: str, status: str) -> None:
|
def update_task_status(self, task_id: str, status: str) -> None:
|
||||||
"""
|
"""
|
||||||
|
|
||||||
|
|
||||||
Force-updates the status of a specific task.
|
Force-updates the status of a specific task.
|
||||||
Args:
|
Args:
|
||||||
task_id: The ID of the task.
|
task_id: The ID of the task.
|
||||||
|
|||||||
File diff suppressed because one or more lines are too long
Reference in New Issue
Block a user