Skip to content

Commit

Permalink
Add full example appendix
Browse files Browse the repository at this point in the history
  • Loading branch information
nicholasjng committed Mar 15, 2024
1 parent 16179d1 commit 76d08be
Showing 1 changed file with 8 additions and 0 deletions.
8 changes: 8 additions & 0 deletions docs/guides/transforms.md
Original file line number Diff line number Diff line change
Expand Up @@ -51,3 +51,11 @@ A few points are useful to keep in mind while writing transforms:
* It is in general not advised to inject arbitrary metadata into records via a transform. If you find yourself needing to supply more metadata, consider using a `ContextProvider` instead.
* When serializing Python values (like the benchmark parameters), be careful to choose a unique representation, otherwise you might not be able to reconstruct model and data versions from written records.
* When designing a transform that is not invertible, consider raising a `NotImplementedError` in the `iapply()` method to prevent accidental calls to the (ill-defined) inverse.

## Appendix: The full example code

Here is the full example on how to use transforms for record-to-file serialization:

```python
--8<-- "examples/transforms/transforms.py"
```

0 comments on commit 76d08be

Please sign in to comment.