From acf9b3a745027ca7376d10a875a3d673b150c122 Mon Sep 17 00:00:00 2001 From: Umut Date: Fri, 20 Sep 2024 13:56:33 +0300 Subject: [PATCH] docs(frontend-python): write examples guide --- docs/SUMMARY.md | 1 + docs/dev/examples.md | 28 ++++++++++++++++++++++++++++ 2 files changed, 29 insertions(+) create mode 100644 docs/dev/examples.md diff --git a/docs/SUMMARY.md b/docs/SUMMARY.md index d14e4de866..84af7fc8be 100644 --- a/docs/SUMMARY.md +++ b/docs/SUMMARY.md @@ -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) diff --git a/docs/dev/examples.md b/docs/dev/examples.md new file mode 100644 index 0000000000..d1785c986f --- /dev/null +++ b/docs/dev/examples.md @@ -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).