Skip to content

Commit

Permalink
DEPR hub_utils.push (#398)
Browse files Browse the repository at this point in the history
* DEPR hub_utils.push

* use new linters

* remove examples using push

* use and simplify california housing example
  • Loading branch information
adrinjalali authored Oct 23, 2023
1 parent 41f71fd commit 60d7063
Show file tree
Hide file tree
Showing 7 changed files with 21 additions and 544 deletions.
4 changes: 2 additions & 2 deletions docs/changes.rst
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,8 @@ v0.9
estimators. :pr:`384` by :user:`Reid Johnson <reidjohnson>`.
- Fix an issue with visualizing Skops files for `scikit-learn` tree estimators.
:pr:`386` by :user:`Reid Johnson <reidjohnson>`.
- :func:`skops.hug_utils.get_model_output` is deprecated and will be removed in version
0.10. :pr:`396` by `Adrin Jalali`_.
- :func:`skops.hub_utils.get_model_output` and :func:`skops.hub_utils.push` are
deprecated and will be removed in version 0.10. :pr:`396` by `Adrin Jalali`_.

v0.8
----
Expand Down
6 changes: 2 additions & 4 deletions docs/index.rst
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,8 @@ find the source code and the development discussions on `Github

The following examples are good starting points:

- How to create and initialize a scikit-learn model repo:
:ref:`sphx_glr_auto_examples_plot_hf_hub.py`. You can see all the models
uploaded to the Hugging Face Hub using this library `here
<https://huggingface.co/models?other=skops>`_.
- Improve your data science workflow with skops:
:ref:`sphx_glr_auto_examples_plot_california_housing.py`
- How to create a model card for your scikit-learn based model:
:ref:`sphx_glr_auto_examples_plot_model_card.py`
- A text classification example, and its integration with the hub:
Expand Down
60 changes: 6 additions & 54 deletions examples/plot_california_housing.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
"""
Improve your data science workflow with skops and Hugging Face
==============================================================
Improve your data science workflow with skops
=============================================
"""

# %%
Expand Down Expand Up @@ -48,7 +48,6 @@
import numpy as np
import pandas as pd
import sklearn
from huggingface_hub import HfApi
from matplotlib.patches import Rectangle
from sklearn.compose import ColumnTransformer
from sklearn.datasets import fetch_california_housing
Expand Down Expand Up @@ -1860,57 +1859,10 @@
os.listdir(hub_dir)

# %%
# Perfect. In order to create a repository on the Hub, we need a token.
# When you’re logged into the Hub, you can find it here:
# https://huggingface.co/settings/tokens. For this exercise, we assume the
# token is set as an environment variable called ``HF_HUB_TOKEN``.
# We could also set it here directly by pasting it as a string, but
# generally we should keep the token secret.


# %%
token = os.environ["HF_HUB_TOKEN"]

# %%
# Now it’s time to push the repository to the Hub. We think of a good
# name, which, together with the user name, will constitute the
# ``repo_id``:

# %%
repo_name = "example-california-housing"
user_name = HfApi().whoami(token=token)["name"]
repo_id = f"{user_name}/{repo_name}"
print(f"Creating and pushing to repo: {repo_id}")

# %% [markdown]
# Finally, we call `hub_utils.push` like this:

# %%
hub_utils.push(
repo_id=repo_id,
source=hub_dir,
token=token,
create_remote=True,
private=False,
)

# %%
# We might consider changing the ``private`` argument here,
# depending on our goal. However, we can always change it later on the
# repository settings if we want to.

# %%
# Now let’s print the full URL and visit it:

# %%
print(f"Visit the following URL: https://huggingface.co/{repo_id}")

# %%
# We can now visit the page and see the rendered model card, we can use
# the inference widget to try out what the model would predict for a given
# input (the warmup for the widget may take a while), other people can
# comment on the repo and make PRs, etc. So let’s share the link with our
# interested friends and colleagues!
# Creating the Repo and Pushing to Hugging Face Hub
# You can use the tools available in ``huggingface_hub`` to create a repo and
# push the contents of the repo folder to that repo. For more information visit
# https://huggingface.co/docs/huggingface_hub/index

# %%
# Conclusion
Expand Down
172 changes: 0 additions & 172 deletions examples/plot_hf_hub.py

This file was deleted.

Loading

0 comments on commit 60d7063

Please sign in to comment.