ArneBinder commited on
Commit
70446e7
1 Parent(s): d921d5b

use config.data_dir instead of checking if url points to local directory

Browse files

this fixes "NotImplementedError: os.path.isdir is not extended to support URLs in streaming mode" when calling with a remote (zip) target as url.

Files changed (1) hide show
  1. brat.py +8 -11
brat.py CHANGED
@@ -301,20 +301,17 @@ class Brat(datasets.GeneratorBasedBuilder):
301
  def _split_generators(self, dl_manager):
302
  """Returns SplitGenerators."""
303
 
304
- subdirectory_mapping = self.config.subdirectory_mapping
305
-
306
- # since subclasses of BuilderConfig are not allowed to define
307
- # attributes without defaults, check here
308
- assert self.config.url is not None, "data url not specified"
309
-
310
- # if url points to a local directory, just point to that
311
- if path.exists(self.config.url) and path.isdir(self.config.url):
312
- data_dir = self.config.url
313
- # otherwise, download and extract
314
  else:
 
 
 
 
315
  data_dir = dl_manager.download_and_extract(self.config.url)
316
- logging.info(f"load from data dir: {data_dir}")
317
 
 
318
  # if no subdirectory mapping is provided, ...
319
  if subdirectory_mapping is None:
320
  # ... use available subdirectories as split names ...
 
301
  def _split_generators(self, dl_manager):
302
  """Returns SplitGenerators."""
303
 
304
+ if self.config.data_dir is not None:
305
+ data_dir = self.config.data_dir
306
+ logging.warning(f"load from data_dir: {data_dir}")
 
 
 
 
 
 
 
307
  else:
308
+ # since subclasses of BuilderConfig are not allowed to define
309
+ # attributes without defaults, check here
310
+ assert self.config.url is not None, "data url not specified"
311
+
312
  data_dir = dl_manager.download_and_extract(self.config.url)
 
313
 
314
+ subdirectory_mapping = self.config.subdirectory_mapping
315
  # if no subdirectory mapping is provided, ...
316
  if subdirectory_mapping is None:
317
  # ... use available subdirectories as split names ...