alexgshaw Claude Opus 4.6 (1M context) commited on
Commit
e419e83
·
1 Parent(s): 32096df

Replace snapshot_download with level-by-level listing for agent files.

Browse files

snapshot_download causes timeouts on large repos due to recursive tree
listing. Use the same per-trial list_repo_tree approach as result.json.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>

Files changed (1) hide show
  1. app.py +19 -14
app.py CHANGED
@@ -30,11 +30,11 @@ from harbor.models.job.result import JobResult
30
  # Instead, we parse only the specific fields we need from raw dicts.
31
  from huggingface_hub import (
32
  HfApi,
 
33
  RepoFolder,
34
  WebhookPayload,
35
  WebhooksServer,
36
  hf_hub_download,
37
- snapshot_download,
38
  )
39
  from litellm import model_cost
40
  from pydantic import UUID4, BaseModel, ConfigDict, Field, ValidationError
@@ -1131,6 +1131,24 @@ async def _download_submission_files(
1131
  for trial_item in trial_items:
1132
  if isinstance(trial_item, RepoFolder):
1133
  files_to_download.append(f"{trial_item.path}/result.json")
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1134
 
1135
  logger.info(f"Downloading {len(files_to_download)} files for {submission_name}")
1136
 
@@ -1147,19 +1165,6 @@ async def _download_submission_files(
1147
  for f in files_to_download:
1148
  tg.create_task(_safe_download(f))
1149
 
1150
- # Download agent/* files for reward hacking checks
1151
- try:
1152
- await asyncio.to_thread(
1153
- snapshot_download,
1154
- repo_id=DATASET_REPO,
1155
- repo_type="dataset",
1156
- revision=revision,
1157
- local_dir=str(local_dir),
1158
- allow_patterns=[f"{sub_path}/*/trial-*/agent/*"],
1159
- )
1160
- except Exception as e:
1161
- logger.warning(f"Could not download agent files for {submission_name}: {e}")
1162
-
1163
 
1164
  async def get_changed_submission_names(api: HfApi, pr_revision: str) -> list[str]:
1165
  """Detect which submission folders changed in a PR vs main.
 
30
  # Instead, we parse only the specific fields we need from raw dicts.
31
  from huggingface_hub import (
32
  HfApi,
33
+ RepoFile,
34
  RepoFolder,
35
  WebhookPayload,
36
  WebhooksServer,
37
  hf_hub_download,
 
38
  )
39
  from litellm import model_cost
40
  from pydantic import UUID4, BaseModel, ConfigDict, Field, ValidationError
 
1131
  for trial_item in trial_items:
1132
  if isinstance(trial_item, RepoFolder):
1133
  files_to_download.append(f"{trial_item.path}/result.json")
1134
+ # List agent/* files for reward hacking checks
1135
+ try:
1136
+ agent_items = await asyncio.to_thread(
1137
+ lambda tp=trial_item.path: list(
1138
+ api.list_repo_tree(
1139
+ repo_id=DATASET_REPO,
1140
+ path_in_repo=f"{tp}/agent",
1141
+ repo_type="dataset",
1142
+ revision=revision,
1143
+ recursive=True,
1144
+ )
1145
+ )
1146
+ )
1147
+ for agent_item in agent_items:
1148
+ if isinstance(agent_item, RepoFile):
1149
+ files_to_download.append(agent_item.path)
1150
+ except Exception:
1151
+ pass # agent/ dir may not exist
1152
 
1153
  logger.info(f"Downloading {len(files_to_download)} files for {submission_name}")
1154
 
 
1165
  for f in files_to_download:
1166
  tg.create_task(_safe_download(f))
1167
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1168
 
1169
  async def get_changed_submission_names(api: HfApi, pr_revision: str) -> list[str]:
1170
  """Detect which submission folders changed in a PR vs main.