UXInteract / task_036 /solution /code /distributed_demo.py
DojiSum's picture
Publish the current 141-task UXInteract release
ef987bb verified
Raw History Blame Contribute Delete
640 Bytes
#!/usr/bin/env python3
"""Assign globally sorted tar sample keys to a distributed rank."""
import argparse
from dataloader_demo import sample_keys
def main():
parser = argparse.ArgumentParser()
parser.add_argument("--rank", type=int, required=True)
parser.add_argument("--world-size", type=int, required=True)
args = parser.parse_args()
if args.world_size < 1 or not 0 <= args.rank < args.world_size:
parser.error("rank must be in [0, world-size)")
for index, key in enumerate(sample_keys()):
if index % args.world_size == args.rank:
print(key)
if __name__ == "__main__":
main()