Skip to content

Commit

Permalink
Merge pull request #87 from NillionNetwork/chore/css-content-updates
Browse files Browse the repository at this point in the history
Chore/css content updates
  • Loading branch information
oceans404 authored Aug 28, 2024
2 parents 3e87b9b + 80d07a0 commit 21a02cd
Show file tree
Hide file tree
Showing 5 changed files with 151 additions and 133 deletions.
2 changes: 1 addition & 1 deletion docs/community-and-support.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,5 +19,5 @@ Got a suggestion for improving the docs? Let us know by [creating a Github Issue
### How to open a support ticket

1. Join our [Discord](https://discord.com/invite/nillionnetwork)
2. Visit the [#support-ticket](https://discord.com/channels/905926225120338000/927874817355563018) channel
2. Visit the #support-ticket Discord channel
3. Create a ticket (General support or Partnership request)
36 changes: 18 additions & 18 deletions docs/nada-by-example-quickstart.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,26 +7,28 @@ import TabItem from '@theme/TabItem';
import PythonVersionInfo from './\_python-version-info.mdx';
import IframeVideo from '@site/src/components/IframeVideo/index';

# How to Run Nada by Example
# How to Run Nada by Example

## Setup options

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:

- 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. _Recommended_ - 1 Click Gitpod Setup
2. Local Machine Setup

### 1 Click Setup with Gitpod
<Tabs>

<TabItem value="gitpod" label="1 Click Gitpod Setup" default>

[![Open in Gitpod](https://gitpod.io/button/open-in-gitpod.svg)](https://gitpod.io/#https://github.com/nillionnetwork/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.
Click the button above to open the Nada by Example repo in Gitpod. Then follow 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"/>

</TabItem>

### Local Setup Guide

<TabItem value="local" label="Local Machine Setup">
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 @@ -87,8 +89,9 @@ nada build

`nada build` is a [nada tool command](/nada#build-compile-a-program) that compiles programs to create one compiled binary (.nada.bin) file per program listed in the [nada-project.toml file](https://github.com/NillionNetwork/nada-by-example/blob/main/nada-project.toml) in the target/ directory.


✅ Great work! Now that you've set up the nada-by-example repo, you can run any example.
</TabItem>
</Tabs>

## How to run and test an example program

Expand All @@ -99,7 +102,6 @@ The [nada-by-example](https://github.com/NillionNetwork/nada-by-example) repo is

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.


Run any program with the inputs specified in the test file with [`nada run`](/nada#run-a-program)

```
Expand All @@ -112,8 +114,7 @@ Test any program with the inputs and outputs specified in the test file with [`n
nada test <test-file-name>
```


### Run the addition example
### Run the addition example

Here is the Nada program and test file for the addition example. The program is [src/addition.py](https://github.com/NillionNetwork/nada-by-example/blob/main/src/addition.py) and the test file is [tests/addition_test.yaml](https://github.com/NillionNetwork/nada-by-example/blob/main/tests/addition_test.yaml)

Expand Down Expand Up @@ -155,7 +156,7 @@ Outputs: {
}
```

### Test the addition example
### Test the addition example

Here is the Nada program and test file for the addition example. The program is [src/addition.py](https://github.com/NillionNetwork/nada-by-example/blob/main/src/addition.py) and the test file is [tests/addition_test.yaml](https://github.com/NillionNetwork/nada-by-example/blob/main/tests/addition_test.yaml)

Expand Down Expand Up @@ -192,7 +193,7 @@ addition_test: PASS

Testing the addition program with `addition_test` results in a PASS because the expected_outputs `sum` output matches the run result.

### Add a new test for the addition example
### Add a new test for the addition example

Use the [nada tool](/nada#generate-a-test-file) to add a new test file named "addition_test_2" for the addition example.

Expand All @@ -217,13 +218,12 @@ Update the values in the test file to anything you want, for example:
program: addition
inputs:
num_1:
SecretInteger: "100"
SecretInteger: '100'
num_2:
SecretInteger: "10"
SecretInteger: '10'
expected_outputs:
sum:
SecretInteger: "110"

SecretInteger: '110'
```
#### Run addition with your new test
Expand All @@ -240,4 +240,4 @@ nada test addition_test_2

## Keep exploring examples

🥳 You're all set up to run and test any example in [nada-by-example](https://github.com/NillionNetwork/nada-by-example). Keep exploring what's possible with Nada by running the rest of the programs in the repo.
🥳 You're all set up to run and test any example in [nada-by-example](https://github.com/NillionNetwork/nada-by-example). Keep exploring what's possible with Nada by running the rest of the programs in the repo.
210 changes: 103 additions & 107 deletions docs/nada-debugging.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,121 +10,117 @@ These few tips when setting up your project can help ensure a healthier developm

1. **Don't use `main` to write your code**: Instead, write it in another `.py` file, import it, and execute it. This way, we can use multiple test files for each piece of code, ensuring consistent behavior.

<table>
<tr>
<th>DO:</th>
<th>DON'T:</th>
</tr>
<tr>
<td>

```bash
src
├── lib.py
└── main.py
```

```python
# lib.py
from nada_dsl import *
def func(a, b):
return a + b
```

```python
# main.py
from nada_dsl import *
from lib import func
def main():
...
c = func(a, b)
...
```
</td>
<td>

```bash
src
└── main.py
```

```python
# main.py
from nada_dsl import *
def func(a, b):
return a + b
def main():
...
c = func(a, b)
...
```
</td>
</tr>
</table>
<table>
<tr>
<th>DO:</th>
<th>DON'T:</th>
</tr>
<tr>
<td>

```bash
src
├── lib.py
└── main.py
```

```python
# lib.py
from nada_dsl import *
def func(a, b):
return a + b
```

```python
# main.py
from nada_dsl import *
from lib import func
def main():
...
c = func(a, b)
...
```

</td>
<td>

```bash
src
└── main.py
```

```python
# main.py
from nada_dsl import *
def func(a, b):
return a + b
def main():
...
c = func(a, b)
...
```

</td>
</tr>
</table>

2. **Create and test multiple compilation units**: Using the `nada` project management tool, one can create multiple independent compilation units, that is, programs that compile independently. To create a separate compilation unit, follow these steps:

* Add the following line to `nada-project.toml`:
```toml
[[programs]]
path = "src/test_func.py" # test_func must be replaced by the name of your choice.
prime_size = 128 # Can also be 64 or 256
```
- Add the following line to `nada-project.toml`:

* Create the appropriate file in the `src/` directory, in this case, `test_func.py`:
```toml
[[programs]]
path = "src/test_func.py" # test_func must be replaced by the name of your choice.
prime_size = 128 # Can also be 64 or 256
```

```bash
src
├── lib.py
├── main.py
└── test_func.py
```
- Create the appropriate file in the `src/` directory, in this case, `test_func.py`:

* Use this file to test a single functionality, in this case our function `func`:
```bash
src
├── lib.py
├── main.py
└── test_func.py
```

```python
# test_func.py
from nada_dsl import *
from lib import func
- Use this file to test a single functionality, in this case our function `func`:

def main():
...
c = func(a, b)
...
```
```python
# test_func.py
from nada_dsl import *
from lib import func
After this point, whenever we execute `nada build`, `nada` will compile all the programs in the `nada-project.toml` file. This can serve as a way to test that any changes do not break other functionalities. Furthermore, if you wish to compile a single file, you can do so with: `nada build <file>`, in this case `nada build test_func`.
def main():
...
c = func(a, b)
...
```

After this point, whenever we execute `nada build`, `nada` will compile all the programs in the `nada-project.toml` file. This can serve as a way to test that any changes do not break other functionalities. Furthermore, if you wish to compile a single file, you can do so with: `nada build <file>`, in this case `nada build test_func`.

3. **Add Tests for Every Function**: Adding tests for every function can be a good way to detect wrong behavior and to test for corner cases. For that, you can use `nada generate-test` to produce a test file named `test_func_1.yaml` in the `tests/` directory, with the following command:
```bash
# nada generate-test --test-name <test_name> <source_file>
nada generate-test --test-name test_func_1 test_func
```

This will produce the following tree:

```bash
├── src
│   ├── lib.py
│   ├── main.py
│   └── test_func.py
└── tests
└── test_func_1.yaml
```
You can create as many tests as you wish for the same compilation unit. If you execute `nada test`, it will execute all the existing tests for all compilation units. This can be a good way to check for any regression errors in your Nada programs. If you wish to execute the tests for a single file, you can do so with `nada test test_func_1`.

4. **Don't use `print` to debug**: Using `print` statements to debug is a usual way to diagnose the potential misbehavior of a program. However, Nada DSL does **not** currently support `print` statements and will fail if any are included. The best way to diagnose the behavior at a certain point is to use Python exceptions. The following is an example to understand the type of a variable:
```python
my_int1 = SecretInteger(Input(name="my_int1", party=party1))
my_int2 = SecretInteger(Input(name="my_int2", party=party1))
new_int = my_int1 + my_int2
raise Exception(type(new_int)) # Exception on the type
```
This exception will show us which type the `new_int` variable holds and can help us reason about what is failing in our program.

```bash
# nada generate-test --test-name <test_name> <source_file>
nada generate-test --test-name test_func_1 test_func
```

This will produce the following tree:

```bash
├── src
│   ├── lib.py
│   ├── main.py
│   └── test_func.py
└── tests
└── test_func_1.yaml
```

You can create as many tests as you wish for the same compilation unit. If you execute `nada test`, it will execute all the existing tests for all compilation units. This can be a good way to check for any regression errors in your Nada programs. If you wish to execute the tests for a single file, you can do so with `nada test test_func_1`.

4. Use `print` to debug: Follow our [Debugging with print()](/nada-by-example/debugging#debugging-with-print) guide to learn how to inspect the values and types of variables at various points in your Nada program code.
22 changes: 19 additions & 3 deletions docs/nucleus-builders-program.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,24 @@ description: Apply to the Nucleus Builders Program to start building on Nillion

# Nucleus Builders Program

Nillion is on a mission to decentralize high value data across a wave of new web3 use cases and industries. We are working directly with builders to achieve this vision. Nucleus is Nillion's builders program dedicated to nurturing the development and expansion of high value data focused applications.
Nillion is on a mission to decentralize high value data across a wave of new web3 use cases and industries. We are working directly with builders to achieve this vision. Nucleus is designed to support and empower developers as they build on the Nillion Network.

### The Genesis Cohort
## Join the Nucleus Builders Program

The [Genesis Cohort of Nucleus](https://medium.com/@Nillion_Network/next-on-nillion-the-nucleus-builders-program-45aeaf158214) includes 12 teams building self-sovereign AI data monetization, private order books, highly secure messaging and sharing apps, and many other interesting use cases. We will continue adding projects to the Genesis Cohort through to the beginning of April. If you are a developer, team, or project interested in being an early builder on the Nillion Network, [apply to our Nucleus Builders Program](https://app.deform.cc/form/51a162ff-4ffb-4d9b-86ec-249f087a332f/).
The [Genesis Cohort of Nucleus](https://medium.com/@Nillion_Network/next-on-nillion-the-nucleus-builders-program-45aeaf158214) includes 12+ teams building self-sovereign AI data monetization, private order books, highly secure messaging and sharing apps, and many other interesting use cases. If you are a developer, team, or project interested in building a startup on the Nillion Network, [apply to our Nucleus Builders Program](https://app.deform.cc/form/51a162ff-4ffb-4d9b-86ec-249f087a332f/).

## Support

We provide comprehensive support across all key areas — technical, financial, marketing, and business to ensure that your journey from concept to production is smooth and successful.

### Technical Support

We are committed to your success every step of the way. Nucleus offers weekly support sessions, where our technical experts work closely with you to guide the development of your project on the Nillion Network. Beyond these sessions, we provide daily communication through dedicated support channels, ensuring you have the resources and guidance needed to overcome any challenges and bring your product to life.

### Financial Support

We believe in aligning our interests with those of our builders. We offer Nucleus builders a robust financial support package, including network credits that cover storage and compute costs on the Nillion Network. Additionally, our token compensation rewards provide tangible economic benefits as you build on our platform.

### Marketing & Business Support

Your innovation deserves recognition. As part of Nucleus, we help raise awareness of your use cases through a range of marketing initiatives. From AMAs and Twitter Spaces to featured articles and more, we actively promote your projects to the broader community, helping you gain visibility and traction.
14 changes: 10 additions & 4 deletions src/css/custom.css
Original file line number Diff line number Diff line change
Expand Up @@ -76,10 +76,6 @@ h4 {
font-size: 30px;
}

[data-theme='dark'] .header-github:hover {
filter: invert(0.8);
}

.header-github:hover {
opacity: 0.6;
}
Expand All @@ -92,3 +88,13 @@ h4 {
background: url("data:image/svg+xml,%3Csvg viewBox='0 0 24 24' xmlns='http://www.w3.org/2000/svg'%3E%3Cpath fill='white' d='M12 .297c-6.63 0-12 5.373-12 12 0 5.303 3.438 9.8 8.205 11.385.6.113.82-.258.82-.577 0-.285-.01-1.04-.015-2.04-3.338.724-4.042-1.61-4.042-1.61C4.422 18.07 3.633 17.7 3.633 17.7c-1.087-.744.084-.729.084-.729 1.205.084 1.838 1.236 1.838 1.236 1.07 1.835 2.809 1.305 3.495.998.108-.776.417-1.305.76-1.605-2.665-.3-5.466-1.332-5.466-5.93 0-1.31.465-2.38 1.235-3.22-.135-.303-.54-1.523.105-3.176 0 0 1.005-.322 3.3 1.23.96-.267 1.98-.399 3-.405 1.02.006 2.04.138 3 .405 2.28-1.552 3.285-1.23 3.285-1.23.645 1.653.24 2.873.12 3.176.765.84 1.23 1.91 1.23 3.22 0 4.61-2.805 5.625-5.475 5.92.42.36.81 1.096.81 2.22 0 1.606-.015 2.896-.015 3.286 0 .315.21.69.825.57C20.565 22.092 24 17.592 24 12.297c0-6.627-5.373-12-12-12'/%3E%3C/svg%3E")
no-repeat;
}

/* Dark mode css */

[data-theme='dark'] .header-github:hover {
filter: invert(0.8);
}

[data-theme='dark'] .sidebar-title {
border-bottom: solid rgb(96, 103, 112) 1px;
}

0 comments on commit 21a02cd

Please sign in to comment.