Datasets:

ArXiv:
License:
gorold commited on
Commit
47b3afb
1 Parent(s): ed5afb0

streamline splits

Browse files
Files changed (1) hide show
  1. cloudops_tsf.py +21 -31
cloudops_tsf.py CHANGED
@@ -13,7 +13,6 @@
13
  # limitations under the License.
14
  from dataclasses import dataclass, field
15
  from typing import Iterator, Optional
16
- from functools import cached_property
17
 
18
  import datasets
19
  import pandas as pd
@@ -157,19 +156,12 @@ class CloudOpsTSFConfig(datasets.BuilderConfig):
157
  feat_static_real_dim: int = field(default=0)
158
  past_feat_dynamic_real_dim: int = field(default=0)
159
 
160
- @cached_property
161
- def feat_static_cat_cardinalities(self) -> Optional[list[int]]:
 
162
  if FieldName.FEAT_STATIC_CAT not in self.optional_fields:
163
  return None
164
 
165
- if self.pretrain:
166
- split = "pretrain"
167
- elif self.train_test:
168
- split = "train_test"
169
- else:
170
- raise ValueError(
171
- "At least one of `train_test` and `pretrain` should be True"
172
- )
173
  return [c[1] for c in self._feat_static_cat_cardinalities[split]]
174
 
175
 
@@ -239,26 +231,24 @@ class CloudOpsTSF(datasets.ArrowBasedBuilder):
239
  )
240
 
241
  def _split_generators(self, dl_manager) -> list[datasets.SplitGenerator]:
242
- generators = []
243
- if self.config.train_test:
244
- downloaded_files = dl_manager.download_and_extract(
245
- f"{self.config.name}/train_test.zip"
246
- )
247
- generators.append(
248
- datasets.SplitGenerator(
249
- name=TRAIN_TEST if self.config.train_test else PRETRAIN,
250
- gen_kwargs={"filepath": downloaded_files},
251
- )
252
- )
253
- if self.config.pretrain:
254
- downloaded_files = dl_manager.download_and_extract(
255
- f"{self.config.name}/pretrain.zip"
256
- )
257
- generators.append(
258
- datasets.SplitGenerator(
259
- name=PRETRAIN, gen_kwargs={"filepath": downloaded_files}
260
- )
261
- )
262
  return generators
263
 
264
  def _generate_tables(self, filepath: str) -> Iterator[pa.Table]:
 
13
  # limitations under the License.
14
  from dataclasses import dataclass, field
15
  from typing import Iterator, Optional
 
16
 
17
  import datasets
18
  import pandas as pd
 
156
  feat_static_real_dim: int = field(default=0)
157
  past_feat_dynamic_real_dim: int = field(default=0)
158
 
159
+ def feat_static_cat_cardinalities(
160
+ self, split: str = "train_test"
161
+ ) -> Optional[list[int]]:
162
  if FieldName.FEAT_STATIC_CAT not in self.optional_fields:
163
  return None
164
 
 
 
 
 
 
 
 
 
165
  return [c[1] for c in self._feat_static_cat_cardinalities[split]]
166
 
167
 
 
231
  )
232
 
233
  def _split_generators(self, dl_manager) -> list[datasets.SplitGenerator]:
234
+ downloaded_files = dl_manager.download_and_extract(
235
+ [
236
+ f"{self.config.name}/train_test.zip",
237
+ f"{self.config.name}/pretrain.zip",
238
+ ]
239
+ )
240
+
241
+ generators = [
242
+ datasets.SplitGenerator(
243
+ name=TRAIN_TEST,
244
+ gen_kwargs={"filepath": downloaded_files[0]},
245
+ ),
246
+ datasets.SplitGenerator(
247
+ name=PRETRAIN,
248
+ gen_kwargs={"filepath": downloaded_files[1]},
249
+ ),
250
+ ]
251
+
 
 
252
  return generators
253
 
254
  def _generate_tables(self, filepath: str) -> Iterator[pa.Table]: