Skip to content

Commit c790ce4

Browse files
committed
enable travis
1 parent 414e108 commit c790ce4

File tree

4 files changed

+42
-1
lines changed

4 files changed

+42
-1
lines changed

.gitignore

+1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
.py[cod]
2+
*.jsonl
23
__pycache__/
34
data/
45
annotated/

.travis.yml

+10
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
language: python
2+
python:
3+
- "3.6"
4+
install:
5+
- pip install -r requirements.txt
6+
- tar xvjf data.tar.bz2
7+
- bunzip2 test/example.pred.dev.jsonl.bz2
8+
script:
9+
- python test/check.py
10+
- python evaluate.py data/dev.jsonl data/dev.db test/example.pred.dev.jsonl

test/Dockerfile

+1-1
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,6 @@ ADD . /eval/
66

77
RUN pip install -r requirements.txt
88
RUN tar xvjf data.tar.bz2
9-
RUN bunzip2 test/example.pred.dev.jsonl.bz2
9+
RUN bunzip2 -f test/example.pred.dev.jsonl.bz2
1010

1111
CMD python /eval/evaluate.py /eval/data/dev.jsonl /eval/data/dev.db /eval/test/example.pred.dev.jsonl

test/check.py

+30
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
import json
2+
from tqdm import tqdm
3+
import os
4+
import sys
5+
sys.path.append(os.path.dirname(os.path.dirname(os.path.abspath(__file__))))
6+
from lib.query import Query
7+
from lib.dbengine import DBEngine
8+
9+
10+
if __name__ == '__main__':
11+
for split in ['train', 'dev', 'test']:
12+
print('checking {}'.format(split))
13+
engine = DBEngine('data/{}.db'.format(split))
14+
n_lines = 0
15+
with open('data/{}.jsonl'.format(split)) as f:
16+
for l in f:
17+
n_lines += 1
18+
with open('data/{}.jsonl'.format(split)) as f:
19+
for l in tqdm(f, total=n_lines):
20+
d = json.loads(l)
21+
query = Query.from_dict(d['sql'])
22+
23+
# make sure it's executable
24+
result = engine.execute_query(d['table_id'], query)
25+
if result:
26+
for a, b, c in d['sql']['conds']:
27+
if str(c).lower() not in d['question'].lower():
28+
raise Exception('Could not find conditon {} in question {} for query {}'.format(c, d['question'], query))
29+
else:
30+
raise Exception('Query {} did not execute to a valid result'.format(query))

0 commit comments

Comments
 (0)