choderalab / espaloma_charge

Standalone charge assignment from Espaloma framework.
MIT License
35 stars 5 forks source link

Cannot `import espaloma_charge` upon fresh installation #34

Closed lgsmith closed 2 months ago

lgsmith commented 2 months ago

I used pip to install espaloma_charge in an environment with the openff-toolkit package installed via conda. The respective install commands run, and appear to pull in sensible packages, but when I start an interpreter session and try to import something from espaloma charge I get the following error:

ImportError: cannot import name 'DILL_AVAILABLE' from 'torch.utils.data.datapipes.utils.common' (path/to/miniconda3/envs/espalomatester/lib/python3.12/site-packages/torch/utils/data/datapipes/utils/common.py)

I've tried doing several different things, but this will minimally reproduce this issue if you have a fresh miniconda3 around:

mamba create -n espalomatester -c conda-forge openff-toolkit
conda activate espalomatester
pip install espaloma_charge
python -m espaloma_charge

One can of course open an interpreter session and try to do things more similar to the example input in the readme, but when I do that I get the same error.

Of particular note, when I check to see if it failed to install dill somehow I get the following, implying that some version of it has been installed:

$ pip install dill
Requirement already satisfied: dill in ./miniconda3/envs/espalomatester/lib/python3.12/site-packages (0.3.8)

I'd really appreciate any direction, or if there's some mistake I've made in trying to install this tool--though I must say I don't know how the error could be on my end, given the minimal nature of the install procedure.

mikemhenry commented 2 months ago

The issue is that pypi package doesn't correctly pin the dependencies. I was able to replicate your issue and solved it by installing the correct dgl version from conda-forge.

mamba create -n espalomatester -c conda-forge openff-toolkit dgl==1.1.2
conda activate espalomatester
pip install espaloma_charge
python -m espaloma_charge

I am working to get espaloma_charge onto conda-forge which will handle this issue automatically.

though I must say I don't know how the error could be on my end, given the minimal nature of the install procedure.

:100: The issue is on our end with the package dependencies, sorry about that!

Let me know if this works for you. Thank you so much for raising this issue, I really appreciate it.

ijpulidos commented 2 months ago

Yes, I agree with @mikemhenry , we probably want to make a new release and update/fix our install instructions. I believe that the release in PyPI is outdated.

@lgsmith as an alternative to install the latest espaloma_charge, you can do the following in a clone of this repository:

mamba env create -f environment.yml -n espaloma-charge-env
mamba activate espaloma-charge-env
python -m pip install .

Thanks for reporting the issue and I hope you find this helpful.

lgsmith commented 2 months ago

Ah dammit. One of the things I specifically asked conda to do was install dgl, but I didn't ask for a specific version. It grabbed me 2.1.0 for whatever reason. Must be some kind of regression between your usage and their version?

I can now import espaloma_charge. Thanks for this touch-up. You might want to put it in your readme somewhere...

Wishing you luck with getting this on conda forge. I feel like pip always turns an environment into a dumpster fire after it gets used...or at least I've had bad luck with it.

lgsmith commented 2 months ago

@ijpulidos I did try this and it also produced an importable package. Why does it restrict the OpenFFTK version to less than 0.15? I assume that must be in the setup.py but is that a known issue or an avoidance of unknown issues?

And to further clarify, are you suggesting that I should do this because there are some known bugfixes that aren't in the PyPI version, so working from the tip of main is better in the near term?

mikemhenry commented 2 months ago

@lgsmith We are just in a bit of a weird spot with this package, I want to get version 0.0.8 onto conda-forge so that people can easily install the version we published on. I agree with @ijpulidos that we should cut a new release, we can update the package to work with the newest version of the openff-toolkit as well as dgl

I can now import espaloma_charge. Thanks for this touch-up. You might want to put it in your readme somewhere...

Doing that right now as a short term fix :)

mikemhenry commented 2 months ago

We now have esplaoma_charge on conda-forge, so installing it that way will pull down the correct dgl version. On osx, depending on python version and cpu arch (m1 or intel) the env may fail to resolve, but this problem will go away once we update to using dgl 2.0

lgsmith commented 2 months ago

Huzzah!

On Mon, Apr 29, 2024 at 7:20 PM Mike Henry @.***> wrote:

We now have esplaoma_charge on conda-forge, so installing it that way will pull down the correct dgl version. On osx, depending on python version and cpu arch (m1 or intel) the env may fail to resolve, but this problem will go away once we update to using dgl 2.0

— Reply to this email directly, view it on GitHub https://github.com/choderalab/espaloma_charge/issues/34#issuecomment-2083846363, or unsubscribe https://github.com/notifications/unsubscribe-auth/ABAZVYLL2F7ZSF26BJN5KCLY73ITDAVCNFSM6AAAAABGXNK2MWVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZDAOBTHA2DMMZWGM . You are receiving this because you were mentioned.Message ID: @.***>