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 version cli command #2498

Merged
merged 5 commits into from
Sep 4, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion src/huggingface_hub/commands/huggingface_cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
from huggingface_hub.commands.upload import UploadCommand
from huggingface_hub.commands.upload_large_folder import UploadLargeFolderCommand
from huggingface_hub.commands.user import UserCommands
from huggingface_hub.commands.version import VersionCommand


def main():
Expand All @@ -40,13 +41,13 @@ def main():
ScanCacheCommand.register_subcommand(commands_parser)
DeleteCacheCommand.register_subcommand(commands_parser)
TagCommands.register_subcommand(commands_parser)
VersionCommand.register_subcommand(commands_parser)

# Experimental
UploadLargeFolderCommand.register_subcommand(commands_parser)

# Let's go
args = parser.parse_args()

if not hasattr(args, "func"):
parser.print_help()
exit(1)
Expand Down
37 changes: 37 additions & 0 deletions src/huggingface_hub/commands/version.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
# Copyright 2022 The HuggingFace Team. All rights reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
"""Contains command to print information about the version.

Usage:
huggingface-cli version
"""

from argparse import _SubParsersAction

from huggingface_hub import __version__

from . import BaseHuggingfaceCLICommand


class VersionCommand(BaseHuggingfaceCLICommand):
def __init__(self, args):
self.args = args

@staticmethod
def register_subcommand(parser: _SubParsersAction):
env_parser = parser.add_parser("version", help="Print information about the hugginface-cli version.")
010kim marked this conversation as resolved.
Show resolved Hide resolved
010kim marked this conversation as resolved.
Show resolved Hide resolved
env_parser.set_defaults(func=VersionCommand)

def run(self) -> None:
print(f"huggingface_hub version: {__version__}")
Loading