Skip to content

Commit

Permalink
Add test-install errors to the registry checks.
Browse files Browse the repository at this point in the history
  • Loading branch information
AhmedBasem20 authored and ltalirz committed Sep 17, 2023
1 parent 250383a commit f182c30
Show file tree
Hide file tree
Showing 3 changed files with 36 additions and 14 deletions.
21 changes: 16 additions & 5 deletions aiida-registry-app/src/Components/Details.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -76,13 +76,24 @@ function Details({pluginKey}) {
</div>

<h3>Registry checks</h3>
{value.warnings ? (
{value.warnings || value.errors ? (
<>
{value.warnings.map((warning) => (
<Alert severity="warning">{warning}</Alert>
))}
{value.warnings && (
<>
{value.warnings.map((warning) => (
<Alert severity="warning">{warning}</Alert>
))}
</>
)}
{value.errors && (
<>
{value.errors.map((error) => (
<Alert severity="error"><pre>{error}</pre></Alert>
))}
</>
)}
</>
):(
) : (
<Alert severity="success">All checks passed!</Alert>
)}

Expand Down
21 changes: 13 additions & 8 deletions aiida_registry/fetch_metadata.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,10 @@
from .parse_pypi import PypiData, get_pypi_metadata
from .utils import fetch_file

GITHUB_TOKEN = os.environ["GITHUB_TOKEN"]
try:
GITHUB_TOKEN = os.environ["GITHUB_TOKEN"]
except KeyError:
GITHUB_TOKEN = ""


@lru_cache(maxsize=None)
Expand Down Expand Up @@ -354,12 +357,16 @@ def is_pip_url_pypi(string: str) -> bool:
return PYPI_NAME_RE.match(string) is not None


def add_warnings(metadata):
"""Add fetch warnings to the data object."""
def add_registry_checks(metadata, include_errors=False):
"""Add fetch warnings/errors to the data object."""
plugins_warnings = REPORTER.plugins_warnings

for name, warnings in plugins_warnings.items():
metadata[name]["warnings"] = warnings
if include_errors:
for name, error_list in plugins_warnings.items():
metadata["plugins"][name]["errors"] = error_list
else:
for name, warning_list in plugins_warnings.items():
metadata[name]["warnings"] = warning_list

return metadata

Expand All @@ -379,9 +386,7 @@ def fetch_metadata(filter_list=None, fetch_pypi=True, fetch_pypi_wheel=True):
plugins_metadata[plugin_name] = complete_plugin_data(
plugin_data, fetch_pypi=fetch_pypi, fetch_pypi_wheel=fetch_pypi_wheel
)

plugins_metadata = add_warnings(plugins_metadata)

plugins_metadata = add_registry_checks(plugins_metadata)
REPORTER.info(f"{PLUGINS_METADATA} dumped")

if os.environ.get("GITHUB_ACTIONS") == "true":
Expand Down
8 changes: 7 additions & 1 deletion aiida_registry/test_install.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,9 @@
import sys
from dataclasses import asdict, dataclass

from . import PLUGINS_METADATA
from aiida_registry.fetch_metadata import add_registry_checks

from . import PLUGINS_METADATA, REPORTER

# Where to mount the workdir inside the Docker container
_DOCKER_WORKDIR = "/tmp/scripts"
Expand Down Expand Up @@ -72,6 +74,7 @@ def handle_error(process_result, message):

if process_result.exit_code != 0:
error_message = process_result.output.decode("utf8")
REPORTER.warn(f"{message}\n{error_message}")
raise ValueError(f"{message}\n{error_message}")

return error_message
Expand All @@ -87,6 +90,7 @@ def test_install_one_docker(container_image, plugin):
is_package_importable = False
process_metadata = {}
error_message = ""
REPORTER.set_plugin_name(plugin["name"])

print(" - Starting container for {}".format(plugin["name"]))
container = client.containers.run(
Expand Down Expand Up @@ -219,6 +223,8 @@ def test_install_all(container_image):
except KeyError:
continue

data = add_registry_checks(data, include_errors=True)

print("Dumping plugins.json")
with open(PLUGINS_METADATA, "w", encoding="utf8") as handle:
json.dump(data, handle, indent=2)
Expand Down

0 comments on commit f182c30

Please sign in to comment.