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

[Chunk Teacher] Remove exception for specifying non-streaming data #3653

Merged
merged 2 commits into from
May 14, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 0 additions & 3 deletions parlai/core/teachers.py
Original file line number Diff line number Diff line change
Expand Up @@ -2291,9 +2291,6 @@ def __init__(self, opt, shared=None):
super().__init__(opt, shared)
self.buffersize = self.get_buffersize()

if 'stream' not in opt['datatype']:
raise ValueError('Chunk teacher should be used with streaming. ')

self.set_datasettings(opt)

self.dws = int(self.opt.get('distributed_world_size', 1))
Expand Down
40 changes: 19 additions & 21 deletions tests/test_teachers.py
Original file line number Diff line number Diff line change
Expand Up @@ -301,27 +301,25 @@ def test_dynamic_batched(self):
assert valid['exs'] == 100
assert test['exs'] == 100

def test_stream_only(self):
with self.assertRaises(ValueError):
valid, test = testing_utils.eval_model(
dict(
task='integration_tests:chunky',
model='parlai.agents.test_agents.test_agents:MockTorchAgent',
batchsize=32,
),
valid_datatype='valid',
)

with self.assertRaises(ValueError):
valid, test = testing_utils.eval_model(
dict(
task='integration_tests:chunky',
model='parlai.agents.test_agents.test_agents:MockTorchAgent',
batchsize=32,
),
valid_datatype='valid:stream',
test_datatype='test',
)
def test_non_stream_works(self):
testing_utils.eval_model(
dict(
task='integration_tests:chunky',
model='parlai.agents.test_agents.test_agents:MockTorchAgent',
batchsize=32,
),
valid_datatype='valid',
)

testing_utils.eval_model(
dict(
task='integration_tests:chunky',
model='parlai.agents.test_agents.test_agents:MockTorchAgent',
batchsize=32,
),
valid_datatype='valid:stream',
test_datatype='test',
)


class CustomEvaluationTeacher(DialogTeacher):
Expand Down