MCPcopy Create free account
hub / github.com/agentscope-ai/Trinity-RFT / serve

Function serve

trinity/cli/launcher.py:181–220  ·  view source on GitHub ↗

Run explorer in server mode.

(config: Config, *, timeout: Optional[float] = None)

Source from the content-addressed store, hash-verified

179
180
181def serve(config: Config, *, timeout: Optional[float] = None) -> StageStatus:
182 """Run explorer in server mode."""
183 from trinity.explorer.explorer import Explorer
184
185 explorer = Explorer.get_actor(config)
186 startup_started_at = time.perf_counter()
187 startup_time_sec: Optional[float] = None
188 run_started_at: Optional[float] = None
189
190 try:
191 ray.get(explorer.prepare.remote(), timeout=timeout)
192 startup_time_sec = time.perf_counter() - startup_started_at
193
194 run_started_at = time.perf_counter()
195 ray.get(explorer.sync_weight.remote(), timeout=timeout)
196 ray.get(explorer.serve.remote(), timeout=timeout)
197 execution_time_sec = time.perf_counter() - run_started_at
198 return StageStatus(
199 stage="serve",
200 success=True,
201 startup_time_sec=startup_time_sec,
202 execution_time_sec=execution_time_sec,
203 total_time_sec=time.perf_counter() - startup_started_at,
204 )
205 except Exception as exc:
206 error = _build_stage_error(exc)
207 logger.error(f"Explorer failed:\n{error.traceback_text}")
208 execution_time_sec = (
209 time.perf_counter() - run_started_at if run_started_at is not None else None
210 )
211 return StageStatus(
212 stage="serve",
213 success=False,
214 startup_time_sec=startup_time_sec,
215 execution_time_sec=execution_time_sec,
216 total_time_sec=time.perf_counter() - startup_started_at,
217 error=error,
218 )
219 finally:
220 ray.get(explorer.shutdown.remote(), timeout=timeout)
221
222
223def both(config: Config) -> StageStatus:

Callers 1

run_serveFunction · 0.90

Calls 5

StageStatusClass · 0.85
_build_stage_errorFunction · 0.85
remoteMethod · 0.80
get_actorMethod · 0.45
getMethod · 0.45

Tested by 1

run_serveFunction · 0.72