Datasets:

ArXiv:
License:
NamCyan commited on
Commit
9d0d843
1 Parent(s): 2bbcda8
Files changed (1) hide show
  1. the-vault.py +18 -27
the-vault.py CHANGED
@@ -44,7 +44,7 @@ splits = ["all"] + list(num_shard_split.keys())
44
  class TheVaultConfig(datasets.BuilderConfig):
45
  """BuilderConfig for The Vault dataset."""
46
 
47
- def __init__(self, *args, languages=["all"], split_set= "all", **kwargs):
48
  """BuilderConfig for the GitHub Code dataset.
49
  Args:
50
  languages (:obj:`List[str]`): List of languages to load.
@@ -58,9 +58,12 @@ class TheVaultConfig(datasets.BuilderConfig):
58
 
59
  languages = set(languages)
60
 
61
- assert all([language in _LANG_CONFIGS for language in languages]), f"Language not in {_LANG_CONFIGS}."
62
- assert split_set in splits, "split_set {} not in {}.".format(split_set, splits)
63
 
 
 
 
64
  if "all" in languages:
65
  assert len(languages)==1, f"Passed 'all' together with other languages. {languages}"
66
  self.filter_languages = False
@@ -106,40 +109,28 @@ class TheVault(datasets.GeneratorBasedBuilder):
106
 
107
  def _split_generators(self, dl_manager):
108
  print(self.config.split_set)
109
- if self.config.split_set == "all":
110
- generators = []
111
- for split in num_shard_split:
112
- num_shards = num_shard_split[split]
113
- data_files = [
114
- f"data/{split}-{_index:05d}-of-{num_shards:05d}.parquet"
115
- for _index in range(num_shards)
116
- ]
117
- files = dl_manager.download(data_files)
118
- generators.append(
119
- datasets.SplitGenerator(
120
- name=split.replace("/", "_"),
121
- gen_kwargs={
122
- "files": files,
123
- },
124
- ),
125
- )
126
- return generators
127
 
128
- else:
129
- num_shards = num_shard_split[self.config.split_set]
 
 
 
 
 
130
  data_files = [
131
- f"data/{self.config.split_set}-{_index:05d}-of-{num_shards:05d}.parquet"
132
  for _index in range(num_shards)
133
  ]
134
  files = dl_manager.download(data_files)
135
- return [
136
  datasets.SplitGenerator(
137
- name=self.config.split_set.replace("/", "_"),
138
  gen_kwargs={
139
  "files": files,
140
  },
141
  ),
142
- ]
 
143
 
144
  def _generate_examples(self, files):
145
  key = 0
 
44
  class TheVaultConfig(datasets.BuilderConfig):
45
  """BuilderConfig for The Vault dataset."""
46
 
47
+ def __init__(self, *args, languages=["all"], split_set= ["all"], **kwargs):
48
  """BuilderConfig for the GitHub Code dataset.
49
  Args:
50
  languages (:obj:`List[str]`): List of languages to load.
 
58
 
59
  languages = set(languages)
60
 
61
+ assert all([language in _LANG_CONFIGS for language in languages]), f"languages {languages} contains language not in {_LANG_CONFIGS}."
62
+ assert all([split in splits for split in split_set]), "split_set {} contains element not in {}.".format(split_set, splits)
63
 
64
+ if "all" in split_set:
65
+ assert len(split_set)==1, f"Passed 'all' together with other split sets. {split_set}"
66
+
67
  if "all" in languages:
68
  assert len(languages)==1, f"Passed 'all' together with other languages. {languages}"
69
  self.filter_languages = False
 
109
 
110
  def _split_generators(self, dl_manager):
111
  print(self.config.split_set)
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
112
 
113
+ generators = []
114
+ split_set = self.config.split_set
115
+ if "all" in split_set:
116
+ split_set = list(num_shard_split.keys())
117
+
118
+ for split in split_set:
119
+ num_shards = num_shard_split[split]
120
  data_files = [
121
+ f"data/{split}-{_index:05d}-of-{num_shards:05d}.parquet"
122
  for _index in range(num_shards)
123
  ]
124
  files = dl_manager.download(data_files)
125
+ generators.append(
126
  datasets.SplitGenerator(
127
+ name=split.replace("/", "_"),
128
  gen_kwargs={
129
  "files": files,
130
  },
131
  ),
132
+ )
133
+ return generators
134
 
135
  def _generate_examples(self, files):
136
  key = 0