-
Notifications
You must be signed in to change notification settings - Fork 27
/
main.py
38 lines (30 loc) · 1.14 KB
/
main.py
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
import os
from parser import Parser
from datetime import datetime
from config import *
from misc.utils import *
from data.generator import DataGenerator
def main(args):
args = set_data_config(args)
if args.work_type == 'gen_data':
dm = DataGenerator(args)
dm.generate_data()
else:
args = set_config(args)
os.environ['CUDA_VISIBLE_DEVICES']=args.gpu
now = datetime.now().strftime("%Y%m%d-%H%M")
args.log_dir = os.path.join(args.output_path, 'logs/{}-{}-{}'.format(now, args.model, args.task))
args.state_dir = os.path.join(args.output_path, 'states/{}-{}-{}'.format(now, args.model, args.task))
if not os.path.isdir(args.log_dir):
os.makedirs(args.log_dir)
if not os.path.isdir(args.state_dir):
os.makedirs(args.state_dir)
if args.model == 'fedweit':
from models.fedweit.server import Server
server = Server(args)
server.run()
else:
print('incorrect model was given: {}'.format(args.model))
os._exit(0)
if __name__ == '__main__':
main(Parser().parse())