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

RecursionError: maximum recursion depth exceeded while getting the repr of an object #260

Open
ivnsch opened this issue Dec 1, 2024 · 9 comments

Comments

@ivnsch
Copy link

ivnsch commented Dec 1, 2024

Hi, I just installed meeko from conda-forge and am following the basic docking for vina tutorial https://meeko.readthedocs.io/en/release/tutorial1.html#for-autodock-vina

pdb_file="Meeko/example/tutorial1/input_files/1iep_protein.pdb"
mk_prepare_receptor.py --read_pdb $pdb_file -o rec_1iep -p

and I get

  File "<path>/miniconda3/envs/vina/bin/mk_prepare_receptor.py", line 7, in <module>
    from meeko.cli.mk_prepare_receptor import main
  File "<path>/miniconda3/envs/vina/lib/python3.11/site-packages/meeko/__init__.py", line 10, in <module>
# ... 
RecursionError: maximum recursion depth exceeded while getting the repr of an object

What's wrong? thanks!

@rwxayheee
Copy link
Contributor

Can confirm this problem may be a result of circular import. When installed via conda, the generated script is

#!/bin/sh
'''exec' /opt/homebrew/anaconda3/envs/meeko_tutorial/bin/python "$0" "$@"
' '''
# -*- coding: utf-8 -*-
import re
import sys
from meeko.cli.mk_prepare_receptor import main
if __name__ == '__main__':
    sys.argv[0] = re.sub(r'(-script\.pyw|\.exe)?$', '', sys.argv[0])
    sys.exit(main())

This problem is not observed with some other package managers like micromamba. As a walkaround for the time being, you could install meeko via pip or micromamba.

We should fix this; we might want to rename the console scripts, or devert the entry points.

@rwxayheee
Copy link
Contributor

rwxayheee commented Dec 1, 2024

Hi @ivnsch
Thanks again for reporting this. I opened a PR (#261) but need to talk to other lab members about it. We will need to upload the updated package and it might take a little longer. While we're working on this, there are a few walkaround options:

@diogomart
Copy link
Contributor

I can't reproduce on linux. @rwxayheee did you observe the recursion error?

@rwxayheee
Copy link
Contributor

Hi @diogomart! Yes, I can reproduce this when installed via conda on Mac.

@diogomart
Copy link
Contributor

Do you know where the circular import happens?

@rwxayheee
Copy link
Contributor

rwxayheee commented Dec 2, 2024 via email

@diogomart
Copy link
Contributor

I can't reproduce on a Mac either. From the code I don't see a path for recursion. We should meet and figure out where it is happening, I'm afraid it might be something weird like a conflicting installation of an older meeko where we missed an if __name__ == "__main__" guard.

@rwxayheee
Copy link
Contributor

rwxayheee commented Dec 2, 2024 via email

@rwxayheee
Copy link
Contributor

rwxayheee commented Dec 3, 2024

Hello @ivnsch

I am reaching out to ask for your assistance in reproducing this issue. When I wrote the first reply to you, I could reproduce this but now I couldn't reproduce the exact issue. I'm afraid that #261 may be unnecessary and is not the right way to address this issue. Could you please let us know, if a startover from a new environment solve the issue?

When updating or reinstalling a package, some old files might not be removed (renamed) properly, causing unexpected behaviors. I have encountered, and could still produce some other importlib-related issues if I attempted to downgrade or upgrade Meeko with conda in the same environment. I think the reason is that the entry point is not properly updated, while the package body is changing with the version.

If this is the case, start over with a new environment and reinstall the required packages should always work. **If so, I will close #261 as unnecessary. ** Before, I was thinking that the problem was literally circular import but now I think it's not.

If this is a persistent issue even with a new install in a new environment, could you please provide:

  • Configuration of current environment
    Could you please share with us the output file of pip freeze > requirements.txt?

  • Content of the generated script "/miniconda3/envs/vina/bin/mk_prepare_receptor.py"

  • Did you possibly install meeko (more than one times) with multiple package managers?
    I encountered some other importlib-related issues when I have attemped to install multiple Meeko in the same environment. See below for how I found out about it. You can use similar commands to check:

(meeko_tutorial_py39) amyhe@Amys-MBP Meeko % conda list meeko
# packages in environment at /Users/amyhe/miniconda3/envs/meeko_tutorial_py39:
#
# Name                    Version                   Build  Channel
meeko                     0.5.1                     dev_0    <develop>
(meeko_tutorial_py39) amyhe@Amys-MBP Meeko % micromamba list | grep meeko
List of packages in environment: "/Users/amyhe/miniconda3/envs/meeko_tutorial_py39"
  meeko                      0.6.0        pyhd8ed1ab_1          conda-forge
(meeko_tutorial_py39) amyhe@Amys-MBP Meeko % pip list | grep meeko
meeko               0.6.0
(meeko_tutorial_py39) amyhe@Amys-MBP Meeko % 

Either way, start over would be the best way to resolve the issue. Please let us know how it goes, and we're more than willing to help ^^

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

When branches are created from issues, their pull requests are automatically linked.

3 participants