KeithG33 commited on
Commit
af9ac7f
·
1 Parent(s): 750a871
Files changed (1) hide show
  1. ChessBot-Dataset.py +16 -18
ChessBot-Dataset.py CHANGED
@@ -1,5 +1,4 @@
1
  import logging
2
- from datasets.data_files import DataFilesPatternsDict
3
  from datasets import (
4
  GeneratorBasedBuilder,
5
  DatasetInfo,
@@ -12,22 +11,24 @@ from datasets import (
12
  Version,
13
  BuilderConfig
14
  )
15
- from adversarial_gym.chess_env import ChessEnv
16
 
 
 
17
 
18
  class ChessPGNDataset(GeneratorBasedBuilder):
 
19
  BUILDER_CONFIGS = [
20
- BuilderConfig(
21
- name="default",
22
- version=Version("0.0.2"),
23
- description="Chess positions + moves + results, streamed from PGN shards",
24
- data_files=DataFilesPatternsDict({
25
- "train": "**/train/*.pgn",
26
- "test": "**/test/*.pgn",
27
- }),
28
- ),
29
- ]
30
- DEFAULT_CONFIG_NAME = "default"
31
  def _info(self):
32
  return DatasetInfo(
33
  description="Chess positions + moves + results, streamed from PGN shards",
@@ -41,10 +42,7 @@ class ChessPGNDataset(GeneratorBasedBuilder):
41
  def _split_generators(self, dl_manager: DownloadManager):
42
  from pathlib import Path, os
43
 
44
- logging.getLogger(__name__).info(f"Loaded config: {self.config.name}")
45
- logging.getLogger(__name__).info(f"Data files: {self.config.data_files}")
46
-
47
- if self.config.data_dir:
48
  repo_root = Path(self.config.data_dir)
49
  train_files = [repo_root / 'train' / f for f in os.listdir(repo_root / 'train')]
50
  test_files = [repo_root / 'test' / f for f in os.listdir(repo_root / 'test')]
@@ -67,7 +65,7 @@ class ChessPGNDataset(GeneratorBasedBuilder):
67
  gen_kwargs={"shards": test_paths},
68
  ),
69
  ]
70
-
71
  def _generate_examples(self, shards):
72
  import chess.pgn
73
  uid = 0
 
1
  import logging
 
2
  from datasets import (
3
  GeneratorBasedBuilder,
4
  DatasetInfo,
 
11
  Version,
12
  BuilderConfig
13
  )
 
14
 
15
+ from datasets.data_files import sanitize_patterns, DataFilesDict
16
+ from adversarial_gym.chess_env import ChessEnv
17
 
18
  class ChessPGNDataset(GeneratorBasedBuilder):
19
+ VERSION = "0.0.1"
20
  BUILDER_CONFIGS = [
21
+ BuilderConfig(
22
+ name="default",
23
+ version=Version("0.0.2"), # bump version so HF reloads your updated code
24
+ description="Chess PGN stream",
25
+ data_files=DataFilesDict.from_patterns(sanitize_patterns({
26
+ "train": "train/*.pgn",
27
+ "test": "test/*.pgn",
28
+ })),
29
+ ),
30
+ ]
31
+
32
  def _info(self):
33
  return DatasetInfo(
34
  description="Chess positions + moves + results, streamed from PGN shards",
 
42
  def _split_generators(self, dl_manager: DownloadManager):
43
  from pathlib import Path, os
44
 
45
+ if self.config.data_dir or self.config.data_files is None:
 
 
 
46
  repo_root = Path(self.config.data_dir)
47
  train_files = [repo_root / 'train' / f for f in os.listdir(repo_root / 'train')]
48
  test_files = [repo_root / 'test' / f for f in os.listdir(repo_root / 'test')]
 
65
  gen_kwargs={"shards": test_paths},
66
  ),
67
  ]
68
+
69
  def _generate_examples(self, shards):
70
  import chess.pgn
71
  uid = 0