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

Update dependencies #402

Merged
merged 3 commits into from
Nov 24, 2022
Merged
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
2 changes: 1 addition & 1 deletion .ci/aiida-version.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"schemaVersion": 1,
"label": "AiiDA",
"message": "v2.0.4",
"message": "v2.1.2",
"color": "brightgreen"
}
8 changes: 4 additions & 4 deletions .github/aiida/setup_aiida.sh
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,10 @@ set -ev
# Replace the placeholders in configuration files with actual values
CONFIG="${GITHUB_WORKSPACE}/.github/aiida"
sed -i "s|PLACEHOLDER_BACKEND|${AIIDA_TEST_BACKEND}|" "${CONFIG}/profile.yaml"
sed -i "s|PLACEHOLDER_PROFILE|test_${AIIDA_TEST_BACKEND}|" "${CONFIG}/profile.yaml"
sed -i "s|PLACEHOLDER_DATABASE_NAME|test_${AIIDA_TEST_BACKEND}|" "${CONFIG}/profile.yaml"
sed -i "s|PLACEHOLDER_REPOSITORY|/tmp/test_repository_test_${AIIDA_TEST_BACKEND}/|" "${CONFIG}/profile.yaml"
sed -i "s|PLACEHOLDER_PROFILE|test_${AIIDA_TEST_BACKEND#core.}|" "${CONFIG}/profile.yaml"
sed -i "s|PLACEHOLDER_DATABASE_NAME|test_${AIIDA_TEST_BACKEND#core.}|" "${CONFIG}/profile.yaml"
sed -i "s|PLACEHOLDER_REPOSITORY|/tmp/test_repository_test_${AIIDA_TEST_BACKEND#core.}/|" "${CONFIG}/profile.yaml"

verdi setup --config "${CONFIG}/profile.yaml"

verdi profile setdefault test_${AIIDA_TEST_BACKEND}
verdi profile setdefault test_${AIIDA_TEST_BACKEND#core.}
26 changes: 9 additions & 17 deletions .github/workflows/ci_tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,6 @@ jobs:
fail-fast: false
matrix:
python-version: ['3.8', '3.9', '3.10']
backend: [psql_dos]

services:
mongo:
Expand All @@ -56,7 +55,7 @@ jobs:
postgres:
image: postgres:12
env:
POSTGRES_DB: test_${{ matrix.backend }}
POSTGRES_DB: test_psql_dos
POSTGRES_PASSWORD: test
options: >-
--health-cmd pg_isready
Expand All @@ -66,6 +65,11 @@ jobs:
ports:
- 5432:5432

env:
AIIDA_TEST_BACKEND: core.psql_dos
AIIDA_TEST_PROFILE: test_psql_dos
AIIDA_PROFILE: test_psql_dos

steps:
- uses: actions/checkout@v3
with:
Expand All @@ -83,30 +87,18 @@ jobs:
pip install -e .[testing]

- name: Setup up environment for AiiDA
env:
AIIDA_TEST_BACKEND: ${{ matrix.backend }}
run: .github/aiida/setup_aiida.sh

- name: Test with pytest (AiiDA)
env:
AIIDA_TEST_BACKEND: ${{ matrix.backend }}
AIIDA_TEST_PROFILE: test_${{ matrix.backend }}
AIIDA_PROFILE: test_${{ matrix.backend }}
run: pytest -v --cov=./aiida_optimade/ --cov-report=xml --durations=20

- name: Test with pytest (Data Curation)
env:
AIIDA_TEST_BACKEND: ${{ matrix.backend }}
AIIDA_TEST_PROFILE: test_${{ matrix.backend }}
AIIDA_PROFILE: test_${{ matrix.backend }}
PYTEST_OPTIMADE_CONFIG_FILE: ./tests/static/test_data_curation_config.json
run: pytest -v --cov=./aiida_optimade/ --cov-report=xml --cov-append --durations=20 tests/server/routers/test_structures.py::test_structures_endpoint_data

- name: Test with pytest (MongoDB)
env:
AIIDA_TEST_BACKEND: ${{ matrix.backend }}
AIIDA_TEST_PROFILE: test_${{ matrix.backend }}
AIIDA_PROFILE: test_${{ matrix.backend }}
PYTEST_OPTIMADE_CONFIG_FILE: ./tests/static/test_mongo_config.json
OPTIMADE_MONGO_URI: mongodb://localhost:27017
OPTIMADE_DATABASE_BACKEND: mongodb
Expand Down Expand Up @@ -178,7 +170,7 @@ jobs:

- name: Setup up environment for AiiDA
env:
AIIDA_TEST_BACKEND: psql_dos
AIIDA_TEST_BACKEND: core.psql_dos
run: .github/aiida/setup_aiida.sh

- name: Load test data
Expand Down Expand Up @@ -251,7 +243,7 @@ jobs:

- name: Setup up environment for AiiDA
env:
AIIDA_TEST_BACKEND: psql_dos
AIIDA_TEST_BACKEND: core.psql_dos
run: .github/aiida/setup_aiida.sh

- name: Load test data (AiiDA)
Expand Down Expand Up @@ -320,7 +312,7 @@ jobs:

- name: Setup up environment for AiiDA
env:
AIIDA_TEST_BACKEND: psql_dos
AIIDA_TEST_BACKEND: core.psql_dos
run: .github/aiida/setup_aiida.sh

- name: Build docker image
Expand Down
4 changes: 2 additions & 2 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
---
repos:
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v4.3.0
rev: v4.4.0
hooks:
- id: trailing-whitespace
args: [--markdown-linebreak-ext=md]
Expand Down Expand Up @@ -33,7 +33,7 @@ repos:
language: system

- repo: https://github.com/pycqa/flake8
rev: 5.0.4
rev: 6.0.0
hooks:
- id: flake8

Expand Down
2 changes: 1 addition & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ WORKDIR /app

# Install specific optimade and aiida-core versions
ARG OPTIMADE_TOOLS_VERSION=0.19.4
ARG AIIDA_VERSION=2.0.4
ARG AIIDA_VERSION=2.1.2

# Copy repo contents
COPY setup.py setup.json README.md requirements*.txt ./
Expand Down
26 changes: 15 additions & 11 deletions aiida_optimade/cli/cmd_aiida_optimade.py
Original file line number Diff line number Diff line change
@@ -1,20 +1,27 @@
import os
from pathlib import Path
from typing import TYPE_CHECKING

import click
from aiida.cmdline.params.options import PROFILE as VERDI_PROFILE
from aiida.cmdline.groups import VerdiCommandGroup
from aiida.cmdline.params.options import PROFILE as AIIDA_PROFILE
from aiida.cmdline.params.types import ProfileParamType as VerdiProfileParamType
from aiida.manage.configuration import Profile, get_config

from aiida_optimade.cli.options import AIIDA_PROFILES
from aiida_optimade.cli.utils import AIIDA_OPTIMADE_TEST_PROFILE

if TYPE_CHECKING: # pragma: no cover
from aiida.cmdline.groups.verdi import VerdiContext
from aiida.manage.configuration import Profile

@click.group(context_settings={"help_option_names": ["-h", "--help"]})

@click.command(
cls=VerdiCommandGroup, context_settings={"help_option_names": ["-h", "--help"]}
)
@click.version_option(
None, "-v", "--version", message="AiiDA-OPTIMADE version %(version)s"
)
@VERDI_PROFILE(
@AIIDA_PROFILE(
type=VerdiProfileParamType(),
default="optimade",
show_default=True,
Expand All @@ -30,17 +37,14 @@
"profile and `--debug` options).",
)
@click.pass_context
def cli(ctx, profile: Profile, dev: bool): # pragma: no cover
def cli(ctx: "VerdiContext", profile: "Profile", dev: bool): # pragma: no cover
"""AiiDA-OPTIMADE command line interface (CLI)."""

if ctx.obj is None:
ctx.obj = {}

if dev:
profile = get_config(create=True).get_profile(AIIDA_OPTIMADE_TEST_PROFILE)
profile = ctx.obj.config.get_profile(AIIDA_OPTIMADE_TEST_PROFILE)

ctx.obj["profile"] = profile
ctx.obj["dev"] = dev
ctx.obj.profile = profile
ctx.obj.dev = dev

# Set config
if (
Expand Down
11 changes: 8 additions & 3 deletions aiida_optimade/cli/cmd_calc.py
Original file line number Diff line number Diff line change
@@ -1,12 +1,17 @@
# pylint: disable=protected-access,too-many-locals,too-many-branches
from typing import Tuple
from typing import TYPE_CHECKING

import click
from tqdm import tqdm

from aiida_optimade.cli.cmd_aiida_optimade import cli
from aiida_optimade.common.logger import LOGGER, disable_logging

if TYPE_CHECKING: # pragma: no cover
from typing import Tuple

from aiida.common.extendeddicts import AttributeDict


@cli.command()
@click.argument(
Expand Down Expand Up @@ -35,7 +40,7 @@
help="Suppress informational output.",
)
@click.pass_obj
def calc(obj: dict, fields: Tuple[str], force_yes: bool, silent: bool):
def calc(obj: "AttributeDict", fields: "Tuple[str]", force_yes: bool, silent: bool):
"""Calculate OPTIMADE fields in the AiiDA database."""
from aiida import load_profile
from aiida.cmdline.utils import echo
Expand All @@ -45,7 +50,7 @@ def calc(obj: dict, fields: Tuple[str], force_yes: bool, silent: bool):
echo.CMDLINE_LOGGER.setLevel("INFO")

try:
profile: str = obj.get("profile").name
profile: str = obj.profile.name
except AttributeError:
profile = None
profile = load_profile(profile).name
Expand Down
19 changes: 12 additions & 7 deletions aiida_optimade/cli/cmd_init.py
Original file line number Diff line number Diff line change
@@ -1,13 +1,18 @@
# pylint: disable=protected-access,too-many-statements
from pathlib import Path
from typing import IO, Generator, Iterator, List, Union
from typing import TYPE_CHECKING

import click
from tqdm import tqdm

from aiida_optimade.cli.cmd_aiida_optimade import cli
from aiida_optimade.common.logger import LOGGER, disable_logging

if TYPE_CHECKING: # pragma: no cover
from typing import IO, Generator, Iterator, List, Union

from aiida.common.extendeddicts import AttributeDict


@cli.command()
@click.option(
Expand Down Expand Up @@ -43,7 +48,7 @@
help="Filename to load as database (currently only usable for MongoDB).",
)
@click.pass_obj
def init(obj: dict, force: bool, silent: bool, mongo: bool, filename: str):
def init(obj: "AttributeDict", force: bool, silent: bool, mongo: bool, filename: str):
"""Initialize an AiiDA database to be served with AiiDA-OPTIMADE."""
from aiida import load_profile
from aiida.cmdline.utils import echo
Expand All @@ -58,7 +63,7 @@ def init(obj: dict, force: bool, silent: bool, mongo: bool, filename: str):
profile = f"MongoDB JSON file {filename.name}"
else:
try:
profile: str = obj.get("profile").name
profile: str = obj.profile.name
except AttributeError:
profile = None
profile = load_profile(profile).name
Expand Down Expand Up @@ -221,8 +226,8 @@ def init(obj: dict, force: bool, silent: bool, mongo: bool, filename: str):


def read_chunks(
file_object: IO, chunk_size: int = None
) -> Generator[Union[str, bytes], None, None]:
file_object: "IO", chunk_size: int = None
) -> "Generator[Union[str, bytes], None, None]":
"""Generator to read a file piece by piece

Parameters:
Expand All @@ -243,8 +248,8 @@ def read_chunks(


def get_documents(
chunk_iterator: Union[Generator[str, None, None], Iterator[str]]
) -> Generator[List[dict], None, None]:
chunk_iterator: "Union[Generator[str, None, None], Iterator[str]]",
) -> "Generator[List[dict], None, None]":
"""Generator to return MongoDB documents from file"""
rest_chunk = ""

Expand Down
19 changes: 15 additions & 4 deletions aiida_optimade/cli/cmd_run.py
Original file line number Diff line number Diff line change
@@ -1,9 +1,14 @@
# pylint: disable=too-many-arguments
from typing import TYPE_CHECKING

import click

from aiida_optimade.cli.cmd_aiida_optimade import cli
from aiida_optimade.cli.options import LOGGING_LEVELS

if TYPE_CHECKING: # pragma: no cover
from aiida.common.extendeddicts import AttributeDict


@cli.command()
@click.option(
Expand Down Expand Up @@ -43,13 +48,20 @@
help="Enable auto-reload. Note, if --debug is set, this will also be set to True.",
)
@click.pass_obj
def run(obj: dict, log_level: str, debug: bool, host: str, port: int, reload: bool):
def run(
obj: "AttributeDict",
log_level: str,
debug: bool,
host: str,
port: int,
reload: bool,
):
"""Run AiiDA-OPTIMADE server."""
import os

import uvicorn

if obj.get("dev", False):
if getattr(obj, "dev", False):
debug = True

log_level = log_level.lower()
Expand All @@ -70,7 +82,7 @@ def run(obj: dict, log_level: str, debug: bool, host: str, port: int, reload: bo
from aiida import load_profile

try:
profile: str = obj.get("profile").name
profile: str = obj.profile.name
except AttributeError:
profile = None
profile_name: str = load_profile(profile).name
Expand All @@ -82,5 +94,4 @@ def run(obj: dict, log_level: str, debug: bool, host: str, port: int, reload: bo
host=host,
port=port,
log_level=log_level,
debug=debug,
)
7 changes: 5 additions & 2 deletions aiida_optimade/cli/utils.py
Original file line number Diff line number Diff line change
@@ -1,12 +1,15 @@
from typing import List
from typing import TYPE_CHECKING

from aiida.common.exceptions import ConfigurationError, MissingConfigurationError
from aiida.manage.configuration import get_config

if TYPE_CHECKING: # pragma: no cover
from typing import List

AIIDA_OPTIMADE_TEST_PROFILE = "aiida-optimade_test"


def get_aiida_profiles() -> List[str]:
def get_aiida_profiles() -> "List[str]":
"""Retrieve list of configured AiiDA profiles"""

try:
Expand Down
2 changes: 1 addition & 1 deletion profiles/docker-compose-mongo.j2
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ services:
dockerfile: Dockerfile
args:
OPTIMADE_TOOLS_VERSION: 0.19.4
AIIDA_VERSION: 2.0.4
AIIDA_VERSION: 2.1.2
CONFIG_FILE: aiida_optimade/config.json
environment:
AIIDA_PATH: /app
Expand Down
2 changes: 1 addition & 1 deletion profiles/docker-compose-mongo.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ services:
dockerfile: Dockerfile
args:
OPTIMADE_TOOLS_VERSION: 0.19.4
AIIDA_VERSION: 2.0.4
AIIDA_VERSION: 2.1.2
CONFIG_FILE: aiida_optimade/config.json
environment:
AIIDA_PATH: /app
Expand Down
2 changes: 1 addition & 1 deletion profiles/docker-compose.j2
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ services:
dockerfile: Dockerfile
args:
OPTIMADE_TOOLS_VERSION: 0.19.4
AIIDA_VERSION: 2.0.4
AIIDA_VERSION: 2.1.2
CONFIG_FILE: aiida_optimade/config.json
environment:
AIIDA_PATH: /app
Expand Down
2 changes: 1 addition & 1 deletion profiles/docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ services:
dockerfile: Dockerfile
args:
OPTIMADE_TOOLS_VERSION: 0.19.4
AIIDA_VERSION: 2.0.4
AIIDA_VERSION: 2.1.2
CONFIG_FILE: aiida_optimade/config.json
environment:
AIIDA_PATH: /app
Expand Down
Loading