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

Add info box widgets with CSS stylesheets #623

Closed
wants to merge 10 commits into from

Conversation

edan-bainglass
Copy link
Member

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

Based on #624

This PR adds info box widgets to provide in-app information to users

@edan-bainglass edan-bainglass marked this pull request as draft July 9, 2024 08:49
Copy link

codecov bot commented Jul 11, 2024

Codecov Report

Attention: Patch coverage is 79.01235% with 17 lines in your changes missing coverage. Please review.

Project coverage is 83.64%. Comparing base (de5f0cc) to head (93d2986).
Report is 2 commits behind head on master.

Files with missing lines Patch % Lines
aiidalab_widgets_base/__init__.py 14.28% 12 Missing ⚠️
aiidalab_widgets_base/utils/loaders.py 73.33% 4 Missing ⚠️
aiidalab_widgets_base/infobox.py 98.07% 1 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##           master     #623      +/-   ##
==========================================
+ Coverage   83.61%   83.64%   +0.02%     
==========================================
  Files          16       18       +2     
  Lines        3522     3595      +73     
==========================================
+ Hits         2945     3007      +62     
- Misses        577      588      +11     
Flag Coverage Δ
python-3.11 83.64% <79.01%> (+0.02%) ⬆️
python-3.9 83.68% <79.01%> (+0.02%) ⬆️

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.

@edan-bainglass
Copy link
Member Author

@superstar54 @unkcpz can you guys have a look at the failed tests? I don't see how my changes could suddenly trigger the following error, which is failing several structure-related tests!

DeprecationWarning: dict interface (SpglibDataset['international']) is deprecated.Use attribute interface ({self.__class__.__name__}.{key}) instead

@superstar54
Copy link
Member

Hi @edan-bainglass , spglib released a new version yesterday. Apparently, it drops support for some old API.

@superstar54
Copy link
Member

I just created an issue on this: #625

@edan-bainglass
Copy link
Member Author

edan-bainglass commented Jul 12, 2024

@superstar54 I see. So we need to update on our end? I take it this is unrelated to my PR. I would rebase on top of an update PR once that's in?

Regarding an spglib update PR, do we need it? Can we instead pin to <2.5.0?

@superstar54
Copy link
Member

Regarding an spglib update PR, do we need it? Can we instead pin to <2.5.0?

No idea yet.

@danielhollas
Copy link
Contributor

You can just add the DeprecationWarning to the list of ignored warnings in pyproject.toml

(We have configured pytest so that it turns any warnings into errors, maybe we should change it)

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.

Hi @edan-bainglass , thanks for the nice work.

Comment on lines 9 to 11
def __init__(self, **kwargs):
"""`InfoBox` constructor."""
custom_css = kwargs.pop("custom-css", "")
Copy link
Member

Choose a reason for hiding this comment

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

I would add the custom-css explicitly, so the user knows it quickly.

Suggested change
def __init__(self, **kwargs):
"""`InfoBox` constructor."""
custom_css = kwargs.pop("custom-css", "")
def __init__(self, custom-css=None, **kwargs):
"""`InfoBox` constructor."""

Copy link
Member Author

Choose a reason for hiding this comment

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

I actually had it like that initially but changed it for what I vaguely recall was a good reason. If I can't remember it in a day or so, I'll revert to this.

Copy link
Contributor

@danielhollas danielhollas Aug 21, 2024

Choose a reason for hiding this comment

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

Btw: I think the parameter should be called custom_class. ;-)

Copy link
Member Author

Choose a reason for hiding this comment

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

I redesigned this part a bit. I think it is clearer. Let me know.

Comment on lines +100 to +110
def _write_existing_user_token_to_file(self):
"""Write a token to file marking the user as an existing user."""
with open(".app-user-config", "w") as file:
file.write("existing-user")
Copy link
Member

Choose a reason for hiding this comment

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

What if I have two FirstTimeUserMessage in my app? They will share the same config file; thus, there is a risk that they are in conflict.

Copy link
Member Author

Choose a reason for hiding this comment

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

I agree. This isn't a great approach. Username would be better, or some other uniquely identifying property. This was just a proof of concept. I was hoping someone with more knowledge of AiiDAlab could provide a better solution :)

Copy link
Contributor

Choose a reason for hiding this comment

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

Should this even be a backend logic? For example, our aiidalab deployment is currently shared in the group, so you can't really identify new user this way.

Probably more canonical solution is to store a cookie in user's browser.

Copy link
Member Author

Choose a reason for hiding this comment

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

I really don't like how I've implemented it. Just needed a proof of concept. Open to suggestions. A cookie to the user's browser may be a good approach.

Copy link
Member Author

Choose a reason for hiding this comment

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

@giovannipizzi suggested we keep this as a local config file and had some ideas for its structure. I'll let him explain it.

@edan-bainglass
Copy link
Member Author

Moving this PR to the QE App for local testing. If all is good and approved for general use, InfoBox classes will move back to the widgets base.

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