8000 Implement app reinstall button by edan-bainglass · Pull Request #250 · aiidalab/aiidalab-home · GitHub
[go: up one dir, main page]

Skip to content

Implement app reinstall button - #250

Merged
edan-bainglass merged 6 commits into
mainfrom
reinstall-button
Oct 2, 2026
Merged

edan-bainglass merged 6 commits into
mainfrom
reinstall-button

Conversation

@edan-bainglass
@edan-bainglass edan-bainglass commented Sep 26, 2026 •
Copy link
Copy Markdown
Member

Closes #245

Implements the button trigger the logic implemented in aiidalab/aiidalab#537 for reinstalling apps.

@cpignedoli
cpignedoli commented Sep 26, 2026 •
Copy link
Copy Markdown
Member

@edan-bainglass I checked 05a3ef786bc43035d2d931cbc1e9b2a1d98f0774 with Codex assistance, including real widget callback probes against the head of aiidalab/aiidalab#537. The button behaves correctly with the new backend.

Support scope clarified: our work targets aiida-core>=2.9.2 and the current AiiDAlab release or later (aiidalab>=26.9.0, based on the current v26.09.0 release, verified on 2026-09-26). Older runtime compatibility is outside our scope. I withdraw the earlier request to hide/disable the button for older backends; the 26.6.0 reproduction is not a blocker under this policy.

This UI still needs to ship with the backend change in aiidalab/aiidalab#537, as the PR description already states: the current released v26.09.0 does not yet contain reinstall_app(). Our working combination uses backend head 2b396274da5ac725c2b3de616719d32e679e0095. This is coordination of the two changes, not a request for backward compatibility.

The core-dependency protection remains a shared prerequisite. Reinstall is enabled even when the installed app has an incompatibility warning. That is appropriate for repairing missing ordinary dependencies, but the backend must reject conflicts with protected core packages before invoking pip. This protects the supported modern environment from being downgraded; it does not require supporting an older environment. Details and the intercepted-pip reproduction are in the review on aiidalab/aiidalab#537; this is the same finding, not an additional independent backend issue.

The added browser assertion only checks that the button exists. A callback test using the supported backend, covering a successful reinstall and an installation error, would help.

Validation on Python 3.12 / ipywidgets 8.1.8: with the new backend, widget probes passed for installed/uninstalled and busy states, locally modified/unregistered apps, a real button click forwarding the log output, success reporting, pip-error reporting with the diagnostic log retained, post-install-error reporting, and button recovery after failures. Installation and hook calls were intercepted; no live apps, packages, or daemon state were changed. All existing GitHub checks are green; I did not rerun the browser suite locally.

Comment thread home/app_manager.py Resolved
@edan-bainglass
Copy link
Copy Markdown
Member Author

@cpignedoli please re-review 🙏

@cpignedoli cpignedoli left a comment
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Thanks, Edan! I re-reviewed 16f6a16 with Codex assistance against the backend in aiidalab/aiidalab#537 (748bdcc). The core-compatibility condition addresses the earlier concern while keeping missing ordinary dependencies repairable. Widget probes passed for enable/disable behavior, output forwarding, success/error reporting, retained error logs, and requirements changed after the button was enabled. CI is green. This should ship together with the backend change, as documented.

One non-blocking suggestion is to add callback coverage alongside the browser button-presence check. Here is a compact example for tests/test_app_manager.py; I ran this exact snippet locally and all three cases passed. It isolates the callback with a mocked installer and the real log widget. Button enable/disable behavior would be a separate widget test.

Test example: success, pip failure and post-install failure
from subprocess import CalledProcessError
from types import SimpleNamespace
from unittest.mock import Mock

import pytest

from home.app_manager import AppManagerWidget
from home.widgets import LogOutputWidget


@pytest.mark.parametrize(
    "error",
    [None, RuntimeError("pip failed"), CalledProcessError(1, "post_install")],
    ids=["success", "pip-failure", "post-install-failure"],
)
def test_reinstall_callback(error):
    log = LogOutputWidget()

    def reinstall(*, stdout):
        assert stdout is log
        stdout.write("installation output\n")
        if error is not None:
            raise error

    app = SimpleNamespace(reinstall_app=Mock(side_effect=reinstall))
    manager = SimpleNamespace(
        app=app,
        dependencies_log=log,
        _show_msg_success=Mock(),
        _show_msg_failure=Mock(),
    )
    try:
        AppManagerWidget._reinstall_app(manager, None)

        app.reinstall_app.assert_called_once_with(stdout=log)
        if error is None:
            manager._show_msg_success.assert_called_once_with("Reinstalled app.")
            manager._show_msg_failure.assert_not_called()
            assert log.value == ""
        else:
            manager._show_msg_failure.assert_called_once_with(str(error))
            manager._show_msg_success.assert_not_called()
            assert log.value == "installation output\n"
    finally:
        log.close()

Local check: pytest -q --noconftest /tmp/test_aiidalab_home_pr250_callback_review.py — 3 passed on Python 3.12 / ipywidgets 8.1.8, with the reviewed checkouts on the import path. --noconftest avoids the unrelated repository-wide PostgreSQL fixture setup; the example itself needs no database and performs no installation.

Looks good to me!

@danielhollas danielhollas left a comment
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Nice, thanks!

I've tested this with my app: re-install works, and button is disabled if the core dependencies are not satisfied.

Comment thread home/app_manager.py Resolved
@danielhollas danielhollas left a comment
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Actually noticed one thing, the log must be cleared at the beginning, because it may contain stuff from previous (failed) install / re-install.

@danielhollas
Copy link
Copy Markdown
Contributor

Actually noticed one thing, the log must be cleared at the beginning, because it may contain stuff from previous (failed) install / re-install.

Hmm, I was testing this with the latest changes and for some reason the log is not being cleared in the UI when I click the re-install button. @edan-bainglass can you please test?

Here's my testing procedure:

  1. Modify setup.cfg in an installed app to contain an invalid package requirement, so that pip installation fails.
  2. Click "Reinstall". See that the log contains pip error and remains displayed.
  3. Click "Reinstall" again. The previous log doesn't seem to disappear.

@edan-bainglass
Copy link
Copy Markdown
Member Author

Hmm, I was testing this with the latest changes and for some reason the log is not being cleared in the UI when I click the re-install button. @edan-bainglass can you please test?

Here's my testing procedure:

  1. Modify setup.cfg in an installed app to contain an invalid package requirement, so that pip installation fails.
  2. Click "Reinstall". See that the log contains pip error and remains displayed.
  3. Click "Reinstall" again. The previous log doesn't seem to disappear.

Hi @danielhollas. I'm getting around to this now. Quick question - I'm a bit confused at your testing procedure, as pip would install from pypi, not local. Did you modify the app to point to your local environment for the installation?

@danielhollas
Copy link
Copy Markdown
Contributor

I have modified the setup.cfg file in an already installed app (e.g. apps/quantum-espresso/setup.cfg) When you then run the reinstall, it executes pip install . inside the app directory and pip reads the dependencies from setup.cfg.

Does that answer your question?

@edan-bainglass
Copy link
Copy Markdown
Member Author

I have modified the setup.cfg file in an already installed app (e.g. apps/quantum-espresso/setup.cfg) When you then run the reinstall, it executes pip install . inside the app directory and pip reads the dependencies from setup.cfg.

Does that answer your question?

Thanks @danielhollas. I missed that we run pip install . in the local directory 🙂
Regarding the test itself, hitting reinstall clears the old log and starts fresh, so I cannot reproduce your issue. However, I am now considering adding perhaps a clear output button, as there is no UI means of doing so. Thoughts?

@danielhollas
Copy link
Copy Markdown
Contributor

Thanks. Can you make a quick screencast just to make sure we're looking at the same thing? (it is very possible that the issue occurs only in my old Firefox version, I'll also try to test on chromium).

I think the clear button would be an overkill for now, since this is only a problem in the error path. If it turns out the issue happens only in my browser I am happy to merge this as is.

@edan-bainglass
edan-bainglass commented Oct 2, 2026 •
Copy link
Copy Markdown
Member Author

Thanks. Can you make a quick screencast just to make sure we're looking at the same thing? (it is very possible that the issue occurs only in my old Firefox version, I'll also try to test on chromium).

appstore-reinstall.mp4

Tested on Chrome

I think the clear button would be an overkill for now, since this is only a problem in the error path. If it turns out the issue happens only in my browser I am happy to merge this as is.

Sure 🙂

@danielhollas danielhollas left a comment
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Alright, I've re-tested on both Firefox and Chromium and it works, I am not sure what I was doing before. Sorry for the noise, let's merge! 🚀

@edan-bainglass
edan-bainglass merged commit 9554161 into main Oct 2, 2026
5 checks passed
@edan-bainglass
edan-bainglass deleted the reinstall-button branch October 2, 2026 12:56
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Implement Reinstall button

3 participants

0