Yassine
commited on
Commit
·
2629cd7
1
Parent(s):
53a7514
support streaming
Browse files- commavq.py +14 -4
commavq.py
CHANGED
@@ -25,10 +25,20 @@ class CommaVQ(datasets.GeneratorBasedBuilder):
|
|
25 |
|
26 |
def _split_generators(self, dl_manager):
|
27 |
"""Returns SplitGenerators."""
|
28 |
-
|
29 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
30 |
|
31 |
-
def _generate_examples(self,
|
32 |
-
for path in glob.glob(f'{
|
33 |
name = os.path.basename(path)
|
34 |
yield name, {'path': path}
|
|
|
|
|
|
|
|
|
|
25 |
|
26 |
def _split_generators(self, dl_manager):
|
27 |
"""Returns SplitGenerators."""
|
28 |
+
dl_manager.download_config.ignore_url_params = True
|
29 |
+
downloaded_files = dl_manager.download(_URLS)
|
30 |
+
local_extracted_archive = dl_manager.extract(downloaded_files) if not dl_manager.is_streaming else None
|
31 |
+
return [
|
32 |
+
datasets.SplitGenerator(
|
33 |
+
name=str(i),
|
34 |
+
gen_kwargs={"local_extracted_archive":local_extracted_archive, "files": dl_manager.iter_archive(downloaded_files[i])}
|
35 |
+
) for i, x in enumerate(downloaded_files)]
|
36 |
|
37 |
+
def _generate_examples(self, local_extracted_archive, files):
|
38 |
+
for path in glob.glob(f'{local_extracted_archive}/*.npy'):
|
39 |
name = os.path.basename(path)
|
40 |
yield name, {'path': path}
|
41 |
+
|
42 |
+
def _get_examples_iterable_for_split(self, split_generator):
|
43 |
+
for path in split_generator.gen_kwargs['files']:
|
44 |
+
yield path[0], {'path': path[0]}
|