|
16 | 16 | from harbor.models.environment_type import EnvironmentType |
17 | 17 | from harbor.models.job.config import RetryConfig |
18 | 18 | from harbor.trial.hooks import TrialEvent, TrialHookEvent |
| 19 | + |
| 20 | +# Only the abundant-ai Harbor fork defines ENVIRONMENT_PROVISIONED; against |
| 21 | +# vanilla harbor the attribute access itself would raise AttributeError on |
| 22 | +# every hook event. Resolve it once so the comparisons below simply never |
| 23 | +# match when the event does not exist. |
| 24 | +_ENVIRONMENT_PROVISIONED = getattr(TrialEvent, "ENVIRONMENT_PROVISIONED", None) |
19 | 25 | from harbor.viewer.scanner import JobScanner |
20 | 26 | from sqlalchemy import select, update |
21 | 27 |
|
@@ -1086,7 +1092,7 @@ async def _handle_harbor_event( |
1086 | 1092 | elif observed_at.tzinfo is None: |
1087 | 1093 | observed_at = observed_at.replace(tzinfo=timezone.utc) |
1088 | 1094 |
|
1089 | | - if event == TrialEvent.ENVIRONMENT_PROVISIONED: |
| 1095 | + if _ENVIRONMENT_PROVISIONED is not None and event == _ENVIRONMENT_PROVISIONED: |
1090 | 1096 | if sandbox_launch is None: |
1091 | 1097 | raise RuntimeError( |
1092 | 1098 | f"Trial {trial_id} received environment-provisioned without a " |
@@ -1343,7 +1349,7 @@ async def _handle_harbor_event( |
1343 | 1349 |
|
1344 | 1350 | except Exception as e: |
1345 | 1351 | console.print(f"[yellow]Hook callback error: {e}[/yellow]") |
1346 | | - if event == TrialEvent.ENVIRONMENT_PROVISIONED: |
| 1352 | + if _ENVIRONMENT_PROVISIONED is not None and event == _ENVIRONMENT_PROVISIONED: |
1347 | 1353 | raise |
1348 | 1354 |
|
1349 | 1355 |
|
|
0 commit comments