Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add unittest for ray text dedup #540

Merged
merged 21 commits into from
Jan 23, 2025
Merged
Changes from 7 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
42 changes: 42 additions & 0 deletions tests/tools/test_process_data.py
Original file line number Diff line number Diff line change
Expand Up @@ -164,6 +164,48 @@ def test_ray_image(self):
for item in dataset['jsonl']:
self.assertIn('aspect_ratios', item['__dj__stats__'])

def test_ray_precise_dedup(self):
chenyushuo marked this conversation as resolved.
Show resolved Hide resolved
tmp_yaml_file = osp.join(self.tmp_dir, 'config_1.yaml')
tmp_out_path = osp.join(self.tmp_dir, 'output_dedup')
text_keys = 'text'

data_path = osp.join(osp.dirname(osp.dirname(osp.dirname(osp.realpath(__file__)))),
'demos', 'data', 'demo-dataset-deduplication.jsonl')
yaml_config = {
'dataset_path': data_path,
'executor_type': 'ray',
'ray_address': 'auto',
'text_keys': text_keys,
'image_key': 'images',
'export_path': tmp_out_path,
'process': [
{
'ray_document_deduplicator': {
'backend': 'ray_actor',
},
}
]
}

with open(tmp_yaml_file, 'w') as file:
yaml.dump(yaml_config, file)

run_in_subprocess(f'python tools/process_data.py --config {tmp_yaml_file}')

self.assertTrue(osp.exists(tmp_out_path))

jsonl_files = [os.path.join(tmp_out_path, f) \
for f in os.listdir(tmp_out_path) \
if f.endswith('.json')]
data_cnt = 0
for file in jsonl_files:
with open(file, 'r') as f:
for line in f.readlines():
if line.strip():
data_cnt += 1

self.assertEqual(data_cnt, 13)


if __name__ == '__main__':
unittest.main()
Loading