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 to no_trainer examples #13659

Merged
merged 4 commits into from
Sep 21, 2021
Merged

Add push_to_hub to no_trainer examples #13659

merged 4 commits into from
Sep 21, 2021

Conversation

sgugger
Copy link
Collaborator

@sgugger sgugger commented Sep 20, 2021

What does this PR do?

This PR adds the --push_to_hub flag to the no_trainer examples in the Transformers repository. For now, it only deals with run_glue_no_trainer.py but once everyone has commented, the final version will be duplicated on the other examples.

Copy link
Contributor

@patil-suraj patil-suraj left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good to me, thanks for adding this!

@julien-c
Copy link
Member

this is great!

else:
repo_name = args.hub_model_id
repo = Repository(args.output_dir, clone_from=repo_name)
elif args.output_dir is not None:
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can this arg be None? Wouldn't this lead to a failure later?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Also we assume in the if above that args.output_dir is not None already no in:

repo_name = get_full_repo_name(Path(args.output_dir).name, token=args.hub_token)

=> maybe raise Error before the repo creation if args.output_dir is None?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is asserted here already :-)

if accelerator.is_main_process:
if args.push_to_hub:
if args.hub_model_id is None:
repo_name = get_full_repo_name(Path(args.output_dir).name, token=args.hub_token)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Does the args.hub_token always have to be passed or is the locally saved fetched token taken in case args.hub_token is None?

Also is a nice error message thrown when the token is incorrect? Since push_to_hub now defaults to True - I think it'd be important to provide a nice error message and maybe also how to disable saving if wished

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Does the args.hub_token always have to be passed or is the locally saved fetched token taken in case args.hub_token is None?

Yes, it uses the local token if none is passed.

Note that the default to push_to_hub is not True, a user has to pass it. I'll add in the README that they should execute huggingface-cli login before running the script. Will also look at the error message and open an issue on huggingface_hub if it's not clear enough.

Copy link
Contributor

@patrickvonplaten patrickvonplaten left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good! Left some comments on how to maybe improve the user experience by catching errors early. Think we can raise an Error early if args.output_dir is not defined no?

@patil-suraj
Copy link
Contributor

Also, since blocking argument to push_to_hub was only introduced v0.0.17 maybe we should add this in the requirements.

Copy link
Member

@LysandreJik LysandreJik left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fantastic, thanks @sgugger! Good usage of the Repository object :)

@sgugger
Copy link
Collaborator Author

sgugger commented Sep 21, 2021

@patil-suraj The requirements huggingface_hub >= 0.0.17 is in the install requirements for Transformers now.

@sgugger sgugger merged commit b7d264b into master Sep 21, 2021
@sgugger sgugger deleted the repo_no_trainer branch September 21, 2021 17:13
Narsil pushed a commit to Narsil/transformers that referenced this pull request Sep 25, 2021
* Add push_to_hub to no_trainer examples

* Quality

* Document integration

* Roll out to other examples
stas00 pushed a commit to stas00/transformers that referenced this pull request Oct 12, 2021
* Add push_to_hub to no_trainer examples

* Quality

* Document integration

* Roll out to other examples
Albertobegue pushed a commit to Albertobegue/transformers that referenced this pull request Jan 13, 2022
* Add push_to_hub to no_trainer examples

* Quality

* Document integration

* Roll out to other examples
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.

None yet

5 participants