ydshieh HF Staff commited on
Commit
04294da
·
verified ·
1 Parent(s): 98a0138

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +52 -14
app.py CHANGED
@@ -23,7 +23,9 @@ def _list_collection_files(pr_number: str) -> Tuple[str, ...]:
23
  Return the `failure_summary.json` paths stored for a specific PR.
24
  """
25
  prefix = f"pr-{pr_number}"
26
- print(f"Looking for files with prefix: {prefix}")
 
 
27
  try:
28
  # List all files in the repo and filter by prefix
29
  entries = API.list_repo_tree(
@@ -32,25 +34,56 @@ def _list_collection_files(pr_number: str) -> Tuple[str, ...]:
32
  revision="main",
33
  recursive=True,
34
  )
 
35
  except HfHubHTTPError as error:
36
- print(f"Failed to list repo tree: {error}")
 
 
 
 
 
37
  return tuple()
38
 
39
  files = []
40
  matching_paths = []
41
- for entry in entries:
42
- entry_type = getattr(entry, "type", None)
43
- # Debug: show all files that match the prefix
44
- if entry_type == "file" and entry.path.startswith(prefix):
45
- matching_paths.append(entry.path)
46
- # Filter by prefix and look for failure_summary.json files
47
- if entry_type == "file" and entry.path.startswith(prefix) and entry.path.endswith("failure_summary.json"):
48
- files.append(entry.path)
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
49
 
50
- print(f"Found {len(matching_paths)} files with prefix {prefix}")
51
- print(f"Found {len(files)} failure_summary.json files")
52
- if matching_paths:
53
- print(f"Sample matching paths: {matching_paths[:5]}")
54
  return tuple(files)
55
 
56
 
@@ -117,11 +150,15 @@ def query(repo: str, pr: str, sha: str) -> Tuple[List[List[str]], str, str]:
117
  repo = repo.strip()
118
  pr = pr.strip()
119
  sha = sha.strip()
 
 
120
 
121
  if not pr:
122
  return [], json.dumps({"error": "PR number is required."}, indent=2), "Provide a PR number to search."
123
 
124
  records = _filter_records(repo, pr, sha)
 
 
125
  if not records:
126
  return [], json.dumps({"error": "No records found."}, indent=2), f"No records found for PR {pr}."
127
 
@@ -142,6 +179,7 @@ def query(repo: str, pr: str, sha: str) -> Tuple[List[List[str]], str, str]:
142
 
143
  latest_payload = json.dumps(records[0], indent=2)
144
  status = f"Showing {len(records)} record(s) for PR {pr}."
 
145
  return table_rows, latest_payload, status
146
 
147
 
 
23
  Return the `failure_summary.json` paths stored for a specific PR.
24
  """
25
  prefix = f"pr-{pr_number}"
26
+ print(f"DEBUG: Looking for files with prefix: {prefix}")
27
+ print(f"DEBUG: Dataset ID: {DATASET_ID}")
28
+
29
  try:
30
  # List all files in the repo and filter by prefix
31
  entries = API.list_repo_tree(
 
34
  revision="main",
35
  recursive=True,
36
  )
37
+ print("DEBUG: Successfully called list_repo_tree")
38
  except HfHubHTTPError as error:
39
+ print(f"ERROR: Failed to list repo tree: {error}")
40
+ return tuple()
41
+ except Exception as error:
42
+ print(f"ERROR: Unexpected error in list_repo_tree: {error}")
43
+ import traceback
44
+ traceback.print_exc()
45
  return tuple()
46
 
47
  files = []
48
  matching_paths = []
49
+ all_entries = []
50
+
51
+ try:
52
+ for entry in entries:
53
+ all_entries.append(entry)
54
+ entry_type = getattr(entry, "type", type(entry).__name__)
55
+ entry_path = getattr(entry, "path", str(entry))
56
+
57
+ # Debug: show all entries
58
+ if len(all_entries) <= 10:
59
+ print(f"DEBUG: Entry {len(all_entries)}: {entry_path} (type: {entry_type})")
60
+
61
+ # Filter by prefix
62
+ if entry_path.startswith(prefix):
63
+ matching_paths.append(entry_path)
64
+
65
+ # Look for failure_summary.json files
66
+ if entry_path.startswith(prefix) and entry_path.endswith("failure_summary.json"):
67
+ if "file" in entry_type.lower() or entry_type == "RepoFile":
68
+ files.append(entry_path)
69
+ print(f"DEBUG: Found matching file: {entry_path}")
70
+
71
+ print(f"DEBUG: Total entries processed: {len(all_entries)}")
72
+ print(f"DEBUG: Entries with prefix '{prefix}': {len(matching_paths)}")
73
+ print(f"DEBUG: failure_summary.json files found: {len(files)}")
74
+
75
+ if matching_paths and len(files) == 0:
76
+ print(f"DEBUG: Sample matching paths (first 5): {matching_paths[:5]}")
77
+ # Check if we're only getting folders
78
+ folder_count = sum(1 for p in matching_paths if "RepoFolder" in str(type(p)))
79
+ print(f"DEBUG: Folders in matching paths: {folder_count}")
80
+
81
+ except Exception as error:
82
+ print(f"ERROR: Error processing entries: {error}")
83
+ import traceback
84
+ traceback.print_exc()
85
+ return tuple()
86
 
 
 
 
 
87
  return tuple(files)
88
 
89
 
 
150
  repo = repo.strip()
151
  pr = pr.strip()
152
  sha = sha.strip()
153
+
154
+ print(f"DEBUG: Query called with repo='{repo}', pr='{pr}', sha='{sha}'")
155
 
156
  if not pr:
157
  return [], json.dumps({"error": "PR number is required."}, indent=2), "Provide a PR number to search."
158
 
159
  records = _filter_records(repo, pr, sha)
160
+ print(f"DEBUG: _filter_records returned {len(records)} records")
161
+
162
  if not records:
163
  return [], json.dumps({"error": "No records found."}, indent=2), f"No records found for PR {pr}."
164
 
 
179
 
180
  latest_payload = json.dumps(records[0], indent=2)
181
  status = f"Showing {len(records)} record(s) for PR {pr}."
182
+ print(f"DEBUG: Returning {len(table_rows)} table rows")
183
  return table_rows, latest_payload, status
184
 
185