Update app.py
Browse files
app.py
CHANGED
|
@@ -22,20 +22,21 @@ def _list_collection_files(pr_number: str) -> Tuple[str, ...]:
|
|
| 22 |
"""
|
| 23 |
prefix = f"pr-{pr_number}"
|
| 24 |
try:
|
|
|
|
| 25 |
entries = API.list_repo_tree(
|
| 26 |
repo_id=DATASET_ID,
|
| 27 |
repo_type="dataset",
|
| 28 |
-
path=prefix,
|
| 29 |
recursive=True,
|
| 30 |
)
|
| 31 |
except HfHubHTTPError as error:
|
| 32 |
-
print(f"Failed to list repo tree
|
| 33 |
return tuple()
|
| 34 |
|
| 35 |
files = []
|
| 36 |
for entry in entries:
|
| 37 |
entry_type = getattr(entry, "type", None)
|
| 38 |
-
|
|
|
|
| 39 |
files.append(entry.path)
|
| 40 |
return tuple(files)
|
| 41 |
|
|
@@ -174,4 +175,4 @@ with gr.Blocks() as demo:
|
|
| 174 |
refresh_btn.click(refresh_dataset, outputs=status)
|
| 175 |
|
| 176 |
if __name__ == "__main__":
|
| 177 |
-
demo.queue(max_size=20).launch()
|
|
|
|
| 22 |
"""
|
| 23 |
prefix = f"pr-{pr_number}"
|
| 24 |
try:
|
| 25 |
+
# List all files in the repo and filter by prefix
|
| 26 |
entries = API.list_repo_tree(
|
| 27 |
repo_id=DATASET_ID,
|
| 28 |
repo_type="dataset",
|
|
|
|
| 29 |
recursive=True,
|
| 30 |
)
|
| 31 |
except HfHubHTTPError as error:
|
| 32 |
+
print(f"Failed to list repo tree: {error}")
|
| 33 |
return tuple()
|
| 34 |
|
| 35 |
files = []
|
| 36 |
for entry in entries:
|
| 37 |
entry_type = getattr(entry, "type", None)
|
| 38 |
+
# Filter by prefix and look for collection_summary.json files
|
| 39 |
+
if entry_type == "file" and entry.path.startswith(prefix) and entry.path.endswith("collection_summary.json"):
|
| 40 |
files.append(entry.path)
|
| 41 |
return tuple(files)
|
| 42 |
|
|
|
|
| 175 |
refresh_btn.click(refresh_dataset, outputs=status)
|
| 176 |
|
| 177 |
if __name__ == "__main__":
|
| 178 |
+
demo.queue(max_size=20).launch()
|