Skip to content

Commit

Permalink
Use new aiida-core docker stack (#280)
Browse files Browse the repository at this point in the history
fixes #276 

Use new `aiidateam/aiida-core-with-services` docker image, with force the `aiida-core` version. Which means if the plugin version is not conform with the latest released `aiida-core` version, the plugin installation check will fail.

I need to make the `_DOCKER_WORKDIR` writable by (o)ther (umask=000) since the new docker stack has default aiida as system user rather than root. This also makes it possible to run on local system that don't have UID=1000.
  • Loading branch information
unkcpz authored Dec 4, 2023
1 parent ec74f0f commit ce1d3af
Show file tree
Hide file tree
Showing 6 changed files with 33 additions and 13 deletions.
3 changes: 3 additions & 0 deletions .github/actions/generate-metadata/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,10 @@ runs:

- name: Check installation of plugins
if: ${{ inputs.cache == 'false' }}
# Attach plugin installation information to the metadata, e.g. if the plugin can be installed or not
# Need to make the _DOCKER_WORKDIR writable by (o)thers since the new docker stack has default aiida as system user rather than root.
run: |
umask 000 && chmod +w ../aiida-registry
aiida-registry test-install
shell: bash

Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ jobs:
runs-on: ubuntu-latest
strategy:
fail-fast: false
timeout-minutes: 60
timeout-minutes: 180
env:
COMMIT_AUTHOR: Deploy Action
COMMIT_AUTHOR_EMAIL: [email protected]
Expand Down
1 change: 1 addition & 0 deletions .github/workflows/webpage.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ on:

jobs:
webpage:
timeout-minutes: 90
if: github.repository == 'aiidateam/aiida-registry'

runs-on: ubuntu-latest
Expand Down
4 changes: 2 additions & 2 deletions aiida-registry-app/src/Components/PluginsList.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -122,8 +122,8 @@ function CheckMark() {
<DialogContent>
<DialogContentText>
This check mark indicates that this plugin was installed successfully inside the latest
<a rel='noopener noreferrer' target='_blank' href='https://hub.docker.com/r/aiidateam/aiida-core'><code> aiida-core</code> docker image</a>.
For in-depth compatibility tests see the source code repository of the plugin.
<a rel='noopener noreferrer' target='_blank' href='https://hub.docker.com/r/aiidateam/aiida-core-with-services'><code>aiida-core-with-services</code> docker image</a>.
For in-depth compatibility tests see <a rel='noopener noreferrer' target='_blank' href='https://github.com/aiidateam/aiida-registry/tree/master#how-to-fix-registry-warnings-and-errors'>how to reproduce it locally</a>.
</DialogContentText>
</DialogContent>
</Dialog>
Expand Down
3 changes: 1 addition & 2 deletions aiida_registry/cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,7 @@ def fetch(package):
@click.option(
"--container-image",
# should use aiidateam/aiida-core-with-services:lastest after the version is released
# default="aiidateam/aiida-core-with-services:edge",
default="aiidateam/aiida-core:latest",
default="ghcr.io/aiidateam/aiida-core-with-services:latest",
help="Container image to use for the install",
)
def test_install(container_image):
Expand Down
33 changes: 25 additions & 8 deletions aiida_registry/test_install.py
Original file line number Diff line number Diff line change
Expand Up @@ -84,9 +84,10 @@ def handle_error(process_result, message, check_id=None):

def test_install_one_docker(container_image, plugin):
"""Test installing one plugin in a Docker container."""
import docker # pylint: disable=import-outside-toplevel
# pylint: disable=too-many-locals,import-outside-toplevel
import docker

client = docker.from_env(timeout=180)
client = docker.from_env(timeout=120)

is_package_installed = False
is_package_importable = False
Expand All @@ -101,28 +102,43 @@ def test_install_one_docker(container_image, plugin):
volumes={os.getcwd(): {"bind": _DOCKER_WORKDIR, "mode": "rw"}},
)

user = container.exec_run("whoami").output.decode("utf8").strip()

try:
print(" - Installing plugin {}".format(plugin["name"]))
install_package = container.exec_run(f'pip install --pre {plugin["pip_url"]}')
aiida_version_output = (
container.exec_run(
"verdi --version",
user=user,
)
.output.decode("utf8")
.strip()
)
aiida_version = aiida_version_output.split(" ")[-1]
container.exec_run(
f'sh -c "echo aiida-core=="{aiida_version}" > /tmp/pip-constraint.txt"',
user=user,
)
install_package = container.exec_run(
f'pip install --constraint /tmp/pip-constraint.txt --pre {plugin["pip_url"]}',
user=user,
)

error_message = handle_error(
install_package,
f"Failed to install plugin {plugin['name']}",
check_id="E001",
)

# Should make this depend on the AiiDA version inside the container,
# at least after 2.0 is out that removes reentry
_reentry_scan = container.exec_run("reentry scan -r aiida")

is_package_installed = True

if "package_name" not in list(plugin.keys()):
plugin["package_name"] = plugin["name"].replace("-", "_")

print(" - Importing {}".format(plugin["package_name"]))
import_package = container.exec_run(
"python -c 'import {}'".format(plugin["package_name"])
"python -c 'import {}'".format(plugin["package_name"]),
user=user,
)

error_message = handle_error(
Expand All @@ -138,6 +154,7 @@ def test_install_one_docker(container_image, plugin):
extract_metadata = container.exec_run(
workdir=_DOCKER_WORKDIR,
cmd="python ./bin/analyze_entrypoints.py -o result.json",
user=user,
)
error_message = handle_error(
extract_metadata,
Expand Down

0 comments on commit ce1d3af

Please sign in to comment.