MCPcopy Create free account
hub / github.com/Dizzy-K/AutoPT / run

Method run

runner/task_runner.py:84–144  ·  view source on GitHub ↗
(self, request: TaskRequest)

Source from the content-addressed store, hash-verified

82class TaskRunner:
83 """Execute a single benchmark task through the LangGraph workflow."""
84 def run(self, request: TaskRequest) -> TaskResult:
85 start = time()
86 context = request.workflow.context
87 context.history.clear()
88 context.commands.clear()
89 context.problem = context.problem_template
90 context.bind_target(request.ip_addr, request.benchmark.target)
91
92 try:
93 llm = build_chat_model(request.model, request.config)
94 graph = request.workflow.compile(llm)
95 state = context.initial_state()
96 result = self._invoke_graph(
97 graph,
98 state,
99 recursion_limit=context.recursion_limit(),
100 )
101 runtime = time() - start
102 status = self._status_from_history(context.history)
103 return TaskResult(
104 status=status,
105 runtime=runtime,
106 benchmark_name=request.benchmark.name,
107 model_alias=request.model.alias,
108 ip_addr=request.ip_addr,
109 details=build_task_result_details(
110 target=request.benchmark.target,
111 benchmark=request.benchmark.to_dict(),
112 model=request.model.to_dict(),
113 architecture="FSM",
114 workflow_name="autopt.workflow.v1",
115 prompt_bundle_name=request.prompt_bundle_name,
116 result=serialize_json_value(result),
117 history=context.history,
118 commands=context.commands,
119 prompts=request.prompts.to_dict(),
120 workflow_edges=request.workflow.edges,
121 ),
122 )
123 except Exception as exc:
124 runtime = time() - start
125 return TaskResult(
126 status="error",
127 runtime=runtime,
128 benchmark_name=request.benchmark.name,
129 model_alias=request.model.alias,
130 ip_addr=request.ip_addr,
131 details=build_task_result_details(
132 target=request.benchmark.target,
133 benchmark=request.benchmark.to_dict(),
134 model=request.model.to_dict(),
135 architecture="FSM",
136 workflow_name="autopt.workflow.v1",
137 prompt_bundle_name=request.prompt_bundle_name,
138 error=str(exc),
139 history=context.history,
140 commands=context.commands,
141 prompts=request.prompts.to_dict(),

Callers 3

_execute_localMethod · 0.45
_invoke_graphMethod · 0.45
handle_runFunction · 0.45

Calls 11

_invoke_graphMethod · 0.95
_status_from_historyMethod · 0.95
build_chat_modelFunction · 0.90
TaskResultClass · 0.85
serialize_json_valueFunction · 0.85
bind_targetMethod · 0.80
compileMethod · 0.80
initial_stateMethod · 0.80
recursion_limitMethod · 0.80
to_dictMethod · 0.45

Tested by

no test coverage detected