Skip to content

Commit

Permalink
Implement minimal py4vasp-core package (#96)
Browse files Browse the repository at this point in the history
* Create new poetry file for py4vasp-core in subfolder
* Implement optional import routine
* Implement fixture to skip test on py4vasp-core/py4vasp
* Skip all tests that cannot pass because an optional package is missing
* Update Github actions to test both py4vasp and py4vasp-core
* Update README to include description of py4vasp-core
  • Loading branch information
martin-schlipf authored Jun 22, 2023
1 parent 2e319be commit 07a2aa0
Show file tree
Hide file tree
Showing 34 changed files with 2,148 additions and 1,659 deletions.
61 changes: 61 additions & 0 deletions .github/workflows/test_core.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
name: test-core

on:
push:
branches: [master]
pull_request:
branches: [master]

jobs:
tests:
runs-on: ${{ matrix.os }}
strategy:
matrix:
os: [ubuntu-latest, macos-latest]
python-version: ["3.8", "3.9", "3.10"]

steps:
- uses: actions/checkout@v3
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v4
with:
python-version: ${{ matrix.python-version }}
- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install "poetry!=1.4.1"
cp core/* .
poetry --version
poetry install
- name: Test with pytest
run: |
poetry run pytest --version
poetry run pytest
test-windows:
runs-on: windows-latest
strategy:
matrix:
python-version: ["3.8", "3.9", "3.10"]

steps:
- uses: actions/checkout@v3
- uses: conda-incubator/setup-miniconda@v2
with:
auto-update-conda: true
python-version: ${{ matrix.python-version }}
- name: Install dependencies with conda
run: |
conda info
conda install -c conda-forge mdtraj
- name: Install py4vasp
run: |
python -m pip install --upgrade pip
cp core/* .
pip install .
- name: Test with pytest
run: |
pip install pytest pytest-cov hypothesis
pytest --version
pytest
30 changes: 5 additions & 25 deletions .github/workflows/test.yml → .github/workflows/test_full.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
name: tests
name: test-full

on:
push:
Expand All @@ -10,7 +10,6 @@ jobs:
tests:
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
matrix:
os: [ubuntu-latest, macos-latest]
python-version: ["3.8", "3.9", "3.10"]
Expand Down Expand Up @@ -43,13 +42,16 @@ jobs:
test-windows:
runs-on: windows-latest
strategy:
matrix:
python-version: ["3.8", "3.9", "3.10"]

steps:
- uses: actions/checkout@v3
- uses: conda-incubator/setup-miniconda@v2
with:
auto-update-conda: true
python-version: 3.8
python-version: ${{ matrix.python-version }}
- name: Install dependencies with conda
run: |
conda info
Expand All @@ -58,7 +60,6 @@ jobs:
run: |
python -m pip install --upgrade pip
pip install .
pip install ipykernel # missing dependecy of nglview
- name: Test with pytest
run: |
pip install pytest pytest-cov hypothesis
Expand All @@ -73,24 +74,3 @@ jobs:
black --version
black --check src
black --check tests
# - name: Install poetry
# run: |
# python -m pip install --upgrade pip
# pip install "poetry!=1.4.1"
# poetry --version
# - name: Install py4vasp
# run: |
# poetry config virtualenvs.create false --local
# poetry install
# - name: Test with pytest
# run: |
# poetry run pytest --version
# poetry run pytest --cov=py4vasp --cov-report term
# - name: Check code style
# run: |
# poetry run isort --version
# poetry run isort --check src
# poetry run isort --check tests
# poetry run black --version
# poetry run black --check src
# poetry run black --check tests
29 changes: 26 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@

We use the [poetry dependency manager](https://python-poetry.org/) which takes care of
all dependencies and maintains a virtual environment to check the code. If you want to
test something in the virtual environment, just use e.g. ```poetry run jupyter-notebook```.
test something in the virtual environment, just use e.g. `poetry run jupyter-notebook`.

Using poetry installing and the code requires the following steps. The last step will
test whether everything worked
Expand All @@ -35,15 +35,38 @@ conda create --name py4vasp-env python=3.8
conda activate py4vasp-env
conda install -c conda-forge poetry
conda install -c conda-forge mdtraj
poetry config virtualenvs.create false --local
poetry install
poetry run pytest
~~~

## py4vasp core

If you want to use py4vasp to develop your own scripts, you may want to limit the amount
of external dependencies. To this end, we provide alternative configuration files that
only install numpy, h5py, and the development dependencies. To install this core package
replace the configurations files in the root folder with the ones in the `core` folder
~~~shell
cp core/* .
~~~
Then you can install py4vasp with the same steps as above. Note that some tests will be
skipped because they require the external packages to run.

If you want to exclude even the development dependencies, you can run
~~~shell
poetry install --without dev
~~~
for the minimal installation.

## Code style

Code style is enforced, but is not something the developer should spend time on, so we
decided on using the black formatter. Please run ```black .``` before committing the code.
decided on using black and isort. Please run
~~~shell
black src tests
isort src tests
~~~
before committing the code. This will autoformat your code and sort the import
statements in a consistent order.

## Contributing to py4vasp

Expand Down
Loading

0 comments on commit 07a2aa0

Please sign in to comment.