Update legacy Repository usage in various example files (#29085)
* Update legacy Repository usage in `examples/pytorch/text-classification/run_glue_no_trainer.py` Marked for deprecation here https://huggingface.co/docs/huggingface_hub/guides/upload#legacy-upload-files-with-git-lfs * Fix import order * Replace all example usage of deprecated Repository * Fix remaining repo call and rename args variable * Revert removing creation of gitignore files and don't change research examples
This commit is contained in:
committed by
GitHub
parent
f1a565a39f
commit
b6404866cd
@@ -42,7 +42,7 @@ from flax import jax_utils, traverse_util
|
||||
from flax.jax_utils import unreplicate
|
||||
from flax.training import train_state
|
||||
from flax.training.common_utils import get_metrics, onehot, shard, shard_prng_key
|
||||
from huggingface_hub import Repository, create_repo
|
||||
from huggingface_hub import HfApi
|
||||
from PIL import Image
|
||||
from tqdm import tqdm
|
||||
|
||||
@@ -455,9 +455,8 @@ def main():
|
||||
if repo_name is None:
|
||||
repo_name = Path(training_args.output_dir).absolute().name
|
||||
# Create repo and retrieve repo_id
|
||||
repo_id = create_repo(repo_name, exist_ok=True, token=training_args.hub_token).repo_id
|
||||
# Clone repo locally
|
||||
repo = Repository(training_args.output_dir, clone_from=repo_id, token=training_args.hub_token)
|
||||
api = HfApi()
|
||||
repo_id = api.create_repo(repo_name, exist_ok=True, token=training_args.hub_token).repo_id
|
||||
|
||||
# Get the datasets: you can either provide your own CSV/JSON training and evaluation files (see below)
|
||||
# or just provide the name of one of the public datasets available on the hub at https://huggingface.co/datasets/
|
||||
@@ -1061,7 +1060,13 @@ def main():
|
||||
model.save_pretrained(os.path.join(training_args.output_dir, ckpt_dir), params=params)
|
||||
tokenizer.save_pretrained(os.path.join(training_args.output_dir, ckpt_dir))
|
||||
if training_args.push_to_hub:
|
||||
repo.push_to_hub(commit_message=commit_msg, blocking=False)
|
||||
api.upload_folder(
|
||||
commit_message=commit_msg,
|
||||
folder_path=training_args.output_dir,
|
||||
repo_id=repo_id,
|
||||
repo_type="model",
|
||||
token=training_args.hub_token,
|
||||
)
|
||||
|
||||
def evaluation_loop(
|
||||
rng: jax.random.PRNGKey,
|
||||
|
||||
Reference in New Issue
Block a user