Upload .mirror/mirror_worker.py with huggingface_hub
Browse files- .mirror/mirror_worker.py +7 -3
.mirror/mirror_worker.py
CHANGED
|
@@ -159,9 +159,13 @@ def main() -> None:
|
|
| 159 |
if number % WORKER_COUNT == WORKER_INDEX
|
| 160 |
and (item.get("Type") or item.get("type")) != "tree"
|
| 161 |
]
|
| 162 |
-
#
|
| 163 |
-
#
|
| 164 |
-
#
|
|
|
|
|
|
|
|
|
|
|
|
|
| 165 |
shard_total = len(selected)
|
| 166 |
resume_at = next(
|
| 167 |
(
|
|
|
|
| 159 |
if number % WORKER_COUNT == WORKER_INDEX
|
| 160 |
and (item.get("Type") or item.get("type")) != "tree"
|
| 161 |
]
|
| 162 |
+
# Prioritize payload throughput. ModelScope's path order begins with a
|
| 163 |
+
# massive collection of sub-kilobyte metrics JSONs; sending those first
|
| 164 |
+
# strands the workers in metadata while multi-gigabyte payloads wait.
|
| 165 |
+
# The order remains deterministic, and uploaded paths are still skipped.
|
| 166 |
+
selected.sort(key=lambda item: int(item.get("Size") or item.get("size") or 0), reverse=True)
|
| 167 |
+
# Resume at the first not-yet-uploaded file instead of walking committed
|
| 168 |
+
# files after every hourly job restart.
|
| 169 |
shard_total = len(selected)
|
| 170 |
resume_at = next(
|
| 171 |
(
|