-
Notifications
You must be signed in to change notification settings - Fork 836
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
Merge Conda and regular Python s2i wrappers #1125
Comments
Just an observation: |
miniconda3 now comes with Python 3.7 We could always create Python 3.6 env there but this would just add another layer to base image and unnecessarily increase its size. Do we still need to support Python 3.6 image? |
It would be 214 MB difference in image size:
The 3.6 is made using following Dockerfile
And seems to give fully functional Python 3.6 base. |
You raise a good point about being forced to use Conda's distribution if we switch to the I assume this would only be possible if we installed Miniconda on top of our Python image? That sounds like a potential rabbit hole... What are your thoughts on this @RafalSkolasinski? |
Interesting - We do still need to support python 3.6 / 3.7 as users would also be on those, same with data science libraries. Why don't we just explicitly remove the 3.7 environment from Conda on the docker file once 3.6 is installed? |
That won't work as the 3.7 will still be present due to how Docker handle
layers.
|
Related to this change, in the s2i python run script, executive seldon-core-microservice uses base conda env regardless of activated conda env (it is using /opt/conda/bin/python in shebang directive). So installed packages in CONDA_ENV_NAME will not be used once the service is running resulting in import errors. |
I am pretty sure this is working as expected. The ❯❯❯ which python
/home/rskolasinski/miniconda3/envs/seldon-core/bin/python
❯❯❯ cat (which seldon-core-microservice)
#!/home/rskolasinski/miniconda3/envs/seldon-core/bin/python3.8
# EASY-INSTALL-ENTRY-SCRIPT: 'seldon-core','console_scripts','seldon-core-microservice'
import re
import sys
# for compatibility with easy_install; see #2198
__requires__ = 'seldon-core'
try:
from importlib.metadata import distribution
except ImportError:
try:
from importlib_metadata import distribution
except ImportError:
from pkg_resources import load_entry_point
def importlib_load_entry_point(spec, group, name):
dist_name, _, _ = spec.partition('==')
matches = (
entry_point
for entry_point in distribution(dist_name).entry_points
if entry_point.group == group and entry_point.name == name
)
return next(matches).load()
globals().setdefault('load_entry_point', importlib_load_entry_point)
if __name__ == '__main__':
sys.argv[0] = re.sub(r'(-script\.pyw?|\.exe)?$', '', sys.argv[0])
sys.exit(load_entry_point('seldon-core', 'console_scripts', 'seldon-core-microservice')()) |
@aghagol Do you have the example that fails and does not work properly? |
Thanks @RafalSkolasinski for getting back quickly. That is interesting to know. I was looking at the prebuilt seldon-core image |
Ah sorry I forgot that I need to activate the conda env first. Will try that next. |
When I run the docker image, this is what I get: ~/devops/dai/dai-harmony/seldon-deployment managed_sql ❯ docker run -it --rm -p 5000:5000 pilot-adl-test:tip 2m 57s
Activating Conda environment 'microservice'
starting microservice
2020-08-14 13:57:21,082 - seldon_core.microservice:main:207 - INFO: Starting microservice.py:main
2020-08-14 13:57:21,082 - seldon_core.microservice:main:208 - INFO: Seldon Core version: 1.2.2
2020-08-14 13:57:21,084 - seldon_core.microservice:main:310 - INFO: Parse JAEGER_EXTRA_TAGS []
2020-08-14 13:57:21,084 - seldon_core.microservice:main:313 - INFO: Annotations: {}
2020-08-14 13:57:21,084 - seldon_core.microservice:main:317 - INFO: Importing XGB
Traceback (most recent call last):
File "/opt/conda/bin/seldon-core-microservice", line 11, in <module>
load_entry_point('seldon-core', 'console_scripts', 'seldon-core-microservice')()
File "/microservice/python/seldon_core/microservice.py", line 318, in main
interface_file = importlib.import_module(args.interface_name)
File "/opt/conda/lib/python3.7/importlib/__init__.py", line 127, in import_module
return _bootstrap._gcd_import(name[level:], package, level)
File "<frozen importlib._bootstrap>", line 1006, in _gcd_import
File "<frozen importlib._bootstrap>", line 983, in _find_and_load
File "<frozen importlib._bootstrap>", line 967, in _find_and_load_unlocked
File "<frozen importlib._bootstrap>", line 677, in _load_unlocked
File "<frozen importlib._bootstrap_external>", line 728, in exec_module
File "<frozen importlib._bootstrap>", line 219, in _call_with_frames_removed
File "/microservice/XGB.py", line 5, in <module>
import xgboost as xgb
ModuleNotFoundError: No module named 'xgboost' Even though it says it is activating env I looked inside the container. When I manually activate the ~/devops/dai/dai-harmony/seldon-deployment managed_sql ❯ docker run -it --rm --entrypoint bash pilot-adl-test:tip 3s
(base) root@b4520c7ac6ba:/microservice# conda env list
# conda environments:
#
base * /opt/conda
microservice /opt/conda/envs/microservice
(base) root@b4520c7ac6ba:/microservice# conda activate microservice
(microservice) root@b4520c7ac6ba:/microservice# python
Python 3.8.5 (default, Aug 5 2020, 08:36:46)
[GCC 7.3.0] :: Anaconda, Inc. on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import xgboost
>>>
(microservice) root@b4520c7ac6ba:/microservice# which seldon-core-microservice
/opt/conda/bin/seldon-core-microservice
(microservice) root@b4520c7ac6ba:/microservice# |
Figured it out. The problem is that I wasn't including |
Context
To include support for custom Conda environments on #1108, we added a new
seldonio/seldon-core-s2i-conda
s2i wrapper. However, it could be a good idea to merge it with the existingseldonio/seldon-core-s2i-python
. This makes sense if we consider that adding Conda is just extending the feature set of the Python wrapper. It could also help with maintainability of the s2i wrappers.Before agreeing to this change, one of the caveats that we need to consider is that the new
seldonio/seldon-core-s2i-conda
wrapper usescontinuum/miniconda3
as a Docker base image. This image is based ondebian:buster-slim
, which is a smaller version ofdebian:buster
and which could break some uses of the existingseldonio/seldon-core-s2i-python
.The text was updated successfully, but these errors were encountered: