Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove pybuilder, Add poetry #215

Merged
merged 45 commits into from
Mar 8, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
45 commits
Select commit Hold shift + click to select a range
697992e
Remove pybuilder, use flakeheaven, bandit
mgkwill Mar 7, 2022
f16df42
Update build-requirements.txt
mgkwill Mar 7, 2022
8aecca6
Delete build.py
mgkwill Mar 7, 2022
def4b0a
Update pyproject.toml
mgkwill Mar 7, 2022
f673724
Update setup.py
mgkwill Mar 7, 2022
4341b0d
Add poetry
mgkwill Mar 7, 2022
9a67dbe
Run unit tests with pytest
mgkwill Mar 7, 2022
848b2d2
Rename CI jobs
mgkwill Mar 7, 2022
d9b396a
Update pyproject.toml
mgkwill Mar 7, 2022
ec278ff
Update pyproject.toml
mgkwill Mar 7, 2022
5616d66
Update mnist.py
mgkwill Mar 7, 2022
1532e98
Update ci-build.yml
mgkwill Mar 7, 2022
3339ae3
Update pyproject.toml
mgkwill Mar 7, 2022
927eb8d
Update ci-build.yml
mgkwill Mar 7, 2022
9cfb460
Update ci-build.yml
mgkwill Mar 7, 2022
7bde1cd
Update pyproject.toml
mgkwill Mar 7, 2022
17dabb7
Update build-requirements.txt
mgkwill Mar 7, 2022
9123a06
Update requirements.txt
mgkwill Mar 7, 2022
d2fcd8c
Update pyproject.toml
mgkwill Mar 7, 2022
59b76d9
Update ci-build.yml
mgkwill Mar 7, 2022
da864d3
Update ci-build.yml
mgkwill Mar 7, 2022
7917e50
Delete requirements.txt
mgkwill Mar 7, 2022
cf589b6
Delete build-requirements.txt
mgkwill Mar 7, 2022
9a9a187
Create poetry.lock
mgkwill Mar 7, 2022
63d8f0f
Update ci-build.yml
mgkwill Mar 7, 2022
6b1a5af
Update ci-build.yml
mgkwill Mar 7, 2022
8222922
Update ci-build.yml
mgkwill Mar 7, 2022
ff38213
Update ci-build.yml
mgkwill Mar 7, 2022
4e99120
Update ci-build.yml
mgkwill Mar 7, 2022
f18f2c6
Update ci-build.yml
mgkwill Mar 7, 2022
b79cffd
Update ci-build.yml
mgkwill Mar 7, 2022
2dbc7d3
Update ci-build.yml
mgkwill Mar 7, 2022
1d3e6be
Update ci-build.yml
mgkwill Mar 7, 2022
3ff6e91
Update ci-build.yml
mgkwill Mar 7, 2022
1339ad0
Update pyproject.toml
mgkwill Mar 7, 2022
9586eda
Update ci-build.yml
mgkwill Mar 7, 2022
f5b18b5
Update ci-build.yml
mgkwill Mar 7, 2022
fc08e44
Update pyproject.toml
mgkwill Mar 7, 2022
5dfa117
Update ci-build.yml
mgkwill Mar 7, 2022
095415e
Update ci-build.yml
mgkwill Mar 7, 2022
32bad14
Update poetry.lock
mgkwill Mar 7, 2022
beed2f6
Delete setup.py
mgkwill Mar 7, 2022
1bfb652
Update PULL_REQUEST_TEMPLATE.md
mgkwill Mar 7, 2022
ad27c26
Update README.md
mgkwill Mar 8, 2022
2803bac
Update PULL_REQUEST_TEMPLATE.md
mgkwill Mar 8, 2022
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions .github/PULL_REQUEST_TEMPLATE.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,8 @@ Your PR fulfills the following requirements:
- [ ] [Docs](https://github.com/lava-nc/docs) reviewed and added / updated if needed (for bug fixes / features)
- [ ] PR conforms to [Coding Conventions](https://lava-nc.org/developer_guide.html#coding-conventions)
- [ ] [PR applys BSD 3-clause or LGPL2.1+ Licenses](https://lava-nc.org/developer_guide.html#add-a-license) to all code files
- [ ] Lint (`pyb`) passes locally
- [ ] Build tests (`pyb -E unit`) or (`python -m unittest`) passes locally
- [ ] Lint (`flakeheaven lint src/lava tests/`) and (`bandit -r src/lava/.`) pass locally
- [ ] Build tests (`pytest`) passes locally


## Pull request type
Expand Down
99 changes: 81 additions & 18 deletions .github/workflows/ci-build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ on: [push, pull_request]

jobs:
lint:
name: Lint with flake8
name: Lint Code
runs-on: ubuntu-latest

steps:
Expand All @@ -14,17 +14,40 @@ jobs:
with:
python-version: 3.9

- name: Install Poetry
uses: snok/install-poetry@v1
with:
virtualenvs-create: true
virtualenvs-in-project: true

- name: Load cached venv
id: cached-poetry-dependencies
uses: actions/cache@v2
with:
path: ~/.cache
key: venv-${{ runner.os }}-${{ steps.setup-python.outputs.python-version }}-01-${{ hashFiles('**/poetry.lock') }}

- name: Install dependencies
if: steps.cached-poetry-dependencies.outputs.cache-hit != 'true'
run: poetry install --no-interaction --no-root

- name: Install Lava
run: poetry install --no-interaction

- name: Run flakeheaven (flake8)
if: runner.os == 'Linux' || runner.os == 'macOS'
run: |
python -m pip install --upgrade pip
pip install pybuilder
source $VENV
flakeheaven lint src/lava tests/

- name: Run pybuilder w/o unit tests
- name: Run flakeheaven (flake8)
if: runner.os == 'Windows'
run: |
pyb analyze
.venv\Scripts\activate.ps1
flakeheaven lint src/lava tests/

security-lint:
name: Security Lint with bandit
name: Security Lint Code
runs-on: ubuntu-latest

steps:
Expand All @@ -35,17 +58,35 @@ jobs:
with:
python-version: 3.9

- name: Install Poetry
uses: snok/install-poetry@v1
with:
virtualenvs-create: true
virtualenvs-in-project: true

- name: Load cached venv
id: cached-poetry-dependencies
uses: actions/cache@v2
with:
path: ~/.cache
key: venv-${{ runner.os }}-${{ steps.setup-python.outputs.python-version }}-01-${{ hashFiles('**/poetry.lock') }}

- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install pybuilder
if: steps.cached-poetry-dependencies.outputs.cache-hit != 'true'
run: poetry install --no-interaction --no-root

- name: Run pybuilder to lint security w/ bandit
run: |
pyb bandit
- name: Install Lava
run: poetry install --no-interaction

- name: Run bandit
uses: tj-actions/[email protected]
with:
targets: |
src/lava/.
options: "-r --format custom --msg-template '{abspath}:{line}: {test_id}[bandit]: {severity}: {msg}'"

unit-tests:
name: Run unit tests
name: Unit Test Code + Coverage
runs-on: ${{ matrix.operating-system }}
strategy:
matrix:
Expand All @@ -59,12 +100,34 @@ jobs:
with:
python-version: 3.9

- name: Install Poetry
uses: snok/install-poetry@v1
with:
virtualenvs-create: true
virtualenvs-in-project: true

- name: Load cached venv
id: cached-poetry-dependencies
uses: actions/cache@v2
with:
path: ~/.cache
key: venv-${{ runner.os }}-${{ steps.setup-python.outputs.python-version }}-01-${{ hashFiles('**/poetry.lock') }}

- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install -r requirements.txt
pip install .
if: steps.cached-poetry-dependencies.outputs.cache-hit != 'true'
run: poetry install --no-interaction --no-root

- name: Install Lava
run: poetry install --no-interaction

- name: Run unit tests
if: runner.os == 'Linux' || runner.os == 'macOS'
run: |
source $VENV
pytest

- name: Run unit tests
if: runner.os == 'Windows'
run: |
python -m unittest
.venv\Scripts\activate.ps1
pytest
99 changes: 57 additions & 42 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -65,53 +65,68 @@ All of Lava's core APIs and higher-level components are released, by default, wi

### Cloning Lava and Running from Source

We highly recommend cloning the repository and using pybuilder to setup lava.
You will need to install pybuilder for the same.
We highly recommend cloning the repository and using poetry to setup lava.
You will need to install poetry.

Open a python terminal and run based on the OS you are on:

#### [Linux/MacOS]
```bash
$ cd ~
$ python3 -m venv python3_venv
$ source python3_venv/bin/activate
$ pip install -U pip
$ pip install poetry>=1.1.13
$ git clone [email protected]:lava-nc/lava.git
$ cd lava
$ pip install -r build-requirements.txt
$ pip install -r requirements.txt
$ pip install -e .
$ python -m unittest
$ poetry config virtualenvs.in-project = true
$ poetry install
$ source .venv/bin/activate
$ pytest
```
Note that you should install the core Lava repository (lava) before installing other Lava libraries such as lava-optimization or lava-dl.

#### [Windows]
```cmd
cd %HOMEPATH%
python -m venv python3_venv
python3_venv\Scripts\activate.bat
python -m pip install --upgrade pip
pip install poetry>=1.1.13
git clone [email protected]:lava-nc/lava.git
cd lava
pip install -r build-requirements.txt
pip install -r requirements.txt
pip install -e .
python -m unittest
poetry config virtualenvs.in-project = true
poetry install
.venv\Scripts\activate
pytest
```
Note that you should install the core Lava repository (lava) before installing other Lava libraries such as lava-optimization or lava-dl.

You should expect the following output after running the unit tests:
```
PyBuilder version 0.13.3
Build started at 2021-10-25 13:32:02
------------------------------------------------------------
[INFO] Activated environments: unit
[INFO] Building Lava version 0.1.0
...... PyBuilder Logs ...
[INFO] Running unit tests
[INFO] Executing unit tests from Python modules in /home/user/lava/lava/tests
[INFO] Executed 72 unit tests
[INFO] All unit tests passed.
$ pytest
============================================== test session starts ==============================================
platform linux -- Python 3.8.10, pytest-7.0.1, pluggy-1.0.0
rootdir: /home/user/lava, configfile: pyproject.toml, testpaths: tests
plugins: cov-3.0.0
collected 205 items

tests/lava/magma/compiler/test_channel_builder.py . [ 0%]
tests/lava/magma/compiler/test_compiler.py ........................ [ 12%]
tests/lava/magma/compiler/test_node.py .. [ 13%]
tests/lava/magma/compiler/builder/test_channel_builder.py . [ 13%]

...... pytest output ...

tests/lava/proc/sdn/test_models.py ........ [ 98%]
tests/lava/proc/sdn/test_process.py ... [100%] =============================================== warnings summary ================================================

...... pytest output ...

src/lava/proc/lif/process.py 38 0 100%
src/lava/proc/monitor/models.py 27 0 100%
src/lava/proc/monitor/process.py 79 0 100%
src/lava/proc/sdn/models.py 159 9 94% 199-202, 225-231
src/lava/proc/sdn/process.py 59 0 100%
-----------------------------------------------------------------------------------------------------------------TOTAL 4048 453 89%

Required test coverage of 85.0% reached. Total coverage: 88.81%
============================ 199 passed, 6 skipped, 2 warnings in 118.17s (0:01:58) =============================

```

### [Alternative] Installing Lava from Binaries
Expand All @@ -125,37 +140,37 @@ Open a python terminal and run:

#### [Windows/MacOS/Linux]
```bash
$ python3 -m venv python3_venv
$ python3 -m venv .venv
$ source .venv/bin/activate ## Or Windows: .venv\Scripts\activate
$ pip install -U pip
$ pip install lava-nc-0.3.0.tar.gz
```

### Linting, Testing, Documentation and Packaging

```bash
# Install pybuilder
$ pip install -r build-requirements.txt
# Install poetry
$ pip install poetry
$ poetry config virtualenvs.in-project = true
$ poetry install
$ poetry shell

# Run linting
$ pyb analyze
$ flakeheaven lint src/lava tests

# Run unit tests
$ pyb -E unit
# Alternate unit test run
$ python -m unittest

# Generate documentation
$ pyb sphinx_generate_documentation
# Run unit tests
$ pytest

# Create distribution
$ pyb publish
#### Find dists at target/dist/Lava-<version>/dist/
$ poetry build
#### Find builds at dist/

# Run Secuity Linting
$ pyb bandit
$ bandit -r src/lava/.
#### If security linting fails run bandit directly
#### and format failures
S bandit -r lava/ --format custom --msg-template "{abspath}:{line}: {test_id}[bandit]: {severity}: {msg}"
$ bandit -r src/lava/. --format custom --msg-template '{abspath}:{line}: {test_id}[bandit]: {severity}: {msg}'
```

## Running Lava on Intel Loihi
Expand All @@ -175,8 +190,8 @@ instructions, email: [email protected]

- Login to INRC VM with your credentials
- Follow the instructions to Install or Clone Lava
- cd /nfs/ncl/releases/lava/0.1.0
- pip install lava-nc-0.1.0.tar.gz
- cd /nfs/ncl/releases/lava/0.3.0
- pip install lava-nc-0.3.0.tar.gz

## Coding example
### Building a simple feed-forward network
Expand Down
9 changes: 0 additions & 9 deletions build-requirements.txt

This file was deleted.

Loading