Save newly-created datapoints to disk. Args: examples: A list of datapoints to save. path: The path to save the datapoints to. Returns: (string) The file path of the saved datapoints.
(self, examples: list[IndexedInput], path: str)
| 336 | return types.MappingProxyType(self._index) |
| 337 | |
| 338 | def save(self, examples: list[IndexedInput], path: str): |
| 339 | """Save newly-created datapoints to disk. |
| 340 | |
| 341 | Args: |
| 342 | examples: A list of datapoints to save. |
| 343 | path: The path to save the datapoints to. |
| 344 | |
| 345 | Returns: |
| 346 | (string) The file path of the saved datapoints. |
| 347 | """ |
| 348 | # Attempt to save the datapoints using the base save method, which |
| 349 | # datasets can override. Then also save in the lit json format and save |
| 350 | # the spec as well. |
| 351 | if not path.endswith(LIT_FILE_EXTENSION): |
| 352 | if (base_dataset := self._base) is not None: |
| 353 | base_dataset.save(examples, path) |
| 354 | path += LIT_FILE_EXTENSION |
| 355 | |
| 356 | write_examples(examples, path) |
| 357 | write_spec(self.spec(), path + LIT_SPEC_EXTENSION) |
| 358 | |
| 359 | return path |
| 360 | |
| 361 | def load(self, path: str): |
| 362 | """Load and return additional previously-saved datapoints for this dataset. |
nothing calls this directly
no test coverage detected