Skip to content

Commit

Permalink
docs: add info about installing extras (#373)
Browse files Browse the repository at this point in the history
* docs: add info about installing extras

Signed-off-by: Matteo Mortari <[email protected]>

* Update clients/python/README.md

Co-authored-by: Isabella Basso <[email protected]>
Signed-off-by: Matteo Mortari <[email protected]>

* add error message details

Co-authored-by: Isabella Basso <[email protected]>
Signed-off-by: Matteo Mortari <[email protected]>

---------

Signed-off-by: Matteo Mortari <[email protected]>
Co-authored-by: Isabella Basso <[email protected]>
  • Loading branch information
tarilabs and isinyaaa authored Sep 11, 2024
1 parent 031e963 commit 4eadcec
Show file tree
Hide file tree
Showing 2 changed files with 42 additions and 2 deletions.
32 changes: 31 additions & 1 deletion clients/python/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,37 @@

[![Python](https://img.shields.io/badge/python%20-3.9%7C3.10%7C3.11%7C3.12-blue)](https://github.com/kubeflow/model-registry)
[![License](https://img.shields.io/badge/License-Apache_2.0-blue.svg)](../../../LICENSE)
[![Read the Docs](https://img.shields.io/readthedocs/model-registry)](https://model-registry.readthedocs.io/en/latest/)
[![Tutorial Website](https://img.shields.io/badge/Website-green?style=plastic&label=Tutorial&labelColor=blue)](https://www.kubeflow.org/docs/components/model-registry/getting-started/)

This library provides a high level interface for interacting with a model registry server.

## Installation

In your Python environment, you can install the latest version of the Model Registry Python client with:

```
pip install --pre model-registry
```

### Installing extras

Some capabilities of this Model Registry Python client, such as [importing model from Hugging Face](#importing-from-hugging-face-hub),
require additional dependencies.

By [installing an extra variant](https://packaging.python.org/en/latest/tutorials/installing-packages/#installing-extras) of this package
the additional dependencies will be managed for you automatically, for instance with:

```
pip install --pre "model-registry[hf]"
```

This step is not required if you already installed the additional dependencies already, for instance with:

```
pip install huggingface-hub
```

## Basic usage

```py
Expand Down Expand Up @@ -72,7 +100,9 @@ model = registry.register_model(
### Importing from Hugging Face Hub

To import models from Hugging Face Hub, start by installing the `huggingface-hub` package, either directly or as an
extra (available as `model-registry[hf]`).
extra (available as `model-registry[hf]`). Reference section "[installing extras](#installing-extras)" above for
more information.

Models can be imported with

```py
Expand Down
12 changes: 11 additions & 1 deletion clients/python/src/model_registry/_client.py
Original file line number Diff line number Diff line change
Expand Up @@ -247,7 +247,17 @@ def register_hf_model(
try:
from huggingface_hub import HfApi, hf_hub_url, utils
except ImportError as e:
msg = "huggingface_hub is not installed"
msg = """package `huggingface-hub` is not installed.
To import models from Hugging Face Hub, start by installing the `huggingface-hub` package, either directly or as an
extra (available as `model-registry[hf]`), e.g.:
```sh
!pip install --pre model-registry[hf]
```
or
```sh
!pip install huggingface-hub
```
"""
raise StoreError(msg) from e

api = HfApi()
Expand Down

0 comments on commit 4eadcec

Please sign in to comment.