Converting auto_partition.sh to auto_partition.py