-
-
Notifications
You must be signed in to change notification settings - Fork 152
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
🐛 Bug: Bentoml and Python3.12 compatibility #1379
Comments
@Abellegese I remember the stack trace having more to it - ie specifically, I am asking for the part of the trace where this bug originates from ersilia's copy of bentoml. If possible could you attach that to the issue as well? |
Okay @DhanshreeA will update it. |
Hi @DhanshreeA and @Abellegese Can you update this issue? And set a deadline for completion |
I am unable to reproduce the exact error that @Abellegese has reported here, however, I do notice an issue with Python 3.12 and fetching from github, however I do experience a similar error (ie in that it is coming from Traceback (most recent call last):
File "/home/dee/.pyenv/versions/ersilia-312/bin/bentoml", line 5, in <module>
from bentoml.cli import cli
File "/home/dee/.pyenv/versions/3.12.5/envs/ersilia-312/lib/python3.12/site-packages/bentoml/__init__.py", line 27, in <module>
from bentoml.saved_bundle import load_from_dir, save_to_dir # noqa: E402
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/home/dee/.pyenv/versions/3.12.5/envs/ersilia-312/lib/python3.12/site-packages/bentoml/saved_bundle/__init__.py", line 15, in <module>
from bentoml.saved_bundle.bundler import save_to_dir
File "/home/dee/.pyenv/versions/3.12.5/envs/ersilia-312/lib/python3.12/site-packages/bentoml/saved_bundle/bundler.py", line 31, in <module>
from bentoml.saved_bundle.local_py_modules import (
File "/home/dee/.pyenv/versions/3.12.5/envs/ersilia-312/lib/python3.12/site-packages/bentoml/saved_bundle/local_py_modules.py", line 27, in <module>
from bentoml.saved_bundle.pip_pkg import get_all_pip_installed_modules
File "/home/dee/.pyenv/versions/3.12.5/envs/ersilia-312/lib/python3.12/site-packages/bentoml/saved_bundle/pip_pkg.py", line 23, in <module>
from pkg_resources import Requirement
ModuleNotFoundError: No module named 'pkg_resources' Edit: This was in a fresh ersilia environment created using Python 3.12, and then running: |
Okay, I believe we have run into this before. However, this only fixed ersilia code using the |
Downgrading the priority here for two reasons:
|
Another update: We will continue to use our BentoML fork for packaging models, however, we will utilise Ersilia Pack for as many old models, and all new models. This is necessary because Ersilia Pack utilises FastAPI which only supports Python 3.8 and above. We will refactor most models to use an upgraded Python version especially if they use Python 3.7 or below. However, for those models that cannot be upgraded, and are still important for us to keep in the hub, we will continue to utilise BentoML. This scenario merits adding to the code, a conditional check here that checks if the user is running ersilia in a Python 3.12 (or above) environment - in this case, if the user is fetching a model from source, ie GitHub, local path, or S3, we will force packing this model using Ersilia Pack. There's a caveat to the above strategy, that is, if the model dependency has a version less than 3.8, then we just simply raise an error to the user that Ersilia should be run in an environment less than 3.12, and exit. |
@OlawumiSalaam is this something that interests you? |
@DhanshreeA |
Here are the steps I followed to reproduce the bug
|
Hi @OlawumiSalaam both of the logs shows that the fetching was skipped because the model |
@Abellegese . Thank you for pointing that out. I have deleted and fetched again. Here is the output |
Okay thanks @OlawumiSalaam you are right. I think "Do not pre-install setuptools in virtual environments created with venv. This means that distutils, setuptools, pkg_resources, and easy_install will no longer available by default; to access these run pip install setuptools in the activated virtual environment." |
Bug: The issue stems from
Suggestions:
|
@OlawumiSalaam both good points. Let's do this, add a check for the python version in the code, and try to import setuptools, if there's an import error, install setuptools (while also logging this on the CLI). And you can also document this in the README in your PR. |
@DhanshreeA I am a bit confused and need guide. |
Having a class would be an overkill, I was referring to the rdkit implementation as a workflow to look at while doing this - in that it first tries to import the module to check if it is present, and if not, uses the ersilia utility We don't need to have a full blown class, we can simply do it within the code that you have referenced. I think it's safe to do it within the fetch at the beginning (regardless of whether it's bentoml, or fastapi), just to be safe. |
Okay, so good work @OlawumiSalaam I have tested the changes in this PR for eos3b5e in a Python 3.12 environment (regular venv, not conda). I propose you test more models mainly the ones listed here and share updates here so we can close this issue for good. Thanks, and good work! |
@DhanshreeA I have tried fetching models but not successful. I don,t know what I am doing wrong. Here is the output please can you take a look |
@OlawumiSalaam Looking at these logs, I believe the cause for this error is that somehow the model packages are not getting installed in the isolated conda environment that gets created during the fetch procedure and are instead somehow being installed in ersilia's virtual environment. For example, for eos3b5e the rdkit version very well exists for Python 3.10, which is the base Python for the model, however here pip complains:
It is trying to find an rdkit version for Python 3.12 (which is the python in Ersilia's environment.) I am not sure why this is happening in your system, it's probably a path corruption somehow. In that, when the model install commands are running on your system, the pip package ends up corresponding to pip from your ersilia environment and not the model environment for some reason. I believe a similar thing is happening for eos4e40 as well. You could try examining your system path to begin with. In any case, I can take over testing these models. |
Tracking models here:
|
It looks like the setuptools issue is resolved through the linked PR, and wherever models failed to fetch is because of other reasons. We can safely close this issue. |
Describe the bug.
Recently got this error when fetching
eos3b5e
from a github onpython 3.12
conda env and got this error:Describe the steps to reproduce the behavior
ersilia -v fetch eos3b5e --from_github
.Operating environment
Ubuntu
The text was updated successfully, but these errors were encountered: