forked from SpeechColab/Leaderboard
-
Notifications
You must be signed in to change notification settings - Fork 1
/
pull
executable file
·58 lines (46 loc) · 1.98 KB
/
pull
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
51
52
53
54
55
56
57
58
#!/usr/bin/env python3
import sys, os
import argparse
import yaml # pip install pyyaml
import logging
logging.basicConfig(stream=sys.stderr, level=logging.INFO, format='%(asctime)s [%(levelname)s] %(message)s')
MODEL_ZOO = os.path.abspath('models'); assert os.path.isdir(MODEL_ZOO)
DATASET_ZOO = os.path.abspath('datasets'); assert os.path.isdir(DATASET_ZOO)
if __name__ == '__main__':
parser = argparse.ArgumentParser()
parser.add_argument('-m', '--model', type = str)
parser.add_argument('-d', '--dataset', type = str)
args = parser.parse_args()
logging.info(args)
if not os.path.isfile('utils/oss'):
logging.error("Please install oss via utils/install_aliyun_oss_client.sh")
sys.exit(-1)
if not os.path.isfile('credentials/aliyun_oss.cfg'):
instructions_to_get_credential = (
'You need credential to use the leaderboard:\n '
'Please send email with title "oss.cfg" to [email protected], '
'and paste replied content to credentials/aliyun_oss.cfg'
)
logging.error(instructions_to_get_credential)
sys.exit(-1)
if args.model and not args.dataset:
model_id = args.model
with open(os.path.join(MODEL_ZOO, 'zoo.yaml'), 'r', encoding='utf8') as f:
remote_model_zoo = yaml.safe_load(f)
src = remote_model_zoo[model_id]['url']
dst = os.path.join(MODEL_ZOO, model_id)
elif args.dataset and not args.model:
dataset_id = args.dataset
with open(os.path.join(DATASET_ZOO, 'zoo.yaml'), 'r', encoding='utf8') as f:
remote_dataset_zoo = yaml.safe_load(f)
src = remote_dataset_zoo[dataset_id]['url']
dst = os.path.join(DATASET_ZOO, dataset_id)
else:
logging.info(
F'\n {__file__} -m <MODEL_ID>\n'
F'\n {__file__} -d <DATASET_ID>\n'
)
exit(0)
cmd = F'utils/oss -c credentials/aliyun_oss.cfg cp -ur {src} {dst}'
logging.info(cmd)
os.system(cmd)