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

Delayed import of scikit-learn and pandas + other dependency tweaks #412

Merged
merged 30 commits into from
Dec 14, 2022

Conversation

danielhollas
Copy link
Contributor

@danielhollas danielhollas commented Dec 9, 2022

Various tweaks to dependencies:

  1. Delayed import of scikit-learn and bokeh.
    Both of these are very large packages that may negatively impact startup time, so it makes sense to import them only when necessary. It would be great to get rid of them altogether. We use pandas only to generate HTML tables from python dictionaries. Perhaps there is a more lightweight solution for that. Sklearn is only used to do PCA in SmilesWidget, I'll try to remove it in another PR.

  2. Declare rdkit and sklearn as optional dependencies for SmilesWidget.

  3. Add basic test for SmilesWidget

  4. Updated test dependencies and moved them from setup.cfg to requirements_test.txt, same way as in QeApp. The pip installation on GHA went from 1 minute to 5 seconds so this is worthwhile.

  5. Removed stale requirements.json file. I am assuming it is not needed given the setup.cfg but correct me if I am wrong.

I added this to the milestone, since we're removing sklearn as a direct dependency, which might potentially break apps that relied on it. Note that SmilesWidget was already broken in principle, since rdkit is not installed in the new docker stack. At least now apps can reliably install needed dependencies by specifying aiidalab-widgets-base[smiles].

@danielhollas danielhollas requested review from yakutovicha and unkcpz and removed request for unkcpz and yakutovicha December 9, 2022 00:46
@danielhollas danielhollas marked this pull request as draft December 9, 2022 01:04
@danielhollas
Copy link
Contributor Author

Tests are failing, not sure why. Will enable screenshots first in #411 to debug this.

@unkcpz
Copy link
Member

unkcpz commented Dec 9, 2022

To reproduce the failing test, you can launch a docker container and run the failed notebook with the branch.

@danielhollas danielhollas changed the title Delayed import of scikit-learn and pandas Delayed import of scikit-learn and pandas + other dependency tweaks Dec 10, 2022
@danielhollas danielhollas marked this pull request as ready for review December 10, 2022 00:25
@unkcpz
Copy link
Member

unkcpz commented Dec 10, 2022

Hi @danielhollas, just request review again when you think this is ready.

@danielhollas danielhollas added this to the v2.0.0-final milestone Dec 11, 2022
@danielhollas
Copy link
Contributor Author

danielhollas commented Dec 11, 2022

@unkcpz I need to fix one of the XPath selector to fix the new test, but otherwise this is good to review.

EDIT: Tests are passing

setup.cfg Outdated
spglib~=1.14
vapory~=0.1.2
python_requires = >=3.8
include_package_data = True
zip_safe = False

[options.extras_require]
smiles =
Copy link
Member

Choose a reason for hiding this comment

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

I am not sure about this, if you want "smiles" related packages installed by aiidalab install, it not supports install from extras dependencies yet.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

That's okay I think, because I can declare the dependency in my setup.cfg with these extras dependencies, so it should pull the package from pip.

Copy link
Member

Choose a reason for hiding this comment

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

Ah, this is clever, but only for packages like aiidalab-widgets-base and when we not treat it as "app" anymore. Anyway, good for the change here.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yes, that is a good point. But @yakutovicha said many times he wants to turn AWB into library anyways, so it should be okay.

setup.cfg Outdated Show resolved Hide resolved
unkcpz
unkcpz previously approved these changes Dec 11, 2022
@unkcpz
Copy link
Member

unkcpz commented Dec 11, 2022

@danielhollas I think you have permission to merge, correct? I'll leave it to you in case you still want to add things. It is all good to me.
This one actually bring the improvement of the performance for some widget, it reminds me that we want to add the benchmark test to the widgets, but we can do in a separate PR.

@danielhollas
Copy link
Contributor Author

I don't have permission to merge actually. This is good to go from my side.

This one actually bring the improvement of the performance for some widget, it reminds me that we want to add the benchmark test to the widgets, but we can do in a separate PR.

Yes, that would be great. I suspect this PR alone does not bring performance improvements much. Pandas is still imported by optimade-client. But I don't know how to measure this well.

@danielhollas
Copy link
Contributor Author

@yakutovicha can you confirm it's okay to delete requirements.txt?

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 am a bit concerned by some changes in this PR. Specifically, I don't see a need of separating dev into dev and testing. All packages will be installed during the CI run anyways. Some while ago we actually did the opposite thing: we merged them together into dev.

.github/workflows/ci.yml Outdated Show resolved Hide resolved
.pre-commit-config.yaml Outdated Show resolved Hide resolved
setup.cfg Outdated Show resolved Hide resolved
@yakutovicha yakutovicha merged commit ac85b7b into master Dec 14, 2022
@yakutovicha yakutovicha deleted the pandas-import branch December 14, 2022 14:04
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