mlem
mlem copied to clipboard
Finding you need to install `google-cloud-storage ` in `from google.cloud import storage`
In some complex cases MLEM can have problems finding what to install. This happens pretty rarely AFAIK, but please upvote and leave a comment if you hit this problem so we can set a priority to investigate and fix.
Example:
$ pip install google-cloud-storage
(see https://cloud.google.com/storage/docs/reference/libraries)
from mlem.api import save
from google.cloud import storage
def f():
storage
save(f, "storage")
print(storage.__name__)
which prints google.cloud.storage
saved metafile:
artifacts:
data.pkl:
hash: 0c3e2cfa007c4e8e25039367c68a29e4
size: 277
uri: storage
model_type:
io:
type: pickle
methods:
__call__:
args: []
name: __call__
returns:
type: unspecified
type: callable
object_type: model
requirements:
- module: google
package_name: google-api-core
last lines should have been something like:
- module: google.cloud.storage
package_name: google_cloud_storage
Rn we use this:
>>> from importlib_metadata import packages_distributions
>>> packages_distributions()['box']
['python-box']
but in such cases as in the first comment, it breaks:
In [10]: pd = packages_distributions()
In [11]: for k in pd:
...: if len(pd[k]) != 1:
...: print(k, pd[k])
...:
azure ['azure-identity', 'azure-core', 'azure-storage-blob', 'azure-datalake-store']
google ['google-api-core', 'googleapis-common-protos', 'google-cloud-core', 'google-cloud-storage', 'google-resumable-media', 'google-auth', 'protobuf']
tests ['smdebug-rulesconfig', 'testcontainers']
ruamel ['ruamel.yaml.clib', 'ruamel.yaml']