@@ -45,6 +45,17 @@ def __repr__(self):
45
45
num_examples = self .num_examples or "unknown"
46
46
return "<tfds.core.SplitInfo num_examples=%s>" % str (num_examples )
47
47
48
+ @property
49
+ def file_instructions (self ):
50
+ """Returns the list of dict(filename, take, skip)."""
51
+ # `self._dataset_name` is assigned in `SplitDict.add()`.
52
+ instructions = tfrecords_reader .make_file_instructions (
53
+ name = self ._dataset_name ,
54
+ split_infos = [self ],
55
+ instruction = str (self .name ),
56
+ )
57
+ return instructions .file_instructions
58
+
48
59
49
60
class SubSplitInfo (object ):
50
61
"""Wrapper around a sub split info.
@@ -583,7 +594,10 @@ def add(self, split_info):
583
594
"""Add the split info."""
584
595
if split_info .name in self :
585
596
raise ValueError ("Split {} already present" .format (split_info .name ))
586
- # TODO(epot): Make sure this works with Named splits correctly.
597
+ # Forward the dataset name required to build file instructions:
598
+ # info.splits['train'].file_instructions
599
+ # Use `object.__setattr__`, because ProtoCls forbid new fields assignement.
600
+ object .__setattr__ (split_info , "_dataset_name" , self ._dataset_name )
587
601
super (SplitDict , self ).__setitem__ (split_info .name , split_info )
588
602
589
603
@classmethod
0 commit comments