Commit ·
9a3c989
1
Parent(s): 36d9d14
Update icy_dolma.py
Browse files- icy_dolma.py +9 -4
icy_dolma.py
CHANGED
|
@@ -154,6 +154,7 @@ class IcyDolmaConfig(datasets.BuilderConfig):
|
|
| 154 |
filepaths=None,
|
| 155 |
file_loc=None,
|
| 156 |
buffer_size=65536,
|
|
|
|
| 157 |
**kwargs):
|
| 158 |
"""BuilderConfig for IcyDolma.
|
| 159 |
Args:
|
|
@@ -165,6 +166,8 @@ class IcyDolmaConfig(datasets.BuilderConfig):
|
|
| 165 |
self.filepaths = filepaths
|
| 166 |
self.file_loc = file_loc
|
| 167 |
self.buffer_size = buffer_size
|
|
|
|
|
|
|
| 168 |
|
| 169 |
class IcyDolma(datasets.GeneratorBasedBuilder):
|
| 170 |
BUILDER_CONFIGS = [IcyDolmaConfig(name) for name in _VARIANTS]
|
|
@@ -172,12 +175,14 @@ class IcyDolma(datasets.GeneratorBasedBuilder):
|
|
| 172 |
def _info(self):
|
| 173 |
self.worker_id = self.config.worker_id
|
| 174 |
self.n_workers = self.config.n_workers
|
| 175 |
-
self.filepaths = self.config.filepaths
|
| 176 |
self.buffer_size = self.config.buffer_size
|
| 177 |
-
if self.config.filepaths is None:
|
| 178 |
-
self.filepaths = [_DATA_URL.format(i,j,k) for i in range(64) for j in range(64) for k in range(2)]
|
| 179 |
-
else:
|
| 180 |
self.filepaths = self.config.filepaths
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 181 |
if self.config.file_loc is not None:
|
| 182 |
self.file_loc = self.config.file_loc
|
| 183 |
else:
|
|
|
|
| 154 |
filepaths=None,
|
| 155 |
file_loc=None,
|
| 156 |
buffer_size=65536,
|
| 157 |
+
shard_spec=None,
|
| 158 |
**kwargs):
|
| 159 |
"""BuilderConfig for IcyDolma.
|
| 160 |
Args:
|
|
|
|
| 166 |
self.filepaths = filepaths
|
| 167 |
self.file_loc = file_loc
|
| 168 |
self.buffer_size = buffer_size
|
| 169 |
+
self.shard_spec = shard_spec
|
| 170 |
+
assert (self.shard_spec is None) or (self.filepaths is None ) #one of these must be None
|
| 171 |
|
| 172 |
class IcyDolma(datasets.GeneratorBasedBuilder):
|
| 173 |
BUILDER_CONFIGS = [IcyDolmaConfig(name) for name in _VARIANTS]
|
|
|
|
| 175 |
def _info(self):
|
| 176 |
self.worker_id = self.config.worker_id
|
| 177 |
self.n_workers = self.config.n_workers
|
|
|
|
| 178 |
self.buffer_size = self.config.buffer_size
|
| 179 |
+
if self.config.filepaths is not None:
|
|
|
|
|
|
|
| 180 |
self.filepaths = self.config.filepaths
|
| 181 |
+
elif self.config.shard_spec is not None:
|
| 182 |
+
shard_idx, subshard_idx = self.config.shard_spec
|
| 183 |
+
self.filepaths = [_DATA_URL.format(shard_idx,subshard_idx,k) for k in range(2)]
|
| 184 |
+
else:
|
| 185 |
+
self.filepaths = [_DATA_URL.format(i,j,k) for i in range(64) for j in range(64) for k in range(2)]
|
| 186 |
if self.config.file_loc is not None:
|
| 187 |
self.file_loc = self.config.file_loc
|
| 188 |
else:
|