for path in tqdm.tqdm(glob.glob(f"{args.root}/*/.wav", recursive=True)): pathhash =…
- User
for path in tqdm.tqdm(glob.glob(f"{args.root}/**/*.wav", recursive=True)): path_hash = hashlib.sha1(path.encode('utf-8')) if path_hash % args.workers != args.worker_index: # Note, cannot use hash(path) because it is not deterministic across runs and we have multiple processes continue
Fix this code
Assistant
Here is one way to fix the code to make the hashing deterministic across runs:
import os import hashlib import glob from tqdm import tqdm for path in tqdm(glob.glob(f"{args.root}/**/*.wav", recursive=True)): path_bytes = path.encode('utf-8') path_hash = hashlib.sha1(path_bytes).hexdigest()[:8].encode() worker_index = int(path_hash, 16) % args.workers if worker_index != args.worker_index: continueThe changes made:
- Encode the path to bytes before hashing to make it consistent
Other models, same or similar prompt
Responses were produced in different, uncontrolled contexts (system prompts, settings, prior turns). This is not a benchmark.