Can you add `import sys` so this script can run alone? I missed this when reviewing @cpennington's last PR (#2292)