mlem
mlem copied to clipboard
Add config option to add alternative python packages
Sometimes python package name is not the same as it's module name (eg sklearn
vs scikit-learn
). For that we have MODULE_PACKAGE_MAPPING
in mlem.core.requirements
that you can update from code. But it would be nice to be able to do it from config like
config.yaml
core:
package_mapping:
box: python-box
Would this approach require the user to manually specify the mapping?
Yes, there is no way to know package name after it was installed
@mike0sv, have you seen this approach? I've tried it and it seems to work
>>> from importlib_metadata import packages_distributions
>>> packages_distributions()['box']
['python-box']
Got to this again, while trying to use pip install chatgptpy --upgrade
, which is imported like from pychatgpt import Chat
. We need to fix this 🔧
UPD: confirmed the method above works:
(mlem) get-started (main) $ ipython 1m48s
Python 3.9.5 (default, May 26 2021, 19:33:21)
Type 'copyright', 'credits' or 'license' for more information
IPython 8.7.0 -- An enhanced Interactive Python. Type '?' for help.
In [1]: from importlib_metadata import packages_distributions
In [2]: packages_distributions()['pychatgpt']
Out[2]: ['chatgptpy']
In [3]:
there are some complicated cases, but IMO it's low priority now https://github.com/iterative/mlem/issues/524