Register
Login
Resources
Docs Blog Datasets Glossary Case Studies Tutorials & Webinars
Product
Data Engine LLMs Platform Enterprise
Pricing Explore
Connect to our Discord channel

upload.py 1.2 KB

You have to be logged in to leave a comment. Sign In
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
  1. from huggingface_hub import Repository, repository
  2. import argparse
  3. import os
  4. parser = argparse.ArgumentParser()
  5. parser.add_argument('REPO', type=str, default='utensil/storage', nargs='?')
  6. parser.add_argument('--pull', type=bool, default=False, help='Whether to pull before push')
  7. args = parser.parse_args()
  8. if __name__ == '__main__':
  9. print('This file is deprecated, the behavior is compatible with notebooks earlier than 2023-04-24')
  10. print('Use storage.py instead')
  11. # determine the root of the repo and cd to it
  12. ROOT = os.path.join(os.path.dirname(os.path.abspath(__file__)), '..')
  13. os.chdir(ROOT)
  14. print(f"Working directory changed to: {ROOT}")
  15. HF_TOKEN = os.environ.get("HUGGINGFACE_TOKEN")
  16. remote_repo = args.REPO
  17. local_repo = remote_repo.split('/')[-1]
  18. repo = Repository(local_dir=local_repo, clone_from=remote_repo, repo_type='dataset', skip_lfs_files=True, use_auth_token=HF_TOKEN)
  19. if args.pull:
  20. repo.git_pull()
  21. if not repo.is_repo_clean():
  22. repo.git_add(auto_lfs_track=True)
  23. # print(f'Files to be uploaded:\n\n{repository.files_to_be_staged(local_repo)}')
  24. repo.push_to_hub()
  25. print('Upload succeeded.')
  26. else:
  27. print('Nothing to upload, exiting...')
Tip!

Press p or to see the previous file or, n or to see the next file

Comments

Loading...