forked from mlcommons/GaNDLF
-
Notifications
You must be signed in to change notification settings - Fork 0
/
gandlf_recoverConfig
50 lines (43 loc) · 1.34 KB
/
gandlf_recoverConfig
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
#!usr/bin/env python
# -*- coding: utf-8 -*-
import argparse
from GANDLF.cli import copyrightMessage, recover_config
import pickle
import os, sys
import yaml
if __name__ == "__main__":
parser = argparse.ArgumentParser(
prog="GANDLF_RecoverConfig",
formatter_class=argparse.RawTextHelpFormatter,
description="Recovers a config file from a GaNDLF model. If used from within a deployed GaNDLF MLCube, attempts to extract the config from the embedded model.\n\n"
+ copyrightMessage,
)
parser.add_argument(
"-m",
"--modeldir",
metavar="",
default="",
type=str,
help="Path to the model directory.",
)
parser.add_argument(
"-c",
"--mlcube",
metavar="",
type=str,
help="Pass this option to attempt to extract the config from the embedded model in a GaNDLF MLCube (if any). Only useful in that context.",
)
parser.add_argument(
"-o",
"--outputFile",
metavar="",
type=str,
help="Path to an output file where the config will be written.",
)
args = parser.parse_args()
if args.mlcube:
search_dir = "/embedded_model/"
else:
search_dir = args.modeldir
result = recover_config(search_dir, args.outputFile)
assert result, "Config file recovery failed."