furax.io
Modules:
-
readers–
furax.io.readers
Classes:
-
AbstractReader–Abstract class for reading data from disk, avoiding recompilation and large static datasets.
Attributes:
-
logger–
logger = logging.getLogger(__name__)
module-attribute
AbstractReader
Bases: ABC
Abstract class for reading data from disk, avoiding recompilation and large static datasets.
Attributes:
-
count(int) –The number of data to read.
-
args(list[tuple[Any, ...]]) –For each data, the positional arguments to be passed to the read function.
-
keywords(list[dict[str, Any]]) –For each data, the keyword arguments to be passed to the read function.
-
common_keywords(dict[str, Any]) –For all data, the keyword arguments to be passed to the read function.
-
out_structure(PyTree[ShapeDtypeStruct]) –The structure of the data that is returned by the read function. The structure is the same for all data.
Methods:
-
__init__–Initialize the reader.
-
reset_failures–Reset runtime read failures to the known-failure baseline.
-
read–Read the data at the given index.
-
read_filler–Return finite filler data without touching any backing store.
Source code in src/furax/io/readers.py
19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 | |
count = len(self.args)
instance-attribute
common_keywords = common_keywords or {}
instance-attribute
known_failures = set(known_failures or ())
instance-attribute
total_nbytes = sum((nbytes(s)) for s in structures)
instance-attribute
out_structure = self._get_common_structure(structures)
instance-attribute
__init__(*args, common_keywords=None, structures=None, known_failures=None, **keywords)
Parameters:
-
*args(Sequence[Any], default:()) –One list per positional argument to the read function, one element per item.
-
common_keywords(Mapping[str, Any] | None, default:None) –Keyword arguments shared by all data items.
-
structures(list[PyTree[ShapeDtypeStruct]] | None, default:None) –Pre-computed per-item output structures. When provided, constructor skips all I/O and uses them directly.
-
known_failures(Sequence[int] | None, default:None) –Item indices known to be unreadable up front (e.g. their shape probe failed);
readreturns filler for them without attempting a load. -
**keywords(Sequence[Any], default:{}) –One list per keyword argument to the read function, one element per item.
Source code in src/furax/io/readers.py
reset_failures()
Reset runtime read failures to the known-failure baseline.
read records caught failures in failed_indices
as a host side effect, so a reused reader would otherwise carry failures across read passes.
Call this before a fresh pass to start from just the up-front known_failures.
failed_indices is a set: read runs inside io_callback, which JAX may dispatch
on concurrent host threads, so two threads can record the same failing index at once.
set.add is idempotent, sidestepping the check-then-append race a list would need.
Source code in src/furax/io/readers.py
read(data_index)
Read the data at the given index.
Returns:
-
PyTree[Array]–A triple
(data, padding, valid): the padded data pytree (matching -
PyTree[Array]–out_structure), the padding pytree, and a scalar boolean that isFalsewhen the -
Array–read failed.
Source code in src/furax/io/readers.py
read_filler()
Return finite filler data without touching any backing store.