Skip to content

Commit

Permalink
docs(frontend-python): write examples guide
Browse files Browse the repository at this point in the history
  • Loading branch information
umut-sahin committed Sep 20, 2024
1 parent 867ed6c commit acf9b3a
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 0 deletions.
1 change: 1 addition & 0 deletions docs/SUMMARY.md
Original file line number Diff line number Diff line change
Expand Up @@ -106,6 +106,7 @@
* [SDFG dialect](explanations/SDFGDialect.md)
* [Call FHE circuits from other languages](explanations/call_from_other_language.md)
* [Benchmarking](dev/benchmarking.md)
* [Examples](dev/examples.md)
* [Making a release](explanations/releasing.md)
* [Release note](https://github.com/zama-ai/concrete/releases)
* [Feature request](https://github.com/zama-ai/concrete/issues/new?assignees=\&labels=feature\&projects=\&template=features.md)
Expand Down
28 changes: 28 additions & 0 deletions docs/dev/examples.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
# Examples

This document gives an overview of example structure.

## Concrete Python

### How to create an example?

There are two options to choose from:

- Option A)
- Create `examples/foo/foo.ipynb` and `examples/foo/foo_utils.py`
- Write a tutorial in the notebook
- Copy the code to utils
- Add tests for the implementation in `tests/execution/test_examples.py`
- Optionally, create `benchmarks/foo.py` and [add benchmarks](benchmarking.md#how-to-add-new-benchmarks).

- Option B)
- Create `examples/foo/foo.py`
- Write the script
- Example should contain a class called `Foo`
- `Foo` should have the following arguments in its `__init__`:
- configuration: Optional\[fhe.Configuration] = None
- compiled: bool = True
- It should compile the circuit with an appropriate inputset using the given configuration if compiled is true
- It should have any additional common utilities (e.g., encoding/decoding) shared between the tests and the benchmarks
- Then, add tests for the implementation in `tests/execution/test_examples.py`
- Optionally, create `benchmarks/foo.py` and [add benchmarks](benchmarking.md#how-to-add-new-benchmarks).

0 comments on commit acf9b3a

Please sign in to comment.