Skip to content
This repository has been archived by the owner on Nov 3, 2023. It is now read-only.

Commit

Permalink
Updating the tests after the conversation teacher changes. (#5038)
Browse files Browse the repository at this point in the history
* test updates

* lint

* extra error for version drifts fixed

* pytest_regressions version upgrade for better yaml on unicode

* pytest

* turning to dict type for the yaml storage

* new tests

* lint
  • Loading branch information
mojtaba-komeili authored May 31, 2023
1 parent 3cc6a79 commit e466907
Show file tree
Hide file tree
Showing 6 changed files with 103 additions and 12 deletions.
8 changes: 4 additions & 4 deletions parlai/core/teachers.py
Original file line number Diff line number Diff line change
Expand Up @@ -1733,8 +1733,8 @@ def _get_ep_from_turns(self, xturns, yturns):
turn['text'] = xturn.get('text')
turn['labels'] = [yturn.get('text')]

turn['x_turn'] = xturn
turn['y_turn'] = yturn
turn['x_turn'] = dict(xturn)
turn['y_turn'] = dict(yturn)

eps.append(turn)
return eps
Expand Down Expand Up @@ -1841,8 +1841,8 @@ def _validate_image_mode_name(self, a):
available_model_names = self.get_available_image_mode_names()
if a not in available_model_names:
raise argparse.ArgumentTypeError(
'\"%s\" unknown image model name. Choose from: %s. Currently suggested resnet is resnet152 and resnext is resnext101_32x48d_wsl.'
% (a, available_model_names)
f'"{a}" unknown image model name. Choose from: {available_model_names}.'
'Currently suggested resnet is resnet152 and resnext is resnext101_32x48d_wsl.'
)
return a

Expand Down
30 changes: 30 additions & 0 deletions parlai/tasks/lccc/test/lccc_test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,25 +4,55 @@ acts:
- 去相机家里吃……
id: lccc
text: 我饿了。
x_turn:
id: partner1
text: 我饿了。
y_turn:
id: partner2
text: 去相机家里吃……
- - episode_done: true
eval_labels:
- 你过来我们什么关系
id: lccc
text: 网络大实话里说的是也许你能在网络里找到你想要的友情但永远不会找到你想要的爱情
x_turn:
id: partner1
text: 网络大实话里说的是也许你能在网络里找到你想要的友情但永远不会找到你想要的爱情
y_turn:
id: partner2
text: 你过来我们什么关系
- - episode_done: true
eval_labels:
- 我不挑食
id: lccc
text: 老铁家好吃贾三不好吃
x_turn:
id: partner1
text: 老铁家好吃贾三不好吃
y_turn:
id: partner2
text: 我不挑食
- - episode_done: true
eval_labels:
- 死鱼皮真会安慰人那不是翘臀是肥肉不!是赘肉!
id: lccc
text: 你有翘臀啊!!!!你的脸还不够小啊?????
x_turn:
id: partner1
text: 你有翘臀啊!!!!你的脸还不够小啊?????
y_turn:
id: partner2
text: 死鱼皮真会安慰人那不是翘臀是肥肉不!是赘肉!
- - episode_done: false
eval_labels:
- 哈哈哈快到南方来
id: lccc
text: 好羡慕原来你们那真的可以光腿
x_turn:
id: partner1
text: 好羡慕原来你们那真的可以光腿
y_turn:
id: partner2
text: 哈哈哈快到南方来
num_episodes: 10000
num_examples: 12943
30 changes: 30 additions & 0 deletions parlai/tasks/lccc/test/lccc_train.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,25 +4,55 @@ acts:
labels:
- 道歉!!再有时间找你去
text: 你去那儿竟然不喊我生气了,快点给我道歉
x_turn:
id: partner1
text: 你去那儿竟然不喊我生气了,快点给我道歉
y_turn:
id: partner2
text: 道歉!!再有时间找你去
- - episode_done: true
id: lccc
labels:
- SEED早上刚被禁用还有一个月的VIP路线呢禁了之后才买的另一个买了一年结果用了一下午就挂了现在用了个极速网速差的很
text: 我用SEED.24小时签到一次可以用4小时,对于我这种每天晚上逛一下的感觉不错
x_turn:
id: partner1
text: 我用SEED.24小时签到一次可以用4小时,对于我这种每天晚上逛一下的感觉不错
y_turn:
id: partner2
text: SEED早上刚被禁用还有一个月的VIP路线呢禁了之后才买的另一个买了一年结果用了一下午就挂了现在用了个极速网速差的很
- - episode_done: true
id: lccc
labels:
- 干完这一票我的会员等级就要升了!
text: 咬咬牙这回要全入了!
x_turn:
id: partner1
text: 咬咬牙这回要全入了!
y_turn:
id: partner2
text: 干完这一票我的会员等级就要升了!
- - episode_done: true
id: lccc
labels:
- 代表了哪里的普通人?
text: 记得还…我们普通人要搬三天砖才赚来的20元
x_turn:
id: partner1
text: 记得还…我们普通人要搬三天砖才赚来的20元
y_turn:
id: partner2
text: 代表了哪里的普通人?
- - episode_done: true
id: lccc
labels:
- 好得差不多啦
text: 早点好起来啊。生日快乐
x_turn:
id: partner1
text: 早点好起来啊。生日快乐
y_turn:
id: partner2
text: 好得差不多啦
num_episodes: 6820506
num_examples: 8869637
30 changes: 30 additions & 0 deletions parlai/tasks/lccc/test/lccc_valid.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,25 +4,55 @@ acts:
- 那个饭凉了吧唧的怎么吃啊摔
id: lccc
text: 啊我好爱虾仁蛋黄酱金枪鱼蛋黄酱
x_turn:
id: partner1
text: 啊我好爱虾仁蛋黄酱金枪鱼蛋黄酱
y_turn:
id: partner2
text: 那个饭凉了吧唧的怎么吃啊摔
- - episode_done: true
eval_labels:
- 看了下全文,那女的考试当天就表明身体不舒服了,考试不是她预约是教练自己安排的,教练还让她考试不就是教练的错吗?而且她住院花了31万,赔30万不过分吧
id: lccc
text: 考试撞墙关驾校屁事?你怎么不顺便把考场施工单位也告了?
x_turn:
id: partner1
text: 考试撞墙关驾校屁事?你怎么不顺便把考场施工单位也告了?
y_turn:
id: partner2
text: 看了下全文,那女的考试当天就表明身体不舒服了,考试不是她预约是教练自己安排的,教练还让她考试不就是教练的错吗?而且她住院花了31万,赔30万不过分吧
- - episode_done: true
eval_labels:
- 好好好,偶遇我大闺蜜
id: lccc
text: 我先去穿衣服,准备走了
x_turn:
id: partner1
text: 我先去穿衣服,准备走了
y_turn:
id: partner2
text: 好好好,偶遇我大闺蜜
- - episode_done: true
eval_labels:
- 保存一下
id: lccc
text: 期待小猎豹的表现
x_turn:
id: partner1
text: 期待小猎豹的表现
y_turn:
id: partner2
text: 保存一下
- - episode_done: true
eval_labels:
- 给你一个么么哒
id: lccc
text: 为了你们新年有惊喜,我也是用心良苦了
x_turn:
id: partner1
text: 为了你们新年有惊喜,我也是用心良苦了
y_turn:
id: partner2
text: 给你一个么么哒
num_episodes: 20000
num_examples: 25558
6 changes: 3 additions & 3 deletions requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,8 @@ joblib==1.2.0
nltk==3.6.6
omegaconf>=2.1.1
pandas==1.4.0
pytest_regressions==2.1.1
pytest==5.3.2
pytest_regressions==2.4.2
pytest==7.3.0
pexpect==4.7.0
Pillow==9.3.0
py-gfm==1.0.2
Expand All @@ -46,7 +46,7 @@ tomli>=2.0.0
torchtext==0.15.1
tornado==6.0.4
tqdm~=4.62.1
typing-extensions==3.7.4.3
typing-extensions==4.5.0
Unidecode==1.1.1
urllib3<1.27,>=1.26.5
websocket-client==0.56.0
Expand Down
11 changes: 6 additions & 5 deletions tests/test_teachers.py
Original file line number Diff line number Diff line change
Expand Up @@ -154,8 +154,9 @@ def test_no_text(self):
'{"dialog": [[{"id": "speaker1"}, {"text": "Hello.", "id": "speaker2"}]]}\n'
)
opt = {'task': 'jsonfile', 'jsonfile_datapath': fp, 'verbose': True}
with self.assertRaises(AttributeError):
testing_utils.display_data(opt)

train_out, _, _ = testing_utils.display_data(opt)
self.assertTrue("'text': None" in train_out.split('\n')[1])

def test_firstspeaker_label(self):
with testing_utils.tempdir() as tmpdir:
Expand All @@ -175,7 +176,7 @@ def test_firstspeaker_label(self):
l.split(':', 1)[-1].strip()
for l in train_out.split('\n')
if l in train_out
if 'text' in l
if '[text]' in l
]
labels = [
l.split(':', 1)[-1].strip()
Expand Down Expand Up @@ -204,7 +205,7 @@ def test_secondspeaker_label(self):
l.split(':', 1)[-1].strip()
for l in train_out.split('\n')
if l in train_out
if 'text' in l
if '[text]' in l
]
labels = [
l.split(':', 1)[-1].strip()
Expand Down Expand Up @@ -233,7 +234,7 @@ def test_both_label(self):
l.split(':', 1)[-1].strip()
for l in train_out.split('\n')
if l in train_out
if 'text' in l
if '[text]' in l
]
labels = [
l.split(':', 1)[-1].strip()
Expand Down

0 comments on commit e466907

Please sign in to comment.