anz2 commited on
Commit
7ca8ff6
1 Parent(s): daf6912

fix data access issues

Browse files
NASA_OSDR.py CHANGED
@@ -97,26 +97,37 @@ class NasaOsdr(datasets.GeneratorBasedBuilder):
97
  citation=_CITATION,
98
  )
99
 
 
 
 
 
100
  def _split_generators(self, dl_manager):
101
- # no need to download, dataset is there!
102
- # dataset_root = dl_manager.download_and_extract(_FIFTYONE_DATASET_URL)
 
 
 
 
 
 
 
103
  return [
104
  datasets.SplitGenerator(
105
  name=datasets.Split.TRAIN,
106
  gen_kwargs={
107
- "split": "train",
108
- "dataset_root": "data",
109
  },
110
  ),
111
  ]
112
 
113
- def _generate_examples(self, split: str, dataset_root: str):
114
- assays = os.path.join(dataset_root, "assays.csv")
115
- samples = os.path.join(dataset_root, "samples.csv")
116
  # there can be other metadata tables merged
117
 
118
- assays_df = pd.read_csv(assays)
119
- samples_df = pd.read_csv(samples)
120
 
121
  for (idx, assay_row), (_, sample_row) in zip(assays_df.iterrows(), samples_df.iterrows()):
122
  _item = {**assay_row.to_dict()}
 
97
  citation=_CITATION,
98
  )
99
 
100
+ _URL = "https://raw.githubusercontent.com/AnzorGozalishvili/NASA_ODSR_DATA/main"
101
+ _ASSAYS_FILE = "assays.csv"
102
+ _SAMPLES_FILE = "samples.csv"
103
+
104
  def _split_generators(self, dl_manager):
105
+ downloaded_files = dl_manager.download_and_extract(
106
+ {
107
+ "train": {
108
+ "assays": os.path.join(self._URL, self._ASSAYS_FILE),
109
+ "samples": os.path.join(self._URL, self._ASSAYS_FILE)
110
+ },
111
+ }
112
+ )
113
+
114
  return [
115
  datasets.SplitGenerator(
116
  name=datasets.Split.TRAIN,
117
  gen_kwargs={
118
+ "assays_file": downloaded_files['train']['assays'],
119
+ "samples_file": downloaded_files['train']['samples'],
120
  },
121
  ),
122
  ]
123
 
124
+ def _generate_examples(self, assays_file: str, samples_file):
125
+ # assays = os.path.join(dataset_root, "assays.csv")
126
+ # samples = os.path.join(dataset_root, "samples.csv")
127
  # there can be other metadata tables merged
128
 
129
+ assays_df = pd.read_csv(assays_file)
130
+ samples_df = pd.read_csv(samples_file)
131
 
132
  for (idx, assay_row), (_, sample_row) in zip(assays_df.iterrows(), samples_df.iterrows()):
133
  _item = {**assay_row.to_dict()}
tests/{test_iliauni_icc_georgian_ocr.py → test_nasa_osdr.py} RENAMED
@@ -33,7 +33,7 @@ def test_inherit_generator_base_builder_works():
33
 
34
  def test_generate_examples():
35
  dataset = NasaOsdr()
36
- train_data = dataset._generate_examples(dataset_root='data', split='train')
37
  idx, sample = next(iter(train_data))
38
  print(idx, sample.keys())
39
 
 
33
 
34
  def test_generate_examples():
35
  dataset = NasaOsdr()
36
+ train_data = dataset._generate_examples(assays_file='data/assays.csv', samples_file='data/samples.csv')
37
  idx, sample = next(iter(train_data))
38
  print(idx, sample.keys())
39