hf.py 2.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768
  1. # Copyright 2020 The HuggingFace Team. All rights reserved.
  2. #
  3. # Licensed under the Apache License, Version 2.0 (the "License");
  4. # you may not use this file except in compliance with the License.
  5. # You may obtain a copy of the License at
  6. #
  7. # http://www.apache.org/licenses/LICENSE-2.0
  8. #
  9. # Unless required by applicable law or agreed to in writing, software
  10. # distributed under the License is distributed on an "AS IS" BASIS,
  11. # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  12. # See the License for the specific language governing permissions and
  13. # limitations under the License.
  14. from huggingface_hub import constants
  15. from huggingface_hub.cli._cli_utils import check_cli_update, typer_factory
  16. from huggingface_hub.cli.auth import auth_cli
  17. from huggingface_hub.cli.cache import cache_cli
  18. from huggingface_hub.cli.datasets import datasets_cli
  19. from huggingface_hub.cli.download import download
  20. from huggingface_hub.cli.inference_endpoints import ie_cli
  21. from huggingface_hub.cli.jobs import jobs_cli
  22. from huggingface_hub.cli.lfs import lfs_enable_largefiles, lfs_multipart_upload
  23. from huggingface_hub.cli.models import models_cli
  24. from huggingface_hub.cli.repo import repo_cli
  25. from huggingface_hub.cli.repo_files import repo_files_cli
  26. from huggingface_hub.cli.spaces import spaces_cli
  27. from huggingface_hub.cli.system import env, version
  28. from huggingface_hub.cli.upload import upload
  29. from huggingface_hub.cli.upload_large_folder import upload_large_folder
  30. from huggingface_hub.utils import logging
  31. app = typer_factory(help="Hugging Face Hub CLI")
  32. # top level single commands (defined in their respective files)
  33. app.command(help="Download files from the Hub.")(download)
  34. app.command(help="Upload a file or a folder to the Hub.")(upload)
  35. app.command(help="Upload a large folder to the Hub. Recommended for resumable uploads.")(upload_large_folder)
  36. app.command(name="env", help="Print information about the environment.")(env)
  37. app.command(help="Print information about the hf version.")(version)
  38. app.command(help="Configure your repository to enable upload of files > 5GB.", hidden=True)(lfs_enable_largefiles)
  39. app.command(help="Upload large files to the Hub.", hidden=True)(lfs_multipart_upload)
  40. # command groups
  41. app.add_typer(auth_cli, name="auth")
  42. app.add_typer(cache_cli, name="cache")
  43. app.add_typer(datasets_cli, name="datasets")
  44. app.add_typer(jobs_cli, name="jobs")
  45. app.add_typer(models_cli, name="models")
  46. app.add_typer(repo_cli, name="repo")
  47. app.add_typer(repo_files_cli, name="repo-files")
  48. app.add_typer(spaces_cli, name="spaces")
  49. app.add_typer(ie_cli, name="endpoints")
  50. def main():
  51. if not constants.HF_DEBUG:
  52. logging.set_verbosity_info()
  53. check_cli_update("huggingface_hub")
  54. app()
  55. if __name__ == "__main__":
  56. main()