Use ModelScope paginated dataset manifest
Browse files39 unmodified lines4041424344454647484950515253547 unmodified lines6263646566676839 unmodified linessource.login(MODELSCOPE_TOKEN)target = HfApi(token=HF_TOKEN)uploaded = set(target.list_repo_files(DEST_REPO, repo_type="dataset"))files = source.list_repo_files(SOURCE_REPO, "dataset", recursive=True)selected = [item for number, item in enumerate(files)if number % WORKER_COUNT == WORKER_INDEX and item.type != "tree"]print(f"worker {WORKER_INDEX}/{WORKER_COUNT}: {len(selected)} files")for number, item in enumerate(selected, start=1):path = item.pathif path in uploaded:print(f"skip {number}/{len(selected)} {path}", flush=True)continue7 unmodified linespath,local_dir=WORKDIR,force=True,expected_sha256=item.blob_id,),f"download {path}",)39 unmodified lines404142434445464748495051525354555657585960617 unmodified lines6970717273747539 unmodified linessource.login(MODELSCOPE_TOKEN)target = HfApi(token=HF_TOKEN)uploaded = set(target.list_repo_files(DEST_REPO, repo_type="dataset"))# The ordinary repository listing is truncated for very large ModelScope# datasets. Their dataset downloader uses this paginated tree endpoint.files = source.legacy.list_dataset_files_paginated(SOURCE_REPO, page_size=200)selected = [item for number, item in enumerate(files)if number % WORKER_COUNT == WORKER_INDEXand (item.get("Type") or item.get("type")) != "tree"]print(f"worker {WORKER_INDEX}/{WORKER_COUNT}: {len(selected)} files")for number, item in enumerate(selected, start=1):path = item.get("Path") or item.get("path") or item.get("Name")if not path:continueif path in uploaded:print(f"skip {number}/{len(selected)} {path}", flush=True)continue7 unmodified linespath,local_dir=WORKDIR,force=True,expected_sha256=item.get("Sha256") or item.get("sha256"),),f"download {path}",)
mirror_worker.py+11-4