Skip to content

Commit

Permalink
Add support for aiida-core==2.X
Browse files Browse the repository at this point in the history
Update the codebase to support `aiida-core` v2.X, mostly via:

1. Adding `core.` prefix to entry points.
2. Removing `dict=`/`list=` keyword arguments in the corresponding constructors.
3. Use new `base` name spacing.

Since the CI was failing in many ways, this has been tweaked and fixed as well:

1. Updates to the `pre-commit`, switching to the `black` formatter, using `isort` 
  and updating `pylint`.
2. Adapting the Docker build for running the examples to:
  * use the `2.3.1` version of the `aiida-core` image.
  * Update RASPA to v2.0.47
  * Include the `run_examples.sh` file, where we select the examples to run for the CI.
3. The CI tests are now split in the actual `pytest` tests, and examples. Running the 
  examples via `pytest` seemed quite broken, and this way we can split the two so we
  can e.g. only run the examples for release PRs.

The repository was also cleaned up of several files that no longer served any purpose.
  • Loading branch information
mpougin authored Aug 26, 2023
1 parent 5d77891 commit fb1860c
Show file tree
Hide file tree
Showing 46 changed files with 1,431 additions and 1,382 deletions.
24 changes: 0 additions & 24 deletions .ci/check_travis_tag.py

This file was deleted.

2 changes: 0 additions & 2 deletions .coveragerc

This file was deleted.

5 changes: 4 additions & 1 deletion .docker/raspa-code.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,4 +5,7 @@ input_plugin: raspa
on_computer: True
remote_abs_path: /opt/RASPA2_installed/bin/simulate
append_text:
prepend_text: export RASPA2_DIR=/opt/RASPA2_installed/
prepend_text: |
export RASPA_DIR=/opt/RASPA2_installed/
export DYLD_LIBRARY_PATH=/opt/RASPA2_installed/lib
export LD_LIBRARY_PATH=/opt/RASPA2_installed/lib
157 changes: 81 additions & 76 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -1,98 +1,103 @@
name: Continuous Integration
name: CI

on: [push, pull_request]

jobs:

test-plugin:
tests:
name: Test Suite
runs-on: ubuntu-latest
timeout-minutes: 30

steps:

- name: Check out repository
uses: actions/checkout@v3

- name: Set up Python 3.10
uses: actions/setup-python@v4
with:
python-version: '3.10'

- name: Install python dependencies
run: |
pip install --upgrade pip
pip install -e .[tests]
- name: Run test suite
run: pytest

examples:
name: Run examples
runs-on: ubuntu-latest
timeout-minutes: 30

steps:

- uses: actions/checkout@v2

- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v1

# see https://github.com/docker/build-push-action/blob/master/docs/advanced/cache.md#github-cache
- name: Cache Docker layers
uses: actions/cache@v2
with:
path: /tmp/.buildx-cache
key: ${{ runner.os }}-buildx-${{ github.sha }}
restore-keys: |
${{ runner.os }}-buildx-
- name: Build #and push
uses: docker/build-push-action@v2
with:
context: .
push: false
load: true
tags: aiida_raspa_test
cache-from: type=local,src=/tmp/.buildx-cache
cache-to: type=local,dest=/tmp/.buildx-cache-new

# Temp fix
# https://github.com/docker/build-push-action/issues/252
# https://github.com/moby/buildkit/issues/1896
- name: Move cache
run: |
rm -rf /tmp/.buildx-cache
mv /tmp/.buildx-cache-new /tmp/.buildx-cache
- name: Run tests
run: |
export DOCKERID=`docker run -d aiida_raspa_test`
docker exec --tty $DOCKERID wait-for-services
docker logs $DOCKERID
docker exec --tty --user aiida $DOCKERID /bin/bash -l -c 'cd /opt/aiida-raspa/ && py.test --cov aiida_raspa --cov-append .'
# see https://docs.github.com/en/actions/reference/environment-variables#default-environment-variables
docker exec --tty --user aiida --env-file <(env | grep GITHUB_) -e GITHUB_TOKEN=${{ secrets.GITHUB_TOKEN }} $DOCKERID /bin/bash -l -c 'cd /opt/aiida-raspa/ && coveralls --service=github'
- name: Check out repository
uses: actions/checkout@v3

- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v2

- name: Build #and push
uses: docker/build-push-action@v2
with:
context: .
push: false
load: true
tags: aiida_raspa_test
cache-from: type=gha
cache-to: type=gha,mode=max

- name: Run examples
run: | # Examples stored and copied from .github/workflows/run_examples.sh
export DOCKERID=`docker run -d aiida_raspa_test`
docker exec --tty $DOCKERID wait-for-services
docker logs $DOCKERID
docker exec --tty --user aiida $DOCKERID /bin/bash -l -c 'cd $HOME; bash run_examples.sh'
pre-commit:
runs-on: ubuntu-latest
timeout-minutes: 10
strategy:
matrix:
python-version: [3.8]

steps:
- uses: actions/checkout@v2
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v2
with:
python-version: ${{ matrix.python-version }}
- name: Install python dependencies
run: |
pip install --upgrade pip
pip install -e .[pre-commit,test,docs]
reentry scan
- name: Run pre-commit
run: |
pre-commit install
pre-commit run --all-files || ( git status --short ; git diff ; exit 1 )

- uses: actions/checkout@v3

- name: Set up Python 3.10
uses: actions/setup-python@v4
with:
python-version: '3.10'

- name: Install python dependencies
run: |
pip install --upgrade pip
pip install -e .[pre-commit,tests,docs]
- name: Run pre-commit
run: |
pre-commit install
pre-commit run --all-files || ( git status --short ; git diff ; exit 1 )
docs:
runs-on: ubuntu-latest
timeout-minutes: 10
strategy:
matrix:
python-version: [3.8]

steps:
- uses: actions/checkout@v2
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v2
with:
python-version: ${{ matrix.python-version }}
- name: Install python dependencies
run: |
pip install --upgrade pip
pip install -e .[docs,test]
reentry scan
- name: Build docs
run: |
cd docs && make

- uses: actions/checkout@v3

- name: Set up Python 3.10
uses: actions/setup-python@v4
with:
python-version: '3.10'

- name: Install python dependencies
run: |
pip install --upgrade pip
pip install -e .[docs]
- name: Build docs
run: |
make -C docs html
7 changes: 7 additions & 0 deletions .github/workflows/run_examples.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
#!/bin/bash

verdi run /opt/aiida-raspa/examples/simple_calculations/example_base.py --submit raspa
verdi run /opt/aiida-raspa/examples/simple_calculations/example_base_restart.py --previous_calc 4 --submit raspa
verdi run /opt/aiida-raspa/examples/simple_calculations/example_binary_mixture.py --submit raspa
verdi run /opt/aiida-raspa/examples/simple_calculations/example_block_pockets_2frameworks_2molecules.py --submit raspa
verdi run /opt/aiida-raspa/examples/simple_calculations/example_block_pockets_simple.py --submit raspa
4 changes: 3 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -271,4 +271,6 @@ tags
[._]*.un~

# End of https://www.gitignore.io/api/vim,linux,macos,python,pycharm
submit_test
submit_test

.vscode
41 changes: 20 additions & 21 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,26 +2,25 @@
# pre-commit install

repos:
- repo: https://github.com/pre-commit/mirrors-yapf
rev: v0.30.0
hooks:
# yapf = yet another python formatter
- id: yapf
name: yapf
types: [python]
exclude: >
(?x)^(
docs/.*|
)$
args: ['-i']
- repo: https://github.com/pycqa/isort
rev: 5.12.0
hooks:
- id: isort

- repo: local
hooks:
# yapf = yet another python formatter
- repo: https://github.com/psf/black
rev: 23.7.0
hooks:
- id: black
# It is recommended to specify the latest version of Python
# supported by your project here, or alternatively use
# pre-commit's default_language_version, see
# https://pre-commit.com/#top_level-default_language_version
language_version: python3.10

# prospector: collection of linters
- id: pylint
language: system
types: [file, python]
name: pylint
entry: pylint
- repo: local
hooks:
- id: pylint
language: system
types: [file, python]
name: pylint
entry: pylint
3 changes: 0 additions & 3 deletions .style.yapf

This file was deleted.

14 changes: 11 additions & 3 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
FROM aiidateam/aiida-core:latest
FROM aiidateam/aiida-core:2.3.1

# Set HOME, PATH and RASPA_DIR variables:
ENV PATH="/opt/RASPA2_installed/bin/:${PATH}"
Expand All @@ -12,7 +12,7 @@ RUN apt-get clean && rm -rf /var/lib/apt/lists/* && apt-get update && apt-get in

# Download, compile and install RASPA into ~/code folder.
WORKDIR /opt/
RUN git clone --depth 1 --branch v2.0.41 https://github.com/iRASPA/RASPA2.git RASPA2
RUN git clone --depth 1 --branch v2.0.47 https://github.com/iRASPA/RASPA2.git RASPA2
WORKDIR /opt/RASPA2
RUN rm -rf autom4te.cache
RUN mkdir m4
Expand All @@ -26,13 +26,21 @@ RUN make install

WORKDIR /opt/

# Grab the raspa data files from the aiida-lsmo-codes repository
RUN git clone https://github.com/lsmo-epfl/aiida-lsmo-codes.git
RUN rsync -av /opt/aiida-lsmo-codes/data/raspa/ /opt/RASPA2_installed
RUN rm -rf aiida-lsmo-codes

# Install coveralls.
RUN pip install coveralls

# Copy and install aiida-raspa plugin.
COPY . aiida-raspa
RUN pip install ./aiida-raspa[pre-commit,test,docs]
RUN pip install -e aiida-raspa[pre-commit,tests,docs]

# Install the RASPA code to AiiDA.
COPY .docker/opt/add-codes.sh /opt/
COPY .docker/my_init.d/add-codes.sh /etc/my_init.d/50_add-codes.sh

# COPY the examples test script
COPY .github/workflows/run_examples.sh /home/aiida/run_examples.sh
1 change: 0 additions & 1 deletion MANIFEST.in

This file was deleted.

4 changes: 1 addition & 3 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
[![Build Status](https://travis-ci.org/yakutovicha/aiida-raspa.svg?branch=develop)](https://travis-ci.org/yakutovicha/aiida-raspa)
[![Coverage Status](https://coveralls.io/repos/github/yakutovicha/aiida-raspa/badge.svg?branch=develop)](https://coveralls.io/github/yakutovicha/aiida-raspa?branch=develop)
![Build Status](https://github.com/lsmo-epfl/aiida-raspa/actions/workflows/ci.yml/badge.svg)
[![PyPI version](https://badge.fury.io/py/aiida-raspa.svg)](https://badge.fury.io/py/aiida-raspa)

# AiiDA RASPA
Expand All @@ -10,7 +9,6 @@ Designed to work with with RASPA 2.0.37 or later.
# Documentation
The documentation for this package can be found on [Read the Docs](https://aiida-raspa.readthedocs.io/en/latest/).


# Installation
If you use ``pip``, you can install it as:
```
Expand Down
1 change: 0 additions & 1 deletion aiida_raspa/__init__.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
# -*- coding: utf-8 -*-
##############################################################################
# Copyright (c), The AiiDA team. All rights reserved. #
# This file is part of the AiiDA code. #
Expand Down
Loading

0 comments on commit fb1860c

Please sign in to comment.