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

Implement path for in-app guides #763

Merged
merged 6 commits into from
Dec 18, 2024
Merged

Implement path for in-app guides #763

merged 6 commits into from
Dec 18, 2024

Conversation

edan-bainglass
Copy link
Member

@edan-bainglass edan-bainglass commented Jul 3, 2024

Based on #967

This PR adds a mechanism for adding in-app guides meant as example use-cases for users. The mechanism leverages a global instance of the GuideManager, which tracks the current selected guide in an active_guide traitlet, which is observed by all InAppGuide instances. Instances are placed throughout the app with unique identifiers. Additional placeholders may be added by plugin developers within their defined panels.

Usage

In-app guide widgets can be added anywhere as follows:

from aiidalab_qe.common.infobox import InAppGuide

example = InAppGuide(
    children=[
        ipw.HTML("An example in-app guide."),
    ],
    guide_id="general/basic",
)

This defines the guide explicitly, providing hard-coded content, which is useful for generic guide sections that are useful for any guide. Children can be any widget supported by ipywidgets. This allows developers to customize the content of the guide as they wish. The guide_id refers to the associated guide and is used to toggle the guide section on/off.

However, for specific guide content, a more flexible approach is

from aiidalab_qe.common.infobox import InAppGuide

example = InAppGuide(identifier="structure-step")

Here, the guide is defined from content fetched by an HTML id attribute from the currently loaded guide (HTML document) in the guide manager corresponding to the active (selected) guide. The HTML document is parsed using beautiful soup.

In either case, CSS classes can be provided to the InAppGuide constructor to override the behavior of the info-box and in-app-guide CSS classes.

example = InAppGuide(
    identifier="structure-step",
    classes=["custom1", "custom2", etc.],
)

This allows developers to control top-level styles for the guide. Styles internal to the guide are more easily controlled directly in the guide HTML documents.

External guides

The app defines internal guides in src/aiidalab_qe/guides. External guides may be added by plugin developers using the same entry point system already used in plugins. Developers simply add a guides key to their plugin definition with a value pointing at the path of their guides directory. The guide manager will pick these up on app start and add them to the list of available guides.

Comments regarding external guides

Entry point

We may consider enforcing a structure here, specifying that external guides must be provided at the root level of the plugin.

  • Pro: developers don't need to bother with adding the new guides key
  • Con: rigid placement and slightly more complex approach to finding the guides directory (easy if there is a simple means of obtaining the path of the plugin directory)

update

Current decision (discussed with @superstar54) is to require the guides key in the entry point.

Uniqueness

In the current implementation, there is a risk an external guide developer names a guide identically to an existing internal/external guide. To avoid this, the plugin identifier can be used as a prefix when storing guides in the manager. In the app, we could consider displaying guides by category. There are various means of achieving this cleanly. Open to discussion.

update

Current approach is to indeed use the plugin identifier as a prefix. This results in the following:
image

Copy link

codecov bot commented Jul 3, 2024

Codecov Report

Attention: Patch coverage is 87.37864% with 13 lines in your changes missing coverage. Please review.

Project coverage is 68.55%. Comparing base (5949bdf) to head (dfa9884).
Report is 1 commits behind head on main.

Files with missing lines Patch % Lines
src/aiidalab_qe/app/wrapper.py 69.23% 8 Missing ⚠️
src/aiidalab_qe/common/guide_manager.py 90.24% 4 Missing ⚠️
src/aiidalab_qe/common/infobox.py 96.15% 1 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main     #763      +/-   ##
==========================================
+ Coverage   68.26%   68.55%   +0.29%     
==========================================
  Files         110      111       +1     
  Lines        6211     6307      +96     
==========================================
+ Hits         4240     4324      +84     
- Misses       1971     1983      +12     
Flag Coverage Δ
python-3.11 68.54% <87.37%> (+0.27%) ⬆️
python-3.9 68.58% <87.37%> (+0.29%) ⬆️

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

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

@mikibonacci mikibonacci self-requested a review July 4, 2024 13:02
@edan-bainglass edan-bainglass force-pushed the in-app-guides branch 4 times, most recently from 8d5dd19 to 722184f Compare July 9, 2024 06:32
@edan-bainglass edan-bainglass marked this pull request as draft July 9, 2024 08:50
@edan-bainglass edan-bainglass marked this pull request as ready for review August 21, 2024 10:30
@superstar54
Copy link
Member

Hi @edan-bainglass , is this PR ready for review? I like the design, and I am looking forward to having it in the APP.

@edan-bainglass
Copy link
Member Author

@superstar54 it is :) The failed tests are due to a chain of yet-to-be-merged PRs all the way back to aiidalab/aiidalab-widgets-base#624, which @danielhollas is reviewing.

@superstar54
Copy link
Member

When reviewing this PR, do I need to switch aiidalab/aiidalab-widgets-base#624?.

@edan-bainglass
Copy link
Member Author

If you're testing locally, then yes.

@edan-bainglass edan-bainglass force-pushed the in-app-guides branch 6 times, most recently from 77926ab to 8d5e19f Compare September 2, 2024 12:21
@edan-bainglass edan-bainglass marked this pull request as draft September 2, 2024 13:41
@edan-bainglass edan-bainglass marked this pull request as ready for review September 2, 2024 15:45
@edan-bainglass edan-bainglass marked this pull request as ready for review December 10, 2024 06:30
Copy link
Member

@superstar54 superstar54 left a comment

Choose a reason for hiding this comment

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

Very nice in-app guide! The style is also pretty. I added a few suggestions in the comments.

Could you also add a guide for step 4.

<div class="alert alert-success">
<h4>Tasks</h4>
<ol>
<li>Select resources</li>
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
<li>Select resources</li>
<li>Select resources in the Global resources tab</li>

<div class="alert alert-success">
<h4>Tasks</h4>
<ol>
<li>Select <b>Full geometry</b> relaxation</li>
Copy link
Member

Choose a reason for hiding this comment

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

Since "Full geometry" is the default, consider select "Atomic positions"

<div id="pdos-settings">
Here we configure the settings for computing the projected density of states,
or PDOS.
<div class="alert alert-success">???</div>
Copy link
Member

Choose a reason for hiding this comment

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

Similar to the advacned settings,

Suggested change
<div class="alert alert-success">???</div>
<div class="alert alert-success">In this walkthrough, we will not modify the pdos settings and proceed with the defaults.</div>

<div class="alert alert-success">
<h4>Tasks</h4>
<ol>
<li>Select resources</li>
Copy link
Member

Choose a reason for hiding this comment

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

Maybe also add a description of the calculation before submitting.

@edan-bainglass
Copy link
Member Author

Very nice in-app guide! The style is also pretty. I added a few suggestions in the comments.

Could you also add a guide for step 4.

Thanks @superstar54. Note that I will make no comments regarding the actual content of the guides, as the current content is only a draft to give @giovannipizzi and @cpignedoli a sense of how it works. I will work with them in an immediately following PR to iron out the actual content, at which point, we will also cover step 4 🙂

Since all your comments above ARE regarding content, I take it you approve of the mechanism itself. Per our discussion, I will update the PR to handle uniqueness as suggested in the PR description.

@danielhollas
Copy link
Contributor

Per our discussion, I will update the PR to handle uniqueness as suggested in the PR description.

LMK when you're done with that and I can have a final look (but feel free to merge anytime / don't feel block by me)

@edan-bainglass
Copy link
Member Author

@danielhollas ready to review. I implemented guide uniqueness in the last commit. Also in that commit is a mechanism for ensuring intended guide order by inspecting the HTML file name, which is now required to include a #_ prefix to indicate the intended order, which I parse. I did this sort of quick, so if you think of a better approach, do share 🙂

@edan-bainglass
Copy link
Member Author

@superstar54 I added placeholders in step 4 and after the wizard. Again, the text is not important, nor is the placement of the guide widgets. We will update these with one final PR once @cpignedoli and @giovannipizzi agree on the text. No changes in this last commit regarding the mechanism, so if you already agree with it, let me know and we merge 🙏

Copy link
Member

@superstar54 superstar54 left a comment

Choose a reason for hiding this comment

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

The structure looks good to me! Please ask others for the texts.

@edan-bainglass
Copy link
Member Author

The structure looks good to me! Please ask others for the texts.

Good. I'm not sure while the docker image is failing though. Can you have a look? 🙏🙏🙏

@edan-bainglass
Copy link
Member Author

@danielhollas this and several other PRs are failing at building the docker image. Could you please have a look? 🙏

@danielhollas
Copy link
Contributor

@edan-bainglass appologies, I will not have time, I am leaving for holidays tomorrow and will be mostly off-line this and next week.

@edan-bainglass
Copy link
Member Author

@edan-bainglass appologies, I will not have time, I am leaving for holidays tomorrow and will be mostly off-line this and next week.

Okay. No worries. Enjoy the holidays 🙂

@edan-bainglass edan-bainglass force-pushed the in-app-guides branch 2 times, most recently from e8f8764 to 811e537 Compare December 17, 2024 15:51
@edan-bainglass edan-bainglass merged commit 64f5e6a into main Dec 18, 2024
11 of 12 checks passed
@edan-bainglass edan-bainglass deleted the in-app-guides branch December 18, 2024 05:23
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.

3 participants