Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add push to Hub functionalities #2897

Merged
merged 7 commits into from
Oct 27, 2022
Merged

Conversation

osanseviero
Copy link
Contributor

This is a follow-up of #2280

Flair users would benefit by being able to easily share their models and try them out with the Hub widgets or load models from others. Here is an example repo created out of it

model = SequenceTagger.load(...)
model.push_to_hub('my-own-ner-english')

This also implements a basic automatic model card generation with the appropriate tags for Flair models to be discoverable. This uses a non-git method so users are not required to use git-locally, even if in the remote server we do have git-versioning.

Let us know what you think! cc @stefan-it

@osanseviero
Copy link
Contributor Author

cc @Wauplin and @LysandreJik 🤗

@osanseviero osanseviero requested a review from alanakbik August 29, 2022 09:27
@alanakbik
Copy link
Collaborator

@osanseviero looks good, though when I run this code:

from flair.models import SequenceTagger

model: SequenceTagger = SequenceTagger.load('ner-fast')
model.push_to_hub(repo_id='flair/test-push', private=True)

it fails with

OSError: You need to provide a `token` or be logged in to Hugging Face with `huggingface-cli login`.

The first part of the error message is a bit hard to parse. How can I provide a token?

@alanakbik
Copy link
Collaborator

Could be related to #2919 - it would be good to have a consistent way of passing tokens.

@osanseviero
Copy link
Contributor Author

Ah good point about the error message! I was assuming user is already logged in through huggingface-cli login. The utilities (upload_folder and create_repo) automatically retrieve the token.

What we can do is add a token parameter to push_to_hub which would be None by default (when it's None we retrieve the token automatically). Do you think this would work?

The token for loading will be a bit more complex as this would require changing the loading function

@alanakbik
Copy link
Collaborator

Yes, a token parameter that defaults to None makes sense here!

@osanseviero
Copy link
Contributor Author

Done! Here is a repo I created by passing the token.

@alanakbik
Copy link
Collaborator

Looks like mypy is throwing some odd errors again, somehow checking code in some cache directory:

FAILED cache/flair/datasets/senteval/data/convert.py::flake-8::FLAKE8
FAILED cache/flair/datasets/senteval/data/convert.py::ISORT
FAILED cache/flair/datasets/senteval/data/mytokenize.py::mypy
FAILED cache/flair/datasets/senteval/data/mytokenize.py::flake-8::FLAKE8
FAILED cache/flair/datasets/senteval/data/mytokenize.py::ISORT

@helpmefindaname do you have an idea what is going on here?

@osanseviero
Copy link
Contributor Author

Hey there :) it seems things were fixed, should we merge this PR?

@alanakbik
Copy link
Collaborator

Hello @osanseviero sorry for the delay in checking this.

I've created a token and pushed a small model, experimenting with both a public and private repo:

For public I used:

model: SequenceTagger = SequenceTagger.load('ner-fast')
model.push_to_hub(repo_id='alanakbik/test-push-public', private=False, token="[ .. my token ..]")

For private I used:

model: SequenceTagger = SequenceTagger.load('ner-fast')
model.push_to_hub(repo_id='alanakbik/test-push-private', private=True, token="[ .. my token ..]")

The public one works, the private one doesn't. I am getting this error:

Repository Not Found for url: https://huggingface.co/api/models/alanakbik/test-push-private.
Please make sure you specified the correct `repo_id` and `repo_type`.
If the repo is private, make sure you are authenticated.

In spite of the error, a private repo is created at https://huggingface.co/alanakbik/test-push-private, but it is empty. Any ideas what I am doing wrong?

Co-authored-by: Lucain <lucainp@gmail.com>
@alanakbik
Copy link
Collaborator

@osanseviero thanks for adding this and @Wauplin thanks for finding the fix for private repos!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants