Skip to content

Fix code loading bug - #1519

Merged
edan-bainglass merged 5 commits into
mainfrom
fix-code-loading-bug
Jun 6, 2026
Merged

Fix code loading bug#1519
edan-bainglass merged 5 commits into
mainfrom
fix-code-loading-bug

Conversation

@edan-bainglass

@edan-bainglass edan-bainglass commented Jun 5, 2026

Copy link
Copy Markdown
Member

To prevent users from submitting calculations with unconfigured codes, we filter them out:

return [
(self._full_code_label(code), code.uuid)
for code in codes
if code.computer.is_user_configured(user)
and (self.allow_hidden_codes or not code.is_hidden)
and (self.allow_disabled_computers or code.computer.is_user_enabled(user))
]

However, this SHOULD NOT happen when loading a process, since the user cannot submit in that state. But it was, so step 3 was emitting blockers due to unselected codes. Prior to #1513, the blockers didn't do their job of blocking the step, but now they do. So if someone loads the app from a process that was run by someone else (e.g., a downloaded example), step 3 is blocked and step 4 never loads.

This PR adds a filter_codes_for_user flag injected through the resources refresh mechanism that is generally True but set to False if we're loading a process. In addition, the PR relaxes default code handling, falling back on the first available code option if the default code does not exist. Finally, the PR removes the blocking of step 3 w.r.t the local QE installation status, since users should still be allowed to proceed with remote submission.

@codecov

codecov Bot commented Jun 5, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 92.30769% with 1 line in your changes missing coverage. Please review.
✅ Project coverage is 75.28%. Comparing base (9ba5c42) to head (41a2c02).

Files with missing lines Patch % Lines
src/aiidalab_qe/common/code/model.py 83.33% 1 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main    #1519      +/-   ##
==========================================
+ Coverage   75.24%   75.28%   +0.03%     
==========================================
  Files         115      115              
  Lines        7381     7371      -10     
==========================================
- Hits         5554     5549       -5     
+ Misses       1827     1822       -5     
Flag Coverage Δ
python-3.12 75.28% <92.30%> (+0.03%) ⬆️
python-3.9 75.31% <92.30%> (+0.03%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

Comment on lines +50 to +54
"""Toggle code selectors conditional on plugin activity and required parameters.

For a given code (e.g., pw), if at least one active plugin requires it (if any condition
registered for the code is met), we activate it.
"""

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Driveby change - just adding some documentation to clarify what this method is doing. Unrelated to this PR.

super().confirm()
if not self.has_process:
self._submit()
self.lock()

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

This is the best logical point for the locking mechanism. If step 3 is confirmed, it should be locked to prevent further submissions.

Comment on lines +154 to +156
def refresh_codes(self, filter_codes_for_user: bool = True):
for _, resource_model in self.get_models():
resource_model.refresh_codes(filter_codes_for_user=filter_codes_for_user)

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Helper method used when loading a process.

Comment on lines -210 to -222
def _link_model(self, model: ResourceSettingsModel):
for dependency in model.dependencies:
dependency_parts = dependency.split(".")
if len(dependency_parts) == 1: # from parent, e.g. input_structure
target_model = self
trait = dependency
else: # from sibling, e.g. workchain.protocol
sibling, trait = dependency_parts
target_model = self.get_model(sibling)
ipw.dlink(
(target_model, trait),
(model, trait),
)

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

This is a remnant that avoided removal in previous PRs. Effectively, it was leading to a broken state, as the parent _link_model, in additional to already covering this logic, has additional logic that is missed by having this override here (e.g., wiring the locked and blockers traits).

Comment on lines +48 to +49
if process_uuid is not None:
submission_model.refresh_codes(filter_codes_for_user=False)

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Th key change - if there's a process, don't filter out codes!

The installation of Quantum ESPRESSO is a background process that
triggers if no local QE installation is detected. However, the user
should be allowed to submit calculations on remote machines that host
some QE installation.
@edan-bainglass
edan-bainglass force-pushed the fix-code-loading-bug branch from 5124180 to 41a2c02 Compare June 5, 2026 13:02
Comment on lines -259 to -264
if self.installing_qe:
yield "Installing Quantum ESPRESSO codes..."

if not self.qe_installed:
yield "Quantum ESPRESSO is not yet installed"

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Users should be allowed to proceed with remote submission on a machine that hosts some QE installation.

self.warning = self._WARNING_TEMPLATE.format(
warning=f"Code '{default_code}' not found"
)
selected = self.first_option

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

None would block the step, but there may be valid code options, e.g., remote ones.

@yakutovicha yakutovicha 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.

The code looks good. I've also tested it for some discovered failures - it works flawlessly now.

@edan-bainglass
edan-bainglass merged commit cbace9d into main Jun 6, 2026
15 of 18 checks passed
@edan-bainglass
edan-bainglass deleted the fix-code-loading-bug branch June 6, 2026 03:32
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.

2 participants