Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Computer setup: Fix core.local transport #502

Merged

Conversation

danielhollas
Copy link
Contributor

It is not clear whether AiiDA Computer setup ever worked with any transport other than SSH,
but in any case the widget is clearly designed with SSH in mind so unless a clear need is found we can simply remove the 'Transport type" dropdown. Note the the value of this widget has not been used anywhere in the code, which is telling.

The localhost computer is setup in the AiiDAlab Docker image by default, and in the unlikely case that another one needs to be setup, such user probably knows how to set it up via verdi command line interface.

Fixes #417

@codecov
Copy link

codecov bot commented Aug 16, 2023

Codecov Report

Patch coverage: 81.39% and project coverage change: +0.04% 🎉

Comparison is base (aec8f87) 79.46% compared to head (15494bf) 79.50%.

Additional details and impacted files
@@            Coverage Diff             @@
##           master     #502      +/-   ##
==========================================
+ Coverage   79.46%   79.50%   +0.04%     
==========================================
  Files          27       27              
  Lines        3759     3792      +33     
==========================================
+ Hits         2987     3015      +28     
- Misses        772      777       +5     
Flag Coverage Δ
python-3.10 79.50% <81.39%> (+0.04%) ⬆️
python-3.8 79.54% <81.39%> (+0.04%) ⬆️
python-3.9 79.54% <81.39%> (+0.04%) ⬆️

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

Files Changed Coverage Δ
aiidalab_widgets_base/computational_resources.py 70.76% <72.41%> (+0.10%) ⬆️
tests/test_computational_resources.py 100.00% <100.00%> (ø)

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

@danielhollas danielhollas mentioned this pull request Aug 16, 2023
10 tasks
Copy link
Member

@yakutovicha yakutovicha left a comment

Choose a reason for hiding this comment

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

I think this is good for now.

However, later I am introducing the ssh_light which will revert things to Dropdown. Then, there will be firecrest. It would take some more work to adopt them, though.

Therefore, for now, it is good to keep it as HTML to signify that widget is not dealing with other cases.

I would only request to keep the self.transport.value = "core.ssh" line and set the original value to core.ssh too.

It was issued later on. Also, settings downloaded from the code database override the value. Herein, SSH as the value may cause trouble.

@danielhollas
Copy link
Contributor Author

However, later I am introducing the aiidateam/aiida-core#6083 which will revert things to Dropdown. Then, there will be firecrest. It would take some more work to adopt them, though.

Ah, that's good to know. I also found out that the transport value is indeed passed to the computer setup function, I did not notice that before since it is accessed via getattrs

kwargs = {key: getattr(self, key).value for key in items_to_configure}

I would only request to keep the self.transport.value = "core.ssh" line and set the original value to core.ssh too.
It was issued later on. Also, settings downloaded from the code database override the value. Herein, SSH as the value may cause trouble.

Another good point. As a side note, I am not a fan of this design, core.ssh is not very user friendly, we're essentially exposing the user to internal AiiDA details. But that's for another time...

Given all of the above, I've reverted the original change and instead fix the underlying bug and made the core.local transport work. I also added a unit test. @yakutovicha could you please test locally?

@danielhollas danielhollas changed the title Remove Transport dropdown in computer setup, assume SSH Computer setup: Fix core.local transport Aug 23, 2023
"safe_interval": self.safe_interval.value,
}
user = orm.User.collection.get_default()
computer.configure(user=user, **authparams)
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Note that we need to catch any potential errors here. Since this was not done in the original function, I am keeping that for separate PR.

Copy link
Member

@yakutovicha yakutovicha left a comment

Choose a reason for hiding this comment

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

Thanks, @danielhollas. As you've suggested, let's not allow creating a computer if its configuration is not working. The rest is good, I tested the widget locally and it works as expected 👍 .

aiidalab_widgets_base/computational_resources.py Outdated Show resolved Hide resolved
aiidalab_widgets_base/computational_resources.py Outdated Show resolved Hide resolved
Validate more inputs and catch more errors.
Copy link
Contributor Author

@danielhollas danielhollas left a comment

Choose a reason for hiding this comment

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

@yakutovicha I've made some more improvements, can you take a look?

@@ -902,16 +936,15 @@ def on_setup_computer(self, _=None):
)
try:
computer = computer_builder.new()
self._configure_computer(computer)
self._configure_computer(computer, self.transport.value)
computer.store()
Copy link
Contributor Author

@danielhollas danielhollas Aug 31, 2023

Choose a reason for hiding this comment

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

I've moved this call here since it can also fail.

Strangely, when a user provides empty workdir, the store command raises ValidationError, but the computer is still stored. That to me seems like aiida-core bug.

aiidalab_widgets_base/computational_resources.py Outdated Show resolved Hide resolved
Copy link
Member

@yakutovicha yakutovicha left a comment

Choose a reason for hiding this comment

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

Thanks, @danielhollas. I suggested a few minor changes. I also tested it, all good.

aiidalab_widgets_base/computational_resources.py Outdated Show resolved Hide resolved
Copy link
Member

@yakutovicha yakutovicha left a comment

Choose a reason for hiding this comment

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

I tested the latest changes - all good 👍. Ship it 🚢 !

@danielhollas danielhollas merged commit b245929 into aiidalab:master Sep 6, 2023
@danielhollas danielhollas deleted the fix/computer-transport-only-ssh branch September 6, 2023 13:56
@danielhollas
Copy link
Contributor Author

Great, thanks @yakutovicha!

@danielhollas danielhollas mentioned this pull request Sep 6, 2023
26 tasks
danielhollas added a commit that referenced this pull request Sep 6, 2023
* Add a test for localhost setup
* Raise if transport type is not recognized
* Validate more inputs and catch more errors.

Co-authored-by: Aliaksandr Yakutovich <[email protected]>
unkcpz pushed a commit to unkcpz/aiidalab-widgets-base that referenced this pull request Nov 16, 2023
This PR adds an entry point for step 1, allowing the user to add a new structure importer and editor. In principle, all the structure importer and editor are pluggable. This PR generalizes this by adding entry point to it.
This will be very useful:
- add structure importer specific for particular structures, e.g. surface, adsorbate.
- add a new editor to edit a structure for the plugin, e.g. edit tags, and cut surface.
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.

Cannot setup localhost computer
2 participants