-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathPrepare_workspace.py
More file actions
55 lines (37 loc) · 1.78 KB
/
Prepare_workspace.py
File metadata and controls
55 lines (37 loc) · 1.78 KB
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
# -*- coding: utf-8 -*-
"""
Created on Wed May 6 15:41:20 2020
@author: Iacopo
"""
import os
import argparse
import shutil
import sys
class MyParser(argparse.ArgumentParser):
def error(self, message):
sys.stderr.write('error: %s\n' % message)
self.print_help()
sys.exit(2)
parser = MyParser(
description='Workspace generator function: the program will create\
a directory with a user-specified name in which a set of predefined sub-directories\
will contain the training data, generated sentences, saved model, saved vocabularies\
respectively. It is advised to use this function for each new experiment, so\
as to create separate locations for each experiment.')
parser.add_argument('--directory_name', '-name', default='experiment', type=str,
help='Name of the directory to be created.')
parser.add_argument('--data_folder', '-data', default='data', type=str,
help='name of the subdirectory storing the data. If two or\
more experiments share the same hyperparameters but different\
data, a differently named data folder can be defined (in which\
case the corresponding line in json file needs to be changed)')
args = parser.parse_args()
os.mkdir(args.directory_name)
os.chdir(args.directory_name)
os.mkdir('saved_models')
os.mkdir(args.data_folder)
os.mkdir('saved_dictionaries')
os.mkdir('outputs')
shutil.copyfile('../Hyperparameters.json','Hyperparameters.json')
print('New directory set up at {}: copy the data in {}, change the parameters of Hyperparameters.json as required and you are ready to go!'.format(os.getcwd(),
os.path.join(os.getcwd(),args.data_folder)))