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

Defer some third-party imports for quicker high-level imports #1085

Merged
merged 5 commits into from
Nov 14, 2024

Conversation

mattwthompson
Copy link
Member

Description

Resolves #239, for now?

I mean, we could defer loading openff.toolkit.ForceField but that seems obtuse

Checklist

  • Add tests
  • Lint
  • Update docstrings

@mattwthompson
Copy link
Member Author

image

Copy link

codecov bot commented Oct 29, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 93.62%. Comparing base (48a65a6) to head (836583c).
Report is 13 commits behind head on main.

Additional details and impacted files

@mattwthompson mattwthompson marked this pull request as ready for review October 29, 2024 21:17
Copy link
Collaborator

@Yoshanuikabundi Yoshanuikabundi left a comment

Choose a reason for hiding this comment

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

I mean, we could defer loading openff.toolkit.ForceField but that seems obtuse

A little, but my inclination would be to do it:

  • it's almost all of the remaining import time according to your graphic (if it ends up being imported anyway I wouldn't bother)
  • there are some workflows in important growth areas that I don't believe need ForceField:
    • workflows importing from OpenMM or Foyer and not using any SMIRNOFF force field
    • workflows loading a previously created Interchange directly from disk (this may be important for determinism)
  • the API points that need it all take it as an argument and call methods on it, so it's going to be imported by the user in most cases, which means complaints about import times will probably go to the right place

Other than that, this LGTM! I have a suggestion about indicating type aliases more explicitly that may or may not make the type checker happier but it's entirely optional.

openff/interchange/components/potentials.py Outdated Show resolved Hide resolved
openff/interchange/components/potentials.py Outdated Show resolved Hide resolved
openff/interchange/components/potentials.py Outdated Show resolved Hide resolved
Co-authored-by: Josh A. Mitchell <[email protected]>
@mattwthompson
Copy link
Member Author

my inclination would be to do it

Good points, I'm convinced

Unfortunately, most of the time is spent importing the toolkit's wrapper machinery (I'd rather RDKit and OEChem not be needed until they are - separate push for a separate time)

image

@mattwthompson mattwthompson merged commit 4703c6a into main Nov 14, 2024
22 checks passed
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.

Cleanup: Slow import times
2 participants