Skip to content

Commit

Permalink
add open in gitpod buttons within nada by example
Browse files Browse the repository at this point in the history
  • Loading branch information
oceans404 committed Aug 2, 2024
1 parent bdecaf2 commit a1fb7b9
Show file tree
Hide file tree
Showing 27 changed files with 143 additions and 45 deletions.
28 changes: 22 additions & 6 deletions docs/nada-by-example-quickstart.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,18 +5,29 @@ displayed_sidebar: nadaByExampleSidebar
import Tabs from '@theme/Tabs';
import TabItem from '@theme/TabItem';
import PythonVersionInfo from './\_python-version-info.mdx';
import IframeVideo from '@site/src/components/IframeVideo/index';

# Nada by Example Local Setup Guide
# How to Run Nada by Example

All examples for "Nada by Example" live in the [nada-by-example](https://github.com/NillionNetwork/nada-by-example) Github repo. Nada programs are in [`nada-by-example/src/`](https://github.com/NillionNetwork/nada-by-example/tree/main/src) and tests are in [`nada-by-example/tests`](https://github.com/NillionNetwork/nada-by-example/tree/main/tests). After you complete local repo setup following the instructions below, you can run an example from the repo locally.
## Setup options

:::tip
All examples for "Nada by Example" live in the [nada-by-example](https://github.com/NillionNetwork/nada-by-example) Github repo. Nada programs are in [`nada-by-example/src/`](https://github.com/NillionNetwork/nada-by-example/tree/main/src) and tests are in [`nada-by-example/tests`](https://github.com/NillionNetwork/nada-by-example/tree/main/tests). To run examples, there are 2 setup options:

The [nada-by-example](https://github.com/NillionNetwork/nada-by-example) repo is a Nada project created with Nillion's [nada](/nada) tool. You can run all existing `nada` commands found in the [nada tool docs](/nada) to compile programs, get program requirements, run a program, and test a program.
:::
- Option 1: _Recommended_ - [1 click setup with Gitpod](/nada-by-example-quickstart#1-click-setup-with-gitpod)
- Option 2: [Follow the Local Setup Guide](/nada-by-example-quickstart#local-setup-guide) to clone the repo and install dependencies

### 1 Click Setup with Gitpod

[![Open in Gitpod](https://gitpod.io/button/open-in-gitpod.svg)](https://gitpod.io/#https://github.com/oceans404/nada-by-example)

Click the button above to open the Nada by Example repo in Gitpod. Then skip ahead to the [run and test an example](/nada-by-example-quickstart#how-to-run-and-test-an-example-program) section to learn how to run and test a Nada program.

<IframeVideo videoSrc="https://www.loom.com/embed/4395eeed66934142ba0feaf68a43534a?sid=785f1cc2-881a-4c30-8d96-07007251bd6b"/>


## Repo setup instructions
### Local Setup Guide

Complete local repo setup following the instructions below to run an example from the repo locally.

Install Nillion, clone the nada-by-example repo, and set up a developer environment for your local nada-by-example repo.

Expand Down Expand Up @@ -81,6 +92,11 @@ nada build

## How to run and test an example program

:::tip

The [nada-by-example](https://github.com/NillionNetwork/nada-by-example) repo is a Nada project created with Nillion's [nada](/nada) tool. You can run all existing `nada` commands found in the [nada tool docs](/nada) to compile programs, get program requirements, run a program, and test a program.
:::

Every Nada program example has a corresponding test file. Programs are in [`nada-by-example/src/`](https://github.com/NillionNetwork/nada-by-example/tree/main/src) and test files are in [`nada-by-example/tests`](https://github.com/NillionNetwork/nada-by-example/tree/main/tests). Running a program uses the inputs specified in the test file. Testing a program uses the inputs specified in the test file and also checks the outputs against the `expected_outputs` specified in the test file.


Expand Down
6 changes: 4 additions & 2 deletions docs/nada-by-example/addition.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

import Tabs from '@theme/Tabs';
import TabItem from '@theme/TabItem';

import TestProgram from '@site/src/components/TestProgram/index';

<Tabs>

Expand All @@ -17,4 +17,6 @@ https://github.com/NillionNetwork/nada-by-example/blob/main/src/addition.py
https://github.com/NillionNetwork/nada-by-example/blob/main/tests/addition_test.yaml
```
</TabItem>
</Tabs>
</Tabs>

<TestProgram programName="addition"/>
8 changes: 8 additions & 0 deletions docs/nada-by-example/comparison.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

import Tabs from '@theme/Tabs';
import TabItem from '@theme/TabItem';
import TestProgram from '@site/src/components/TestProgram/index';

## Less than `<`

Expand All @@ -20,6 +21,8 @@ https://github.com/NillionNetwork/nada-by-example/blob/main/tests/comparison_lt_
</TabItem>
</Tabs>

<TestProgram programName="comparison_lt"/>

## Less than or equal to `<=`

<Tabs>
Expand All @@ -37,6 +40,8 @@ https://github.com/NillionNetwork/nada-by-example/blob/main/tests/comparison_lte
</TabItem>
</Tabs>

<TestProgram programName="comparison_lte"/>

## Greater than `>`

<Tabs>
Expand All @@ -54,6 +59,8 @@ https://github.com/NillionNetwork/nada-by-example/blob/main/tests/comparison_gt_
</TabItem>
</Tabs>

<TestProgram programName="comparison_gt"/>

## Greater than or equal to `>=`

<Tabs>
Expand All @@ -72,4 +79,5 @@ https://github.com/NillionNetwork/nada-by-example/blob/main/tests/comparison_gte
</Tabs>


<TestProgram programName="comparison_gte"/>

2 changes: 1 addition & 1 deletion docs/nada-by-example/debugging.md
Original file line number Diff line number Diff line change
Expand Up @@ -84,4 +84,4 @@ SecretInteger(inner=<nada_dsl.operations.Addition object at 0x104ba5e20>)

## Next steps

🐛 Now that you've learned to debug, you're ready play with Nada programs. Move on to the next section where you will set up a local environment and run and test Nada programs locally following the [Nada by Example Local Setup Guide](/nada-by-example-quickstart).
🐛 Now that you've learned to debug, you're ready to write and debug your own Nada programs in the src/ repo. Check out the [Nada Operations](/nada-by-example/nada-operations) page to see examples of supported Nada operations, their syntax, and supported data types.
3 changes: 2 additions & 1 deletion docs/nada-by-example/division.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

import Tabs from '@theme/Tabs';
import TabItem from '@theme/TabItem';

import TestProgram from '@site/src/components/TestProgram/index';

<Tabs>

Expand All @@ -20,3 +20,4 @@ https://github.com/NillionNetwork/nada-by-example/blob/main/tests/division_test.
</Tabs>


<TestProgram programName="division"/>
7 changes: 6 additions & 1 deletion docs/nada-by-example/equality.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

import Tabs from '@theme/Tabs';
import TabItem from '@theme/TabItem';
import TestProgram from '@site/src/components/TestProgram/index';

## Private equality `==`

Expand All @@ -20,6 +21,8 @@ https://github.com/NillionNetwork/nada-by-example/blob/main/tests/equality_test.
</TabItem>
</Tabs>

<TestProgram programName="equality"/>

## Public output equality `==`

<Tabs>
Expand All @@ -35,4 +38,6 @@ https://github.com/NillionNetwork/nada-by-example/blob/main/src/equality_public.
https://github.com/NillionNetwork/nada-by-example/blob/main/tests/equality_public_test.yaml
```
</TabItem>
</Tabs>
</Tabs>

<TestProgram programName="equality_public"/>
2 changes: 1 addition & 1 deletion docs/nada-by-example/first-program.md
Original file line number Diff line number Diff line change
Expand Up @@ -86,4 +86,4 @@ In this example, you learned how to use Nada to create a multiplication program

The power of Nada lies in its ability to compute on secret inputs without revealing the underlying data to any party involved. This makes Nada programs perfect for applications requiring high levels of privacy and security.

Continue learning and experimenting with Nada by **learning how to debug a Nada program** in the next section.
Start experimenting with Nada by **learning how to run Nada by Example programs** in the next section.
4 changes: 2 additions & 2 deletions docs/nada-by-example/for-loop.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

import Tabs from '@theme/Tabs';
import TabItem from '@theme/TabItem';

import TestProgram from '@site/src/components/TestProgram/index';

<Tabs>

Expand All @@ -19,4 +19,4 @@ https://github.com/NillionNetwork/nada-by-example/blob/main/tests/for_loop_test.
</TabItem>
</Tabs>


<TestProgram programName="for_loop"/>
4 changes: 2 additions & 2 deletions docs/nada-by-example/helper-function.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

import Tabs from '@theme/Tabs';
import TabItem from '@theme/TabItem';

import TestProgram from '@site/src/components/TestProgram/index';

<Tabs>

Expand All @@ -19,4 +19,4 @@ https://github.com/NillionNetwork/nada-by-example/blob/main/tests/list_comprehen
</TabItem>
</Tabs>


<TestProgram programName="list_comprehensions_with_helper"/>
7 changes: 6 additions & 1 deletion docs/nada-by-example/if-else.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

import Tabs from '@theme/Tabs';
import TabItem from '@theme/TabItem';
import TestProgram from '@site/src/components/TestProgram/index';

## If / Else with a public condition

Expand All @@ -20,6 +21,8 @@ https://github.com/NillionNetwork/nada-by-example/blob/main/tests/if_else_public
</TabItem>
</Tabs>

<TestProgram programName="if_else_public"/>

## If / Else with a private condition

<Tabs>
Expand All @@ -35,4 +38,6 @@ https://github.com/NillionNetwork/nada-by-example/blob/main/src/if_else_private.
https://github.com/NillionNetwork/nada-by-example/blob/main/tests/if_else_private_test.yaml
```
</TabItem>
</Tabs>
</Tabs>

<TestProgram programName="if_else_private"/>
4 changes: 2 additions & 2 deletions docs/nada-by-example/list-comprehensions.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

import Tabs from '@theme/Tabs';
import TabItem from '@theme/TabItem';

import TestProgram from '@site/src/components/TestProgram/index';

<Tabs>

Expand All @@ -19,4 +19,4 @@ https://github.com/NillionNetwork/nada-by-example/blob/main/tests/list_comprehen
</TabItem>
</Tabs>


<TestProgram programName="list_comprehensions"/>
7 changes: 6 additions & 1 deletion docs/nada-by-example/literal-data-type.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import Tabs from '@theme/Tabs';
import TabItem from '@theme/TabItem';
import TestProgram from '@site/src/components/TestProgram/index';

# Literals

Expand All @@ -24,6 +25,8 @@ https://github.com/NillionNetwork/nada-by-example/blob/main/tests/addition_liter
</TabItem>
</Tabs>

<TestProgram programName="addition_literal"/>

## UnsignedInteger

`UnsignedInteger` represents a literal unsigned integer value. This value can be zero or a positive integer.
Expand All @@ -41,4 +44,6 @@ https://github.com/NillionNetwork/nada-by-example/blob/main/src/addition_literal
https://github.com/NillionNetwork/nada-by-example/blob/main/tests/addition_literal_unsigned_test.yaml
```
</TabItem>
</Tabs>
</Tabs>

<TestProgram programName="addition_literal_unsigned"/>
4 changes: 2 additions & 2 deletions docs/nada-by-example/modulo.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

import Tabs from '@theme/Tabs';
import TabItem from '@theme/TabItem';

import TestProgram from '@site/src/components/TestProgram/index';

<Tabs>

Expand All @@ -19,4 +19,4 @@ https://github.com/NillionNetwork/nada-by-example/blob/main/tests/modulo_test.ya
</TabItem>
</Tabs>


<TestProgram programName="modulo"/>
4 changes: 2 additions & 2 deletions docs/nada-by-example/multiplication.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

import Tabs from '@theme/Tabs';
import TabItem from '@theme/TabItem';

import TestProgram from '@site/src/components/TestProgram/index';

<Tabs>

Expand All @@ -19,4 +19,4 @@ https://github.com/NillionNetwork/nada-by-example/blob/main/tests/multiplication
</TabItem>
</Tabs>


<TestProgram programName="multiplication"/>
4 changes: 2 additions & 2 deletions docs/nada-by-example/power.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

import Tabs from '@theme/Tabs';
import TabItem from '@theme/TabItem';

import TestProgram from '@site/src/components/TestProgram/index';

<Tabs>

Expand All @@ -19,4 +19,4 @@ https://github.com/NillionNetwork/nada-by-example/blob/main/tests/power_test.yam
</TabItem>
</Tabs>


<TestProgram programName="power"/>
4 changes: 2 additions & 2 deletions docs/nada-by-example/probabilistic-truncation.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

import Tabs from '@theme/Tabs';
import TabItem from '@theme/TabItem';

import TestProgram from '@site/src/components/TestProgram/index';

<Tabs>

Expand All @@ -19,4 +19,4 @@ https://github.com/NillionNetwork/nada-by-example/blob/main/tests/probabilistic_
</TabItem>
</Tabs>


<TestProgram programName="probabilistic_truncation"/>
7 changes: 6 additions & 1 deletion docs/nada-by-example/public-data-type.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import Tabs from '@theme/Tabs';
import TabItem from '@theme/TabItem';
import TestProgram from '@site/src/components/TestProgram/index';

# Public

Expand All @@ -24,6 +25,8 @@ https://github.com/NillionNetwork/nada-by-example/blob/main/tests/addition_publi
</TabItem>
</Tabs>

<TestProgram programName="addition_public"/>

## PublicUnsignedInteger

`PublicUnsignedInteger` represents a user input public unsigned integer value. This value can be zero or a positive integer.
Expand All @@ -41,4 +44,6 @@ https://github.com/NillionNetwork/nada-by-example/blob/main/src/addition_public_
https://github.com/NillionNetwork/nada-by-example/blob/main/tests/addition_public_unsigned_test.yaml
```
</TabItem>
</Tabs>
</Tabs>

<TestProgram programName="addition_public_unsigned"/>
6 changes: 4 additions & 2 deletions docs/nada-by-example/r-p-s.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

import Tabs from '@theme/Tabs';
import TabItem from '@theme/TabItem';

import TestProgram from '@site/src/components/TestProgram/index';

<Tabs>

Expand Down Expand Up @@ -32,4 +32,6 @@ https://github.com/NillionNetwork/nada-by-example/blob/main/tests/rock_paper_sci
https://github.com/NillionNetwork/nada-by-example/blob/main/tests/rock_paper_scissors_scissors.yaml
```
</TabItem>
</Tabs>
</Tabs>

<TestProgram programName="rock_paper_scissors" testFileName="rock_paper_scissors_tie"/>
6 changes: 4 additions & 2 deletions docs/nada-by-example/reduce.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

import Tabs from '@theme/Tabs';
import TabItem from '@theme/TabItem';

import TestProgram from '@site/src/components/TestProgram/index';

<Tabs>

Expand All @@ -17,4 +17,6 @@ https://github.com/NillionNetwork/nada-by-example/blob/main/src/reduce.py
https://github.com/NillionNetwork/nada-by-example/blob/main/tests/reduce_test.yaml
```
</TabItem>
</Tabs>
</Tabs>

<TestProgram programName="reduce" />
Loading

0 comments on commit a1fb7b9

Please sign in to comment.