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

Updates from PR https://github.com/aiidateam/aiida-plugin-cutter/pull/108 #44

Draft
wants to merge 7 commits into
base: master
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
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
60 changes: 30 additions & 30 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,11 @@
name: ci

on: [push, pull_request]
on:
push:
# only pushes to main trigger
branches: [main]
pull_request:
# always triggered

jobs:

Expand All @@ -9,7 +14,7 @@ jobs:
timeout-minutes: 30
strategy:
matrix:
python-version: ['3.10']
python-version: ['3.12']
aiida-version: ['stable']

services:
Expand All @@ -32,54 +37,49 @@ jobs:
- 5672:5672

steps:
- uses: actions/checkout@v2
- uses: actions/checkout@v4

- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v2
uses: actions/setup-python@v5
with:
python-version: ${{ matrix.python-version }}

- name: Install python dependencies
- name: Install project manager
run: |
pip install --upgrade pip
pip install -e .[testing]

pip install hatch
- name: Run test suite
env:
# show timings of tests
PYTEST_ADDOPTS: "--durations=0"
run: pytest --cov aiida_diff --cov-append .
run: |
hatch test --cover

docs:
runs-on: ubuntu-latest
timeout-minutes: 15
steps:
- uses: actions/checkout@v2
- name: Set up Python 3.10
uses: actions/setup-python@v2
- uses: actions/checkout@v4
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v5
with:
python-version: "3.10"
- name: Install python dependencies
python-version: ${{ matrix.python-version }}
- name: Install project manager
run: |
pip install --upgrade pip
pip install -e .[docs]
pip install hatch
- name: Build docs
run: cd docs && make
run: |
hatch run docs:build

pre-commit:
static-analysis:
runs-on: ubuntu-latest
timeout-minutes: 15
steps:
- uses: actions/checkout@v2
- name: Set up Python 3.10
uses: actions/setup-python@v2
- uses: actions/checkout@v4
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v5
with:
python-version: "3.10"
- name: Install python dependencies
python-version: ${{ matrix.python-version }}
- name: Install project manager
run: |
pip install --upgrade pip
pip install -e .[pre-commit,docs,testing]
- name: Run pre-commit
pip install hatch
- name: Run formatter and linter
run: |
pre-commit install
pre-commit run --all-files || ( git status --short ; git diff ; exit 1 )
hatch fmt --check
16 changes: 8 additions & 8 deletions .github/workflows/publish-on-pypi.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,19 +15,19 @@ jobs:
- name: Checkout repository
uses: actions/checkout@v2

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

- name: Install flit
- name: Install hatch
run: |
python -m pip install --upgrade pip
python -m pip install flit~=3.4
python -m pip install hatch~=1.12.0

- name: Build and publish
run: |
flit publish
hatch publish
env:
FLIT_USERNAME: __token__
FLIT_PASSWORD: ${{ secrets.pypi_token }}
HATCH_INDEX_USER: __token__
HATCH_INDEX_AUTH: ${{ secrets.pypi_token }}
44 changes: 9 additions & 35 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -1,39 +1,13 @@
# Install pre-commit hooks via:
# pre-commit install
repos:
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v4.4.0
hooks:
- id: end-of-file-fixer
- id: mixed-line-ending
- id: trailing-whitespace
- id: check-json

- repo: https://github.com/asottile/pyupgrade
rev: v3.3.1
hooks:
- id: pyupgrade
args: ["--py37-plus"]

- repo: https://github.com/PyCQA/isort
rev: 5.12.0
hooks:
- id: isort

- repo: https://github.com/psf/black
rev: 22.12.0
hooks:
- id: black

- repo: local
hooks:
- id: pylint
- id: format
name: format
entry: hatch fmt -f
language: system
types: [python]
- id: lint
name: lint
entry: hatch fmt -l
language: system
types: [file, python]
name: pylint
description: "This hook runs the pylint static code analyzer"
exclude: &exclude_files >
(?x)^(
docs/.*|
)$
entry: pylint
types: [python]
1 change: 1 addition & 0 deletions conftest.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
"""pytest fixtures for simplified testing."""

import pytest

pytest_plugins = ["aiida.manage.tests.pytest_fixtures"]
Expand Down
14 changes: 5 additions & 9 deletions docs/source/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,11 +14,10 @@
import sys
import time

import aiida_diff
from aiida import load_profile
from aiida.storage.sqlite_temp import SqliteTempBackend

import aiida_diff

# -- AiiDA-related setup --------------------------------------------------

# Load AiiDA profile
Expand Down Expand Up @@ -68,9 +67,7 @@

current_year = str(time.localtime().tm_year)
copyright_year_string = (
current_year
if current_year == copyright_first_year
else f"{copyright_first_year}-{current_year}"
current_year if current_year == copyright_first_year else f"{copyright_first_year}-{current_year}"
)
# pylint: disable=redefined-builtin
copyright = f"{copyright_year_string}, {copyright_owners}. All rights reserved"
Expand Down Expand Up @@ -185,6 +182,7 @@
# We should ignore any python built-in exception, for instance
nitpick_ignore = [
("py:class", "Logger"),
("py:class", "QbFields"), # Warning started to appear with aiida 2.6
]


Expand All @@ -198,7 +196,7 @@ def run_apidoc(_):
"""
source_dir = os.path.abspath(os.path.dirname(__file__))
apidoc_dir = os.path.join(source_dir, "apidoc")
package_dir = os.path.join(source_dir, os.pardir, os.pardir, "aiida_diff")
package_dir = os.path.join(source_dir, os.pardir, os.pardir, "src", "aiida_diff")

# In #1139, they suggest the route below, but this ended up
# calling sphinx-build, not sphinx-apidoc
Expand All @@ -223,9 +221,7 @@ def run_apidoc(_):

# See https://stackoverflow.com/a/30144019
env = os.environ.copy()
env[
"SPHINX_APIDOC_OPTIONS"
] = "members,special-members,private-members,undoc-members,show-inheritance"
env["SPHINX_APIDOC_OPTIONS"] = "members,special-members,private-members,undoc-members,show-inheritance"
subprocess.check_call([cmd_path] + options, env=env)


Expand Down
13 changes: 6 additions & 7 deletions examples/example_01.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,12 @@

Usage: ./example_01.py
"""

from os import path

import click

from aiida import cmdline, engine
from aiida.plugins import CalculationFactory, DataFactory

from aiida_diff import helpers

INPUT_DIR = path.join(path.dirname(path.realpath(__file__)), "input_files")
Expand All @@ -26,12 +25,12 @@ def test_run(diff_code):
diff_code = helpers.get_code(entry_point="diff", computer=computer)

# Prepare input parameters
DiffParameters = DataFactory("diff")
parameters = DiffParameters({"ignore-case": True})
diff_parameters = DataFactory("diff")
parameters = diff_parameters({"ignore-case": True})

SinglefileData = DataFactory("core.singlefile")
file1 = SinglefileData(file=path.join(INPUT_DIR, "file1.txt"))
file2 = SinglefileData(file=path.join(INPUT_DIR, "file2.txt"))
singlefile_data = DataFactory("core.singlefile")
file1 = singlefile_data(file=path.join(INPUT_DIR, "file1.txt"))
file2 = singlefile_data(file=path.join(INPUT_DIR, "file2.txt"))

# set up calculation
inputs = {
Expand Down
Loading
Loading