Run explorer.
(config: Config, *, timeout: Optional[float] = None)
| 95 | |
| 96 | |
| 97 | def explore(config: Config, *, timeout: Optional[float] = None) -> StageStatus: |
| 98 | """Run explorer.""" |
| 99 | from trinity.explorer.explorer import Explorer |
| 100 | |
| 101 | explorer = Explorer.get_actor(config) |
| 102 | startup_started_at = time.perf_counter() |
| 103 | startup_time_sec: Optional[float] = None |
| 104 | run_started_at: Optional[float] = None |
| 105 | |
| 106 | try: |
| 107 | ray.get(explorer.prepare.remote(), timeout=timeout) |
| 108 | startup_time_sec = time.perf_counter() - startup_started_at |
| 109 | |
| 110 | run_started_at = time.perf_counter() |
| 111 | ray.get(explorer.sync_weight.remote(), timeout=timeout) |
| 112 | ray.get(explorer.explore.remote(), timeout=timeout) |
| 113 | execution_time_sec = time.perf_counter() - run_started_at |
| 114 | return StageStatus( |
| 115 | stage="explore", |
| 116 | success=True, |
| 117 | startup_time_sec=startup_time_sec, |
| 118 | execution_time_sec=execution_time_sec, |
| 119 | total_time_sec=time.perf_counter() - startup_started_at, |
| 120 | ) |
| 121 | except Exception as exc: |
| 122 | error = _build_stage_error(exc) |
| 123 | logger.error(f"Explorer failed:\n{error.traceback_text}") |
| 124 | execution_time_sec = ( |
| 125 | time.perf_counter() - run_started_at if run_started_at is not None else None |
| 126 | ) |
| 127 | return StageStatus( |
| 128 | stage="explore", |
| 129 | success=False, |
| 130 | startup_time_sec=startup_time_sec, |
| 131 | execution_time_sec=execution_time_sec, |
| 132 | total_time_sec=time.perf_counter() - startup_started_at, |
| 133 | error=error, |
| 134 | ) |
| 135 | finally: |
| 136 | ray.get(explorer.shutdown.remote(), timeout=timeout) |
| 137 | |
| 138 | |
| 139 | def train(config: Config, *, timeout: Optional[float] = None) -> StageStatus: |