-
Notifications
You must be signed in to change notification settings - Fork 2
/
sanity.py
145 lines (120 loc) · 3.91 KB
/
sanity.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
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
#Wasih (02-22-20) Add sanity/confirm smooth run script
#Script to confirm installations
#1. Test installations first
#Wasih (02-26-20) Make conditional imports depending on Python version
import os
import sys
import glob
if sys.version_info[0] == 2:
import ConfigParser as configparser
else:
import configparser
try:
import termcolor
except ImportError:
print ('Please Install termcolor!')
sys.exit(0)
from termcolor import colored
try:
import nltk
except ImportError:
text = colored('Please Install nltk!', 'red', attrs = ['bold'])
print (text)
sys.exit(0)
try:
import sklearn
except ImportError:
text = colored('Please Install scikit-learn!', 'red', attrs = ['bold'])
print (text)
sys.exit(0)
try:
import bs4
except ImportError:
text = colored('Please Install beautifulsoup4!', 'red', attrs = ['bold'])
print (text)
sys.exit(0)
try:
import scipy
except ImportError:
text = colored('Please Install scipy!', 'red', attrs = ['bold'])
print (text)
sys.exit(0)
try:
import numpy
except ImportError:
text = colored('Please Install numpy!', 'red', attrs = ['bold'])
print (text)
sys.exit(0)
try:
import networkx
except ImportError:
text = colored('Please Install networkx!', 'red', attrs = ['bold'])
print (text)
sys.exit(0)
try:
import statistics
except ImportError:
text = colored('Please Install statistics!', 'red', attrs = ['bold'])
print (text)
sys.exit(0)
try:
import pandas
except ImportError:
text = colored('Please Install pandas!', 'red', attrs = ['bold'])
print (text)
sys.exit(0)
try:
import theano
except ImportError:
text = colored('Please Install theano!', 'red', attrs = ['bold'])
print (text)
sys.exit(0)
#2. Check stanford corenlp present or not
config = configparser.ConfigParser()
config.read('parameters.ini')
stanford_dir = config.get('Paths', 'StanfordDir')
coreNlpDir = ""
for filename in os.listdir(stanford_dir):
if (os.path.isdir(os.path.join(stanford_dir, filename)) and 'stanford' in filename):
coreNlpDir = filename
break
if coreNlpDir == "":
text = colored('Stanford CoreNLP not present. Please extract it to %s Directory' % stanford_dir, 'red', attrs = ['bold'])
print (text)
sys.exit(0)
#3. Check if all necessary directories present or not
raw_peer_dir = config.get('Paths', 'RawPeerDir')
raw_model_dir = config.get('Paths', 'RawModelDir')
preprocess_dir = config.get('Paths', 'PreprocessDir')
pyramid_dir = config.get('Paths', 'PyramidDir')
scoring_dir = config.get('Paths', 'ScoringDir')
if os.path.exists(raw_peer_dir) == False:
text = colored('Peers directory not present!. Please give some input', 'red', attrs = ['bold'])
print (text)
sys.exit(0)
if os.path.exists(raw_model_dir) == False:
text = colored('Model directory not present!. Please give some input', 'red', attrs = ['bold'])
print (text)
sys.exit(0)
if os.path.exists(raw_model_dir) and len(glob.glob1(raw_model_dir, "*.txt")) < 4:
text = colored('Model directory contains very few model summaries!. Please give atleast 4 summaries', 'red', attrs = ['bold'])
print (text)
sys.exit(0)
if os.path.exists(raw_peer_dir) and len(glob.glob1(raw_peer_dir, "*.txt")) == 0:
text = colored('Peers directory is empty!. Please give atleast a single text summary', 'red', attrs = ['bold'])
print (text)
sys.exit(0)
if os.path.exists(preprocess_dir) == False:
text = colored('Preprocess directory not present!', 'red', attrs = ['bold'])
print (text)
sys.exit(0)
if os.path.exists(pyramid_dir) == False:
text = colored('Pyramid directory not present!', 'red', attrs = ['bold'])
print (text)
sys.exit(0)
if os.path.exists(scoring_dir) == False:
text = colored('Scoring directory not present!', 'red', attrs = ['bold'])
print (text)
sys.exit(0)
text = colored('All Good to Go!', 'green', attrs = ['bold'])
print (text)