thomasyu888 commited on
Commit
2ec3211
·
1 Parent(s): df1bb86

Update testdataset.py

Browse files
Files changed (1) hide show
  1. testdataset.py +13 -1
testdataset.py CHANGED
@@ -91,6 +91,16 @@ class TestDataset(datasets.GeneratorBasedBuilder):
91
 
92
  DEFAULT_CONFIG_NAME = "testdataset_source"
93
 
 
 
 
 
 
 
 
 
 
 
94
  def _info(self) -> datasets.DatasetInfo:
95
  features = datasets.Features(
96
  {
@@ -112,7 +122,9 @@ class TestDataset(datasets.GeneratorBasedBuilder):
112
  )
113
 
114
  def _split_generators(self, dl_manager) -> List[datasets.SplitGenerator]:
115
- data_dir = self.config.data_dir
 
 
116
  if data_dir is None:
117
  raise ValueError(
118
  "This is a local dataset. Please pass the data_dir kwarg to load_dataset."
 
91
 
92
  DEFAULT_CONFIG_NAME = "testdataset_source"
93
 
94
+ def _download_from_synapse(syn_id, path):
95
+ try:
96
+ import synapseclient
97
+ import synapseutils
98
+ except ModuleNotFoundError as e:
99
+ raise ModuleNotFoundError("synapseclient must be installed. pip install synapseclient")
100
+ syn = synapseclient.login()
101
+ synapseutils.syncFromSynapse(syn, syn_id, path=path)
102
+ # syn.get(entity=syn_id, downloadLocation=path)
103
+
104
  def _info(self) -> datasets.DatasetInfo:
105
  features = datasets.Features(
106
  {
 
122
  )
123
 
124
  def _split_generators(self, dl_manager) -> List[datasets.SplitGenerator]:
125
+ # This is where we can call the custom download function for Synapse
126
+ data_dir = dl_manager.download_custom(_SYN_ID, self._download_from_synapse)
127
+ # data_dir = self.config.data_dir
128
  if data_dir is None:
129
  raise ValueError(
130
  "This is a local dataset. Please pass the data_dir kwarg to load_dataset."