mlem icon indicating copy to clipboard operation
mlem copied to clipboard

Add config option to add alternative python packages

Open mike0sv opened this issue 2 years ago • 3 comments

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

mike0sv avatar Jul 25 '22 15:07 mike0sv

Would this approach require the user to manually specify the mapping?

alex000kim avatar Jul 27 '22 00:07 alex000kim

Yes, there is no way to know package name after it was installed

mike0sv avatar Jul 27 '22 05:07 mike0sv

@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']

aguschin avatar Jul 27 '22 05:07 aguschin

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]:

aguschin avatar Dec 08 '22 14:12 aguschin

there are some complicated cases, but IMO it's low priority now https://github.com/iterative/mlem/issues/524

aguschin avatar Dec 12 '22 12:12 aguschin