ai pretrain-predict: fix - → _ in cli parsing

This commit is contained in:
Starbeamrainbowlabs 2022-09-14 15:12:07 +01:00
parent f97b771922
commit 1876a8883c
Signed by: sbrl
GPG key ID: 1BE5172E637709C2
2 changed files with 6 additions and 1 deletions

View file

@ -25,7 +25,7 @@ For more information, do src/index.py <subcommand> --help.
""") """)
exit(0) exit(0)
subcommand = re.sub(r'[^a-z0-9-]', '', sys.argv[1]) subcommand = re.sub(r'-', '_', re.sub(r'[^a-z0-9-]', '', sys.argv[1]))
subcommand_argparser = importlib.import_module(f"subcommands.{subcommand}").parse_args subcommand_argparser = importlib.import_module(f"subcommands.{subcommand}").parse_args

View file

@ -68,12 +68,17 @@ def run(args):
if filepath_output != "-": if filepath_output != "-":
handle = io.open(filepath_output, "w") handle = io.open(filepath_output, "w")
i = 0
for rainfall, water in ai.embed(dataset): for rainfall, water in ai.embed(dataset):
handle.write(json.dumps({ handle.write(json.dumps({
"rainfall": rainfall.numpy().tolist(), "rainfall": rainfall.numpy().tolist(),
"water": water.numpy().tolist() "water": water.numpy().tolist()
}, separators=(',', ':'))+"\n") # Ref https://stackoverflow.com/a/64710892/1460422 }, separators=(',', ':'))+"\n") # Ref https://stackoverflow.com/a/64710892/1460422
if i == 0 or i % 1000 == 0:
sys.stderr.write(f"[pretrain:predict] STEP {i}\r")
i += 1
handle.close() handle.close()
sys.stderr.write(">>> Complete\n") sys.stderr.write(">>> Complete\n")