move postprocessing into split generator
Browse files
zenodo.py
CHANGED
|
@@ -36,25 +36,18 @@ class NewDataset(datasets.GeneratorBasedBuilder):
|
|
| 36 |
|
| 37 |
url = f"https://zenodo.org/record/{self.zenodo_id}/files/{self.filename}"
|
| 38 |
|
| 39 |
-
|
|
|
|
|
|
|
|
|
|
| 40 |
return [
|
| 41 |
datasets.SplitGenerator(
|
| 42 |
name=datasets.Split.TRAIN,
|
| 43 |
gen_kwargs={
|
| 44 |
-
"filepath":
|
| 45 |
},
|
| 46 |
),
|
| 47 |
]
|
| 48 |
|
| 49 |
-
def _generate_examples(self
|
| 50 |
-
# lets rename the file to the original name
|
| 51 |
-
# copy file to the current directory without os specific commands
|
| 52 |
-
current_directory = os.getcwd()
|
| 53 |
-
|
| 54 |
-
# os.system(f"cp {filepath} .")
|
| 55 |
-
# os.system(f"mv {os.path.basename(filepath)} {self.filename}")
|
| 56 |
-
shutil.copy(filepath, current_directory)
|
| 57 |
-
os.rename(os.path.basename(filepath), self.filename)
|
| 58 |
-
|
| 59 |
-
|
| 60 |
yield 0, {"path": filepath}
|
|
|
|
| 36 |
|
| 37 |
url = f"https://zenodo.org/record/{self.zenodo_id}/files/{self.filename}"
|
| 38 |
|
| 39 |
+
filepath = dl_manager.download([url])[0]
|
| 40 |
+
shutil.copy(filepath, os.getcwd())
|
| 41 |
+
os.rename(os.path.basename(filepath), self.filename)
|
| 42 |
+
|
| 43 |
return [
|
| 44 |
datasets.SplitGenerator(
|
| 45 |
name=datasets.Split.TRAIN,
|
| 46 |
gen_kwargs={
|
| 47 |
+
"filepath": filepath,
|
| 48 |
},
|
| 49 |
),
|
| 50 |
]
|
| 51 |
|
| 52 |
+
def _generate_examples(self):
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 53 |
yield 0, {"path": filepath}
|