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

Support new Python versions #73

Merged
merged 29 commits into from
Nov 18, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
29 commits
Select commit Hold shift + click to select a range
fa395ea
Drop support for AiiDA v1 and Python 3.7
danielhollas Nov 17, 2024
72bfaca
Use uv
danielhollas Nov 17, 2024
607d4a9
Run editable install only for one version
danielhollas Nov 17, 2024
de1002d
Update developer guide
danielhollas Nov 17, 2024
6e533cb
env.UV_VER
danielhollas Nov 17, 2024
ea840a5
Ignore metadata inputs
danielhollas Nov 17, 2024
e1ac993
Downgrade python versions in CI
danielhollas Nov 17, 2024
b33d7a9
Bring back py3.7
danielhollas Nov 17, 2024
2e49092
recursive extras, setuptools dependency
danielhollas Nov 17, 2024
b3eba93
Upgrade mypy, docs with py38
danielhollas Nov 17, 2024
2a15acb
Pin aiida-core <2.4
danielhollas Nov 17, 2024
a238f23
Fix doc build
danielhollas Nov 17, 2024
f246f04
Update pylint
danielhollas Nov 17, 2024
121d62c
Run precommit with py3.11
danielhollas Nov 17, 2024
4a547d5
Try running pre-commit with py3.12
danielhollas Nov 17, 2024
28597ac
Fix new pylint violations
danielhollas Nov 17, 2024
fc63c25
Run doc build with py3.12
danielhollas Nov 17, 2024
06f431c
Pylint fix
danielhollas Nov 17, 2024
e56a8e1
Remove load_documentation_profile, not needed by aiida 2.0
danielhollas Nov 17, 2024
3972248
Bump minimum python version to 3.8
danielhollas Nov 17, 2024
3bc2218
Temporarily pin aiida version <2.6
danielhollas Nov 17, 2024
2294fb0
Don't install editably
danielhollas Nov 17, 2024
af63363
Undeprecate stuff
danielhollas Nov 17, 2024
39f6ce7
Test with python 3.7
danielhollas Nov 17, 2024
3584ff6
Just pre-commit
danielhollas Nov 17, 2024
4c1e2b3
Reentry scan
danielhollas Nov 17, 2024
f1a30d6
Try 2.0
danielhollas Nov 17, 2024
7d00ebb
Try 2.1
danielhollas Nov 17, 2024
a0fff70
Try 2.2
danielhollas Nov 17, 2024
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
13 changes: 7 additions & 6 deletions .aiida-testing-config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,10 @@ mock_code:
archive_cache:
ignore:
calcjob_attributes:
#These attributes have to be ignored to be able to run the export cache tests
#while reusing the same test archive, migrating it to the needed version,
#since they are only present in newer versions
#The test archives have version 0.8
- environment_variables_double_quotes #This option was introduced in aiida-core 2.0
- submit_script_filename #This option was introduced in aiida-core 1.2.1 (archive version 0.9)
# These attributes have to be ignored to be able to run the export cache tests
# while reusing the same test archive, migrating it to the needed version,
# since they are only present in newer versions
# The test archives have version 0.8
- environment_variables_double_quotes # This option was introduced in aiida-core 2.0
- submit_script_filename # This option was introduced in aiida-core 1.2.1 (archive version 0.9)
- metadata_inputs # Added in aiida-core 2.3.0
6 changes: 0 additions & 6 deletions .ci/install_aiida_github.sh

This file was deleted.

73 changes: 40 additions & 33 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
name: ci
name: CI

on: [push, pull_request]
env:
UV_VER: "0.5.2"
FORCE_COLOR: 1

jobs:

Expand All @@ -9,12 +12,7 @@ jobs:
timeout-minutes: 30
strategy:
matrix:
python-version: ['3.9', '3.10']
editable_install_option: ['-e', '']
include:
#Test for aiida-core 1.X (since aiida-core 2.X does not support python 3.7)
- python-version: '3.7'
editable_install_option: '-e'
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Let's just test non-editable install here, we install editably in pre-commit and docs jobs anyway.

python-version: ['3.7', '3.8', '3.9', '3.10', '3.11', '3.12']
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We can ask on the discourse and if no one using aiida-core < 2 with this anymore, maybe can drop the support for 3.7 and 3.8?
I think if it is going to make a release, it is not a problem to drop the support and versioning it?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Let's have this discussion at #72. There I proposed to release the code basically as is (after renaming it) as version 0.1.0 so that existing users can easily switch to the official package. After that all breaking changes and droping support can be done in v0.2.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

one using aiida-core < 2 with this anymore, maybe can drop the support for 3.7 and 3.8?

btw: Dropping support for AiiDA v1 should anyway be done in a separate PR, since there will be a lot of code cleanup associated with that.

fail-fast: false

services:
Expand All @@ -37,16 +35,19 @@ jobs:
- 5672:5672

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

- name: Install python dependencies
- name: Set up uv
uses: astral-sh/setup-uv@v3
with:
version: ${{ env.UV_VER }}
- name: Install package
run: |
pip install --upgrade pip
pip install ${{ matrix.editable_install_option }} .[testing]
uv pip install --system -e .[testing]
reentry scan -r aiida || true

- name: Run test suite
Expand All @@ -61,34 +62,40 @@ jobs:
runs-on: ubuntu-latest
timeout-minutes: 15
steps:
- uses: actions/checkout@v1
- name: Set up Python 3.7
uses: actions/setup-python@v1
- uses: actions/checkout@v4
- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: 3.7
- name: Install python dependencies
run: |
pip install --upgrade pip
pip install -e .[docs]
reentry scan -r aiida || true
python-version: '3.12'

- name: Set up uv
uses: astral-sh/setup-uv@v3
with:
version: ${{ env.UV_VER }}
- name: Install package
run: uv pip install --system -e .[docs]

- name: Build docs
run: cd docs && make

pre-commit:
runs-on: ubuntu-latest
timeout-minutes: 15
steps:
- uses: actions/checkout@v1
- name: Set up Python 3.8
uses: actions/setup-python@v1
- uses: actions/checkout@v4

- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: 3.8
- name: Install python dependencies
run: |
pip install --upgrade pip
pip install -e .[pre_commit]
reentry scan -r aiida || true
python-version: '3.12'

- name: Set up uv
uses: astral-sh/setup-uv@v3
with:
version: ${{ env.UV_VER }}

- name: Install package
run: uv pip install --system -e .[pre_commit]

- name: Run pre-commit
run: |
pre-commit install
pre-commit run --all-files || ( git status --short ; git diff ; exit 1 )
uses: pre-commit/[email protected]
4 changes: 2 additions & 2 deletions aiida_testing/_config.py
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ def validate(self):
return self.schema(self._dict)

@classmethod
def from_file(cls):
def from_file(cls) -> 'Config':
"""
Parses the configuration file ``.aiida-testing-config.yml``.

Expand All @@ -58,7 +58,7 @@ def from_file(cls):
cwd = pathlib.Path().cwd()
config: ty.Dict[str, str]
for dir_path in [cwd, *cwd.parents]:
config_file_path = (dir_path / CONFIG_FILE_NAME)
config_file_path = dir_path / CONFIG_FILE_NAME
if config_file_path.exists():
with open(config_file_path, encoding='utf8') as config_file:
config = yaml.load(config_file, Loader=yaml.SafeLoader)
Expand Down
10 changes: 6 additions & 4 deletions aiida_testing/archive_cache/_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -115,9 +115,11 @@ def import_with_migrate(
raise

except ImportError:
from aiida.tools.importexport import export as create_archive #type: ignore[import,no-redef]
from aiida.tools.importexport import import_data as import_archive #type: ignore[no-redef]
import_archive = partial(import_archive, extras_mode_existing='ncu', extras_mode_new='import')
from aiida.tools.importexport import export as create_archive # type: ignore[import-not-found,no-redef]
from aiida.tools.importexport import import_data as import_archive # type: ignore[no-redef]
import_archive = partial(
import_archive, extras_mode_existing='ncu', extras_mode_new='import'
) # type: ignore[call-arg]

def import_with_migrate(
archive_path: ty.Union[str, pathlib.Path],
Expand All @@ -133,7 +135,7 @@ def import_with_migrate(
from aiida.tools.importexport import EXPORT_VERSION, IncompatibleArchiveVersionError
# these are only availbale after aiida >= 1.5.0, maybe rely on verdi import instead
from aiida.tools.importexport import detect_archive_type
from aiida.tools.importexport.archive.migrators import get_migrator #type: ignore[import]
from aiida.tools.importexport.archive.migrators import get_migrator # type: ignore[import-not-found]

try:
import_archive(archive_path, *args, **kwargs)
Expand Down
2 changes: 1 addition & 1 deletion aiida_testing/mock_code/_fixtures.py
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,7 @@ def mock_code_factory(
aiida_localhost, testing_config, testing_config_action, mock_regenerate_test_data,
mock_fail_on_missing, mock_disable_mpi, monkeypatch, request: pytest.FixtureRequest,
tmp_path: pathlib.Path
): # pylint: disable=too-many-arguments,redefined-outer-name,unused-argument,too-many-statements
): # pylint: disable=all
"""
Fixture to create a mock AiiDA Code.

Expand Down
2 changes: 1 addition & 1 deletion aiida_testing/mock_code/_hasher.py
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ def __call__(self, cwd: Path) -> str:

return md5sum.hexdigest()

def modify_content(self, path: Path, content: bytes) -> ty.Optional[bytes]: # pylint: disable=no-self-use,unused-argument
def modify_content(self, path: Path, content: bytes) -> ty.Optional[bytes]: # pylint: disable=unused-argument
"""A sub-class hook to modify the contents of the file, before hashing.

If None is returned, the file is ignored, when generating the hash.
Expand Down
34 changes: 5 additions & 29 deletions docs/source/conf.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
# -*- coding: utf-8 -*-
#
# Sphinx configuration for aiida-testing
#
# This file is execfile()d with the current directory set to its
Expand All @@ -16,12 +14,7 @@
import time
import contextlib

from aiida.manage.configuration import load_documentation_profile

import aiida_testing

load_documentation_profile()
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This was removed since it is no longer needed in AiiDA 2.0

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.


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

# If extensions (or modules to document with autodoc) are in another directory,
Expand All @@ -37,7 +30,6 @@
with contextlib.suppress(ImportError):
import sphinx_rtd_theme
html_theme = 'sphinx_rtd_theme'
html_theme_path = [sphinx_rtd_theme.get_html_theme_path()]
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Apparently no longer necessary, generated a warning


# -- General configuration ------------------------------------------------

Expand All @@ -56,7 +48,7 @@

intersphinx_mapping = {
'python': ('https://docs.python.org/3', None),
'aiida': ('http://aiida-core.readthedocs.io/en/v1.6.8/', None),
'aiida': ('https://aiida.readthedocs.io/projects/aiida-core/en/stable/', None),
'pytest': ('https://docs.pytest.org/en/latest/', None)
}

Expand All @@ -66,24 +58,18 @@
# The suffix of source filenames.
source_suffix = '.rst'

# The encoding of source files.
#source_encoding = 'utf-8-sig'

# The master toctree document.
#~ master_doc = 'index'
master_doc = 'index'

# General information about the project.
project = u'aiida-testing'
project = 'aiida-testing'
copyright_first_year = "2019"
copyright_owners = "The AiiDA Team"

current_year = str(time.localtime().tm_year)
copyright_year_string = current_year if current_year == copyright_first_year else "{}-{}".format(
copyright_first_year, current_year
)
copyright_year_string = current_year if current_year == copyright_first_year else f"{copyright_first_year}-{current_year}"
# pylint: disable=redefined-builtin
copyright = u'{}, {}. All rights reserved'.format(copyright_year_string, copyright_owners)
copyright = f'{copyright_year_string}, {copyright_owners}. All rights reserved'

# The version info for the project you're documenting, acts as replacement for
# |version| and |release|, also used in various other places throughout the
Expand Down Expand Up @@ -146,9 +132,7 @@
# Theme options are theme-specific and customize the look and feel of a theme
# further. For a list of options available for each theme, see the
# documentation.
html_theme_options = {
'display_version': True,
}
# html_theme_options = {}

# Add any paths that contain custom themes here, relative to this directory.
#~ html_theme_path = ["."]
Expand Down Expand Up @@ -221,9 +205,6 @@
#html_file_suffix = None

# Language to be used for generating the HTML full-text search index.
# Sphinx supports the following languages:
# 'da', 'de', 'en', 'es', 'fi', 'fr', 'hu', 'it', 'ja'
# 'nl', 'no', 'pt', 'ro', 'ru', 'sv', 'tr'
html_search_language = 'en'

# A dictionary with options for the search language support, empty by default.
Expand Down Expand Up @@ -292,11 +273,6 @@ def run_apidoc(_):
apidoc_dir = os.path.join(source_dir, 'apidoc')
package_dir = os.path.join(source_dir, os.pardir, os.pardir, 'aiida_testing')

# In #1139, they suggest the route below, but this ended up
# calling sphinx-build, not sphinx-apidoc
#from sphinx.apidoc import main
#main([None, '-e', '-o', apidoc_dir, package_dir, '--force'])

import subprocess
cmd_path = 'sphinx-apidoc'
if hasattr(sys, 'real_prefix'): # Check to see if we are in a virtualenv
Expand Down
17 changes: 1 addition & 16 deletions docs/source/developer_guide/index.rst
Original file line number Diff line number Diff line change
Expand Up @@ -34,8 +34,7 @@ Enable enable automatic checks of code sanity and coding style::
pre-commit install

After this, the `yapf <https://github.com/google/yapf>`_ formatter,
the `pylint <https://www.pylint.org/>`_ linter, the
`prospector <https://pypi.org/project/prospector/>`_ code analyzer, and
the `pylint <https://www.pylint.org/>`_ linter, and
the `mypy <http://www.mypy-lang.org/>`_ static type checker will run
at every commit.

Expand Down Expand Up @@ -71,17 +70,3 @@ Of course, you can also build the documentation locally::
pip install -e .[docs]
cd docs
make

PyPI release
++++++++++++

The process for creating a distribution and uploading it to PyPI is::

pip install twine
python setup.py sdist
twine upload dist/*

This can only be done by people who are registered as ``aiida-testing``
maintainers on PyPI. After this, you (and everyone else) should be able to::

pip install aiida-testing
21 changes: 9 additions & 12 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,8 @@ classifiers = [
"Programming Language :: Python :: 3.8",
"Programming Language :: Python :: 3.9",
"Programming Language :: Python :: 3.10",
"Programming Language :: Python :: 3.11",
"Programming Language :: Python :: 3.12",
"Topic :: Scientific/Engineering :: Physics",
"Framework :: AiiDA",
"Framework :: Pytest",
Expand All @@ -39,10 +41,12 @@ keywords = [
]
urls = {Homepage = "https://aiida-testing.readthedocs.io/"}
requires-python = ">=3.7"
# Note the dependency on setuptools due to pkg_resources
dependencies = [
"aiida-core>=1.0.0,<3.0.0",
"pytest>=3.6",
"aiida-core>=1.0.0,<2.3",
"pytest>=7.0",
"voluptuous~=0.12",
"setuptools",
]

[project.optional-dependencies]
Expand All @@ -55,20 +59,13 @@ testing = [
]
pre_commit = [
"pre-commit",
"pylint~=2.12.2",
"mypy==0.930",
"pylint~=3.3.1",
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm gonna get rid of pylint for ruff, but in a separate PR.

Copy link
Collaborator Author

@danielhollas danielhollas Nov 18, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I begin to really appreciate the beauty of single rust binaries, this pylint pin was a reason why the installation for newer Python versions did not work. :-(

"mypy==1.13",
"types-setuptools==65.7.0.3",
"types-PyYAML",
]
dev = [
"sphinx",
"sphinx-rtd-theme",
"pgtest~=1.3.1",
"aiida-diff",
"pytest-datadir",
"pre-commit",
"pylint~=2.12.2",
"mypy==0.930",
'aiida-testing[testing,pre_commit,docs]',
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Self-referencing extras are allowed in pyproject.toml (but not in setup.cfg)

]

[project.scripts]
Expand Down
4 changes: 2 additions & 2 deletions tests/archive_cache/test_archive_cache.py
Original file line number Diff line number Diff line change
Expand Up @@ -153,7 +153,7 @@ def test_mock_hash_codes(mock_code_factory, clear_database, liberal_hash):
def test_enable_archive_cache(
archive_path, aiida_local_code_factory, generate_diff_inputs, enable_archive_cache,
clear_database, check_diff_workchain
):
): # pylint: disable=too-many-positional-arguments
"""
Basic test of the enable_archive_cache fixture
"""
Expand All @@ -171,7 +171,7 @@ def test_enable_archive_cache(
def test_enable_archive_cache_non_existent(
aiida_local_code_factory, generate_diff_inputs, enable_archive_cache, clear_database,
tmp_path_factory, check_diff_workchain
):
): # pylint: disable=too-many-positional-arguments
"""
Test of the enable_archive_cache fixture that creation of the archive
and overwriting of the archive works correctly
Expand Down