Skip to content

Commit

Permalink
♻️ REFACTOR: Remove Django storage backend
Browse files Browse the repository at this point in the history
  • Loading branch information
chrisjsewell authored and sphuber committed Feb 16, 2022
1 parent a193a4c commit a8b3da3
Show file tree
Hide file tree
Showing 433 changed files with 10,025 additions and 14,912 deletions.
8 changes: 4 additions & 4 deletions .github/config/profile.yaml
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
---
profile: PLACEHOLDER_PROFILE
profile: test_aiida
email: aiida@localhost
first_name: Giuseppe
last_name: Verdi
institution: Khedivial
db_backend: PLACEHOLDER_BACKEND
db_backend: psql_dos
db_engine: postgresql_psycopg2
db_host: localhost
db_port: 5432
db_name: PLACEHOLDER_DATABASE_NAME
db_name: test_aiida
db_username: postgres
db_password: ''
broker_protocol: amqp
Expand All @@ -17,4 +17,4 @@ broker_password: guest
broker_host: 127.0.0.1
broker_port: 5672
broker_virtual_host: ''
repository: PLACEHOLDER_REPOSITORY
repository: /tmp/test_repository_test_aiida/
4 changes: 2 additions & 2 deletions .github/system_tests/test_polish_workchains.sh
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,10 @@ VERDI=$(which verdi)

if [ -n "$EXPRESSIONS" ]; then
for expression in "${EXPRESSIONS[@]}"; do
$VERDI -p test_${AIIDA_TEST_BACKEND} run "${CLI_SCRIPT}" -X $CODE -C -F -d -t $TIMEOUT "$expression"
$VERDI -p test_aiida run "${CLI_SCRIPT}" -X $CODE -C -F -d -t $TIMEOUT "$expression"
done
else
for i in $(seq 1 $NUMBER_WORKCHAINS); do
$VERDI -p test_${AIIDA_TEST_BACKEND} run "${CLI_SCRIPT}" -X $CODE -C -F -d -t $TIMEOUT
$VERDI -p test_aiida run "${CLI_SCRIPT}" -X $CODE -C -F -d -t $TIMEOUT
done
fi
2 changes: 1 addition & 1 deletion .github/system_tests/test_profile_manager.py
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ def test_create_use_destroy_profile2(self):
with self.assertRaises(TestManagerError):
self.test_create_aiida_db()

self.profile_manager.reset_db()
self.profile_manager.clear_profile()
with self.assertRaises(Exception):
load_node(data_pk)

Expand Down
4 changes: 4 additions & 0 deletions .github/workflows/benchmark-config.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,10 @@
"pytest-benchmarks:ubuntu-18.04,sqlalchemy": {
"header": "Performance Benchmarks (Ubuntu-18.04, SQLAlchemy)",
"description": "Performance benchmark tests, generated using pytest-benchmark."
},
"pytest-benchmarks:ubuntu-18.04,psql_dos": {
"header": "Performance Benchmarks (Ubuntu-18.04)",
"description": "Performance benchmark tests, generated using pytest-benchmark."
}
},
"groups": {
Expand Down
9 changes: 3 additions & 6 deletions .github/workflows/benchmark.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@ jobs:
os: [ubuntu-18.04]
postgres: ['12.3']
rabbitmq: ['3.8.3']
backend: ['django', 'sqlalchemy']

runs-on: ${{ matrix.os }}
timeout-minutes: 60
Expand All @@ -29,7 +28,7 @@ jobs:
postgres:
image: "postgres:${{ matrix.postgres }}"
env:
POSTGRES_DB: test_${{ matrix.backend }}
POSTGRES_DB: test_aiida
POSTGRES_PASSWORD: ''
POSTGRES_HOST_AUTH_METHOD: trust
options: >-
Expand Down Expand Up @@ -79,15 +78,13 @@ jobs:
pip freeze
- name: Run benchmarks
env:
AIIDA_TEST_BACKEND: ${{ matrix.backend }}
run: pytest --benchmark-only --benchmark-json benchmark.json

- name: Store benchmark result
uses: aiidateam/github-action-benchmark@v3
with:
benchmark-data-dir-path: "dev/bench/${{ matrix.os }}/${{ matrix.backend }}"
name: "pytest-benchmarks:${{ matrix.os }},${{ matrix.backend }}"
benchmark-data-dir-path: "dev/bench/${{ matrix.os }}/psql_dos"
name: "pytest-benchmarks:${{ matrix.os }},psql_dos"
metadata: "postgres:${{ matrix.postgres }}, rabbitmq:${{ matrix.rabbitmq }}"
output-file-path: benchmark.json
render-json-path: .github/workflows/benchmark-config.json
Expand Down
11 changes: 3 additions & 8 deletions .github/workflows/ci-code.yml
Original file line number Diff line number Diff line change
Expand Up @@ -44,19 +44,18 @@ jobs:
needs: [check-requirements]

runs-on: ubuntu-latest
timeout-minutes: 30
timeout-minutes: 35

strategy:
fail-fast: false
matrix:
python-version: ['3.8', '3.10']
backend: ['django', 'sqlalchemy']

services:
postgres:
image: postgres:10
env:
POSTGRES_DB: test_${{ matrix.backend }}
POSTGRES_DB: test_aiida
POSTGRES_PASSWORD: ''
POSTGRES_HOST_AUTH_METHOD: trust
options: >-
Expand Down Expand Up @@ -116,14 +115,11 @@ jobs:
pip freeze
- name: Setup environment
env:
AIIDA_TEST_BACKEND: ${{ matrix.backend }}
run:
.github/workflows/setup.sh

- name: Run test suite
env:
AIIDA_TEST_BACKEND: ${{ matrix.backend }}
SQLALCHEMY_WARN_20: 1
run:
.github/workflows/tests.sh
Expand All @@ -132,8 +128,7 @@ jobs:
if: matrix.python-version == 3.8 && github.repository == 'aiidateam/aiida-core'
uses: codecov/codecov-action@v1
with:
name: aiida-pytests-py3.8-${{ matrix.backend }}
flags: ${{ matrix.backend }}
name: aiida-pytests-py3.8
file: ./coverage.xml
fail_ci_if_error: false # don't fail job, if coverage upload fails

Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/rabbitmq.yml
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ jobs:
postgres:
image: postgres:10
env:
POSTGRES_DB: test_django
POSTGRES_DB: test_aiida
POSTGRES_PASSWORD: ''
POSTGRES_HOST_AUTH_METHOD: trust
options: >-
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ jobs:
postgres:
image: postgres:10
env:
POSTGRES_DB: test_django
POSTGRES_DB: test_aiida
POSTGRES_PASSWORD: ''
POSTGRES_HOST_AUTH_METHOD: trust
options: >-
Expand Down
6 changes: 1 addition & 5 deletions .github/workflows/setup.sh
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,6 @@ chmod 755 "${HOME}"
# Replace the placeholders in configuration files with actual values
CONFIG="${GITHUB_WORKSPACE}/.github/config"
cp "${CONFIG}/slurm_rsa" "${HOME}/.ssh/slurm_rsa"
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_WORK_DIR|${GITHUB_WORKSPACE}|" "${CONFIG}/localhost.yaml"
sed -i "s|PLACEHOLDER_REMOTE_ABS_PATH_DOUBLER|${CONFIG}/doubler.sh|" "${CONFIG}/doubler.yaml"
sed -i "s|PLACEHOLDER_SSH_KEY|${HOME}/.ssh/slurm_rsa|" "${CONFIG}/slurm-ssh-config.yaml"
Expand All @@ -33,5 +29,5 @@ verdi computer setup --non-interactive --config "${CONFIG}/slurm-ssh.yaml"
verdi computer configure core.ssh slurm-ssh --non-interactive --config "${CONFIG}/slurm-ssh-config.yaml" -n # needs slurm container
verdi computer test slurm-ssh --print-traceback

verdi profile setdefault test_${AIIDA_TEST_BACKEND}
verdi profile setdefault test_aiida
verdi config set runner.poll.interval 0
10 changes: 3 additions & 7 deletions .github/workflows/test-install.yml
Original file line number Diff line number Diff line change
Expand Up @@ -177,19 +177,18 @@ jobs:

needs: [install-with-pip]
runs-on: ubuntu-latest
timeout-minutes: 30
timeout-minutes: 35

strategy:
fail-fast: false
matrix:
python-version: ['3.8', '3.9', '3.10']
backend: ['django', 'sqlalchemy']

services:
postgres:
image: postgres:10
env:
POSTGRES_DB: test_${{ matrix.backend }}
POSTGRES_DB: test_aiida
POSTGRES_PASSWORD: ''
POSTGRES_HOST_AUTH_METHOD: trust
options: >-
Expand Down Expand Up @@ -234,14 +233,12 @@ jobs:
- run: pip freeze

- name: Setup AiiDA environment
env:
AIIDA_TEST_BACKEND: ${{ matrix.backend }}
run:
.github/workflows/setup.sh

- name: Run test suite
env:
AIIDA_TEST_BACKEND: ${{ matrix.backend }}
SQLALCHEMY_WARN_20: 1
run:
.github/workflows/tests.sh

Expand All @@ -252,7 +249,6 @@ jobs:
# This artifact can be used in the next step to automatically create a pull request
# updating the requirements (in case they are inconsistent with the pyproject.toml file).
- uses: actions/upload-artifact@v1
if: matrix.backend == 'django' # The requirements are identical between backends.
with:
name: requirements.txt
path: requirements-py-${{ matrix.python-version }}.txt
Expand Down
6 changes: 3 additions & 3 deletions .github/workflows/tests.sh
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ export PYTHONPATH="${PYTHONPATH}:${SYSTEM_TESTS}:${MODULE_POLISH}"

# daemon tests
verdi daemon start 4
verdi -p test_${AIIDA_TEST_BACKEND} run ${SYSTEM_TESTS}/test_daemon.py
verdi -p test_aiida run ${SYSTEM_TESTS}/test_daemon.py
bash ${SYSTEM_TESTS}/test_polish_workchains.sh
verdi daemon stop

Expand All @@ -21,7 +21,7 @@ python ${SYSTEM_TESTS}/test_plugin_testcase.py # uses custom unittest test runn

# Until the `${SYSTEM_TESTS}/pytest` tests are moved within `tests` we have to run them separately and pass in the path to the
# `conftest.py` explicitly, because otherwise it won't be able to find the fixtures it provides
AIIDA_TEST_PROFILE=test_$AIIDA_TEST_BACKEND pytest --cov aiida --verbose tests/conftest.py ${SYSTEM_TESTS}/pytest
AIIDA_TEST_PROFILE=test_aiida pytest --cov aiida --verbose tests/conftest.py ${SYSTEM_TESTS}/pytest

# main aiida-core tests
AIIDA_TEST_PROFILE=test_$AIIDA_TEST_BACKEND pytest --cov aiida --verbose tests
AIIDA_TEST_PROFILE=test_aiida pytest --cov aiida --verbose tests
17 changes: 5 additions & 12 deletions .molecule/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ The simplest way to run these tests is to use the `tox` environment provided in

```console
$ pip install tox
$ tox -e molecule-django
$ tox -e molecule
```

**NOTE**: if you wan to run molecule directly, ensure that you set `export MOLECULE_GLOB=.molecule/*/config_local.yml`.
Expand All @@ -29,32 +29,25 @@ This runs the `test` scenario (defined in `config_local.yml`) which:
If you wish to setup the container for manual inspection (i.e. only run steps 2 - 4) you can run:

```console
$ tox -e molecule-django converge
$ tox -e molecule converge
```

Then you can jump into this container or run the tests (step 5) separately with:

```console
$ tox -e molecule-django validate
$ tox -e molecule validate
```

and finally run step 6:

```console
$ tox -e molecule-django destroy
```

You can set up the aiida profile with either django or sqla,
and even run both in parallel:

```console
$ tox -e molecule-django,molecule-sqla -p -- test --parallel
$ tox -e molecule destroy
```

## Additional variables

You can specify the number of daemon workers to spawn using the `AIIDA_TEST_WORKERS` environment variable:

```console
$ AIIDA_TEST_WORKERS=4 tox -e molecule-django
$ AIIDA_TEST_WORKERS=4 tox -e molecule
```
8 changes: 4 additions & 4 deletions .molecule/default/config_local.yml
Original file line number Diff line number Diff line change
Expand Up @@ -22,14 +22,14 @@ scenario:
driver:
name: docker
platforms:
- name: molecule-aiida-${AIIDA_TEST_BACKEND:-django}
- name: molecule-aiida-${AIIDA_TEST_BACKEND:-psql_dos}
image: molecule_tests
context: "../.."
command: /sbin/my_init
healthcheck:
test: wait-for-services
volumes:
- molecule-pip-cache-${AIIDA_TEST_BACKEND:-django}:/home/.cache/pip
- molecule-pip-cache-${AIIDA_TEST_BACKEND:-psql_dos}:/home/.cache/pip
privileged: true
retries: 3
# configuration for how to run the playbooks
Expand Down Expand Up @@ -63,7 +63,7 @@ provisioner:
aiida_pip_cache: /home/.cache/pip
venv_bin: /opt/conda/bin
ansible_python_interpreter: "{{ venv_bin }}/python"
aiida_backend: ${AIIDA_TEST_BACKEND:-django}
aiida_backend: ${AIIDA_TEST_BACKEND:-psql_dos}
aiida_workers: ${AIIDA_TEST_WORKERS:-2}
aiida_path: /tmp/.aiida_${AIIDA_TEST_BACKEND:-django}
aiida_path: /tmp/.aiida_${AIIDA_TEST_BACKEND:-psql_dos}
aiida_query_stats: true
1 change: 0 additions & 1 deletion .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,6 @@ repos:
aiida/orm/implementation/nodes.py|
aiida/orm/implementation/users.py|
aiida/orm/implementation/sql/backends.py|
aiida/orm/implementation/django/backend.py|
aiida/orm/implementation/sqlalchemy/backend.py|
aiida/orm/implementation/querybuilder.py|
aiida/orm/implementation/sqlalchemy/querybuilder/.*py|
Expand Down
2 changes: 1 addition & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ ENV USER_EMAIL aiida@localhost
ENV USER_FIRST_NAME Giuseppe
ENV USER_LAST_NAME Verdi
ENV USER_INSTITUTION Khedivial
ENV AIIDADB_BACKEND django
ENV AIIDADB_BACKEND psql_dos

# Copy and install AiiDA
COPY . aiida-core
Expand Down
12 changes: 4 additions & 8 deletions aiida/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
More information at http://www.aiida.net
"""
from aiida.common.log import configure_logging
from aiida.manage.configuration import get_config_option, get_profile, load_profile
from aiida.manage.configuration import get_config_option, get_profile, load_profile, profile_context

__copyright__ = (
'Copyright (c), This file is part of the AiiDA platform. '
Expand All @@ -48,31 +48,29 @@ def get_strict_version():
return StrictVersion(__version__)


def get_version():
def get_version() -> str:
"""
Return the current AiiDA distribution version
:returns: the current version
:rtype: str
"""
return __version__


def _get_raw_file_header():
def _get_raw_file_header() -> str:
"""
Get the default header for source AiiDA source code files.
Note: is not preceded by comment character.
:return: default AiiDA source file header
:rtype: str
"""
return f"""This file has been created with AiiDA v. {__version__}
If you use AiiDA for publication purposes, please cite:
{__paper__}
"""


def get_file_header(comment_char='# '):
def get_file_header(comment_char: str = '# ') -> str:
"""
Get the default header for source AiiDA source code files.
Expand All @@ -81,10 +79,8 @@ def get_file_header(comment_char='# '):
Prepend by comment character.
:param comment_char: string put in front of each line
:type comment_char: str
:return: default AiiDA source file header
:rtype: str
"""
lines = _get_raw_file_header().splitlines()
return '\n'.join(f'{comment_char}{line}' for line in lines)
Loading

0 comments on commit a8b3da3

Please sign in to comment.