in utils/model_registry.py [0:0]
def main():
parser = argparse.ArgumentParser(
description=__doc__,
# Preserves whitespace in the help text.
formatter_class=argparse.RawTextHelpFormatter,
)
parser.add_argument(
"--no_cache", action="store_true", help="Do not cache the TaskCluster calls"
)
parser.add_argument("--clear_cache", action="store_true", help="Clears the TaskCluster cache")
parser.add_argument(
"--upload",
action="store_true",
help="When set to true, the artifacts are uploaded to GCS. Otherwise they are stored at to data/model-registry/",
)
parser.add_argument(
"--overwrite_runs",
action="store_true",
help="By default only missing training runs are created. This recreates everything.",
)
args = parser.parse_args()
cache = None
if not args.no_cache:
print(f"Using the cache {CACHE_FILE}")
cache = shelve.open(str(CACHE_FILE))
if args.clear_cache:
print(f"Clearing the cache {CACHE_FILE}")
if cache is None:
cache = shelve.open(str(CACHE_FILE))
cache.clear()
cache.close()
cache = None
else:
cache.clear()
runs_by_training_pair = get_training_runs_by_langpair(cache)
print_training_runs_tree(runs_by_training_pair)
# Saves out the training runs depending on the --upload argument:
# - data/model-registry/training-runs/{name}-{langpair}.json
# - gs://{BUCKET}/models/{langpair}/{name}.json
build_json_for_training_runs(runs_by_training_pair, args.overwrite_runs, args.upload, cache)
# Saves a reference of all the listings:
# - gs://{BUCKET}/models/listing.json
if args.upload:
save_training_run_listing(runs_by_training_pair)
if cache is not None:
cache.close()