Converting poetry script to conda yaml for Intel Lava-nc?

Viewed 149

Context

The instructions on the Linux/MacOS instructions to setup your device for the Lava neuromorphic computing framework by Intel provide a few pip commands, a git clone command and some poetry instructions. I am used to be able to integrate pip commands in an environment.yml for conda, and I thought the git clone command could also be included in the environment.yml file. However, I am not yet sure how to integrate the poetry commands.

Question

Hence, I would like to ask: How can I convert the following installation script into a (single) conda environment yaml file?:

cd $HOME
pip install -U pip
pip install "poetry>=1.1.13"
git clone git@github.com:lava-nc/lava.git
cd lava
poetry config virtualenvs.in-project true
poetry install
source .venv/bin/activate
pytest

Attempts

I have been able to install the Lava software successfully in a single environment.yml using:

# run: conda env create --file lava_environment.yml
# include new packages: conda env update --file lava_environment.yml
name: lava
channels:
  - conda-forge
  - conda
dependencies:
- anaconda
- conda:
# Run python tests.
  - pytest=6.1.2
- pip
- pip:
# Auto generate docstrings
  - pyment
# Run pip install on .tar.gz file in GitHub repository.
  - https://github.com/lava-nc/lava/releases/download/v0.3.0/lava-nc-0.3.0.tar.gz

Which I've installed with:

conda env create --file lava_environment.yml

However, that installs it from a binary instead of from source.

2 Answers

This will probably help you:

cd $HOME
pip install -U pip
pip install "poetry>=1.1.13"
git clone git@github.com:lava-nc/lava.git
cd lava
poetry config virtualenvs.in-project true
poetry install
poetry run pytest

When using poetry in scripts, it's easier not to activate the venv manually (reason being that source can be hard to work with), and instead use poetry run <command> to execute commands that should be aware of the venv.

This environment.yml can be used to install and use the Lava v0.0.3 framework:

# This file is to automatically configure your environment. It allows you to
# run the code with a single command without having to install anything
# (extra).

# First run: conda env create --file environment.yml
# If you change this file, run: conda env update --file environment.yml

# Instructions for this networkx-to-lava-nc repository only. First time usage
# On Ubuntu (this is needed for lava-nc):
# sudo apt upgrade
# sudo apt full-upgrade
# yes | sudo apt install gcc

# Conda configuration settings. (Specify which modules/packages are installed.)
name: nx2lava
channels:
  - conda-forge
dependencies:
# Specify specific python version.
  - python=3.8
# Run python tests.
  - pytest-cov
# Generate plots.
  - matplotlib
# Run graph software quickly.
  - networkx
  - pip
  - pip:
# Run pip install on .tar.gz file in GitHub repository (For lava-nc only).
    - https://github.com/lava-nc/lava/releases/download/v0.3.0/lava-nc-0.3.0.tar.gz
# Turns relative import paths into absolute import paths.
    - absolufy-imports
# Auto format Python code to make it flake8 compliant.
    - autoflake
# Scan Python code for security issues.
    - bandit
# Code formatting compliance.
    - black
# Correct code misspellings.
    - codespell
# Verify percentage of code that has at least 1 test.
    - coverage
# Auto formats the Python documentation written in the code.
    - docformatter
# Auto generate docstrings.
    - flake8
# Auto sort the import statements.
    - isort
# Auto format Markdown files.
    - mdformat
# Auto check static typing.
    - mypy
# Auto generate documentation.
    - pdoc3
# Auto check programming style aspects.
    - pylint
# Auto generate docstrings.
    - pyment
# Identify and remove dead code.
    - vulture
# Include GitHub pre-commit hook.
    - pre-commit
# Automatically upgrades Python syntax to the new Python version syntax.
    - pyupgrade
# Another static type checker for python like mypy.
    - pyright

It also includes packages for quality assurance using pre-commit.

Related