Skip to content

Commit f822f91

Browse files
authored
Guard ENVIRONMENT_PROVISIONED hook comparisons for vanilla harbor (#1299)
1 parent 0a11c4f commit f822f91

1 file changed

Lines changed: 8 additions & 2 deletions

File tree

oddish/src/oddish/workers/queue/trial_handler.py

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,12 @@
1616
from harbor.models.environment_type import EnvironmentType
1717
from harbor.models.job.config import RetryConfig
1818
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)
1925
from harbor.viewer.scanner import JobScanner
2026
from sqlalchemy import select, update
2127

@@ -1086,7 +1092,7 @@ async def _handle_harbor_event(
10861092
elif observed_at.tzinfo is None:
10871093
observed_at = observed_at.replace(tzinfo=timezone.utc)
10881094

1089-
if event == TrialEvent.ENVIRONMENT_PROVISIONED:
1095+
if _ENVIRONMENT_PROVISIONED is not None and event == _ENVIRONMENT_PROVISIONED:
10901096
if sandbox_launch is None:
10911097
raise RuntimeError(
10921098
f"Trial {trial_id} received environment-provisioned without a "
@@ -1343,7 +1349,7 @@ async def _handle_harbor_event(
13431349

13441350
except Exception as e:
13451351
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:
13471353
raise
13481354

13491355

0 commit comments

Comments
 (0)