hfutils 0.2.2__tar.gz → 0.2.3__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- {hfutils-0.2.2/hfutils.egg-info → hfutils-0.2.3}/PKG-INFO +1 -1
- {hfutils-0.2.2 → hfutils-0.2.3}/hfutils/config/meta.py +1 -1
- {hfutils-0.2.2 → hfutils-0.2.3}/hfutils/entry/cli.py +2 -0
- hfutils-0.2.3/hfutils/entry/whoami.py +50 -0
- {hfutils-0.2.2 → hfutils-0.2.3/hfutils.egg-info}/PKG-INFO +1 -1
- {hfutils-0.2.2 → hfutils-0.2.3}/hfutils.egg-info/SOURCES.txt +1 -0
- {hfutils-0.2.2 → hfutils-0.2.3}/LICENSE +0 -0
- {hfutils-0.2.2 → hfutils-0.2.3}/MANIFEST.in +0 -0
- {hfutils-0.2.2 → hfutils-0.2.3}/README.md +0 -0
- {hfutils-0.2.2 → hfutils-0.2.3}/hfutils/__init__.py +0 -0
- {hfutils-0.2.2 → hfutils-0.2.3}/hfutils/archive/__init__.py +0 -0
- {hfutils-0.2.2 → hfutils-0.2.3}/hfutils/archive/base.py +0 -0
- {hfutils-0.2.2 → hfutils-0.2.3}/hfutils/archive/rar.py +0 -0
- {hfutils-0.2.2 → hfutils-0.2.3}/hfutils/archive/sevenz.py +0 -0
- {hfutils-0.2.2 → hfutils-0.2.3}/hfutils/archive/tar.py +0 -0
- {hfutils-0.2.2 → hfutils-0.2.3}/hfutils/archive/zip.py +0 -0
- {hfutils-0.2.2 → hfutils-0.2.3}/hfutils/config/__init__.py +0 -0
- {hfutils-0.2.2 → hfutils-0.2.3}/hfutils/entry/__init__.py +0 -0
- {hfutils-0.2.2 → hfutils-0.2.3}/hfutils/entry/base.py +0 -0
- {hfutils-0.2.2 → hfutils-0.2.3}/hfutils/entry/dispatch.py +0 -0
- {hfutils-0.2.2 → hfutils-0.2.3}/hfutils/entry/download.py +0 -0
- {hfutils-0.2.2 → hfutils-0.2.3}/hfutils/entry/ls.py +0 -0
- {hfutils-0.2.2 → hfutils-0.2.3}/hfutils/entry/upload.py +0 -0
- {hfutils-0.2.2 → hfutils-0.2.3}/hfutils/index/__init__.py +0 -0
- {hfutils-0.2.2 → hfutils-0.2.3}/hfutils/index/fetch.py +0 -0
- {hfutils-0.2.2 → hfutils-0.2.3}/hfutils/index/hash.py +0 -0
- {hfutils-0.2.2 → hfutils-0.2.3}/hfutils/index/make.py +0 -0
- {hfutils-0.2.2 → hfutils-0.2.3}/hfutils/index/validate.py +0 -0
- {hfutils-0.2.2 → hfutils-0.2.3}/hfutils/operate/__init__.py +0 -0
- {hfutils-0.2.2 → hfutils-0.2.3}/hfutils/operate/base.py +0 -0
- {hfutils-0.2.2 → hfutils-0.2.3}/hfutils/operate/download.py +0 -0
- {hfutils-0.2.2 → hfutils-0.2.3}/hfutils/operate/upload.py +0 -0
- {hfutils-0.2.2 → hfutils-0.2.3}/hfutils/operate/validate.py +0 -0
- {hfutils-0.2.2 → hfutils-0.2.3}/hfutils/utils/__init__.py +0 -0
- {hfutils-0.2.2 → hfutils-0.2.3}/hfutils/utils/binary.py +0 -0
- {hfutils-0.2.2 → hfutils-0.2.3}/hfutils/utils/download.py +0 -0
- {hfutils-0.2.2 → hfutils-0.2.3}/hfutils/utils/temp.py +0 -0
- {hfutils-0.2.2 → hfutils-0.2.3}/hfutils/utils/tqdm_.py +0 -0
- {hfutils-0.2.2 → hfutils-0.2.3}/hfutils/utils/walk.py +0 -0
- {hfutils-0.2.2 → hfutils-0.2.3}/hfutils.egg-info/dependency_links.txt +0 -0
- {hfutils-0.2.2 → hfutils-0.2.3}/hfutils.egg-info/entry_points.txt +0 -0
- {hfutils-0.2.2 → hfutils-0.2.3}/hfutils.egg-info/requires.txt +0 -0
- {hfutils-0.2.2 → hfutils-0.2.3}/hfutils.egg-info/top_level.txt +0 -0
- {hfutils-0.2.2 → hfutils-0.2.3}/requirements-7z.txt +0 -0
- {hfutils-0.2.2 → hfutils-0.2.3}/requirements-build.txt +0 -0
- {hfutils-0.2.2 → hfutils-0.2.3}/requirements-doc.txt +0 -0
- {hfutils-0.2.2 → hfutils-0.2.3}/requirements-rar.txt +0 -0
- {hfutils-0.2.2 → hfutils-0.2.3}/requirements-test.txt +0 -0
- {hfutils-0.2.2 → hfutils-0.2.3}/requirements-transfer.txt +0 -0
- {hfutils-0.2.2 → hfutils-0.2.3}/requirements.txt +0 -0
- {hfutils-0.2.2 → hfutils-0.2.3}/setup.cfg +0 -0
- {hfutils-0.2.2 → hfutils-0.2.3}/setup.py +0 -0
|
@@ -2,11 +2,13 @@ from .dispatch import hfutilcli
|
|
|
2
2
|
from .download import _add_download_subcommand
|
|
3
3
|
from .ls import _add_ls_subcommand
|
|
4
4
|
from .upload import _add_upload_subcommand
|
|
5
|
+
from .whoami import _add_whoami_subcommand
|
|
5
6
|
|
|
6
7
|
_DECORATORS = [
|
|
7
8
|
_add_download_subcommand,
|
|
8
9
|
_add_upload_subcommand,
|
|
9
10
|
_add_ls_subcommand,
|
|
11
|
+
_add_whoami_subcommand,
|
|
10
12
|
]
|
|
11
13
|
|
|
12
14
|
cli = hfutilcli
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
import click
|
|
2
|
+
from hbutils.string import plural_word
|
|
3
|
+
from huggingface_hub.utils import LocalTokenNotFoundError
|
|
4
|
+
|
|
5
|
+
from .base import CONTEXT_SETTINGS
|
|
6
|
+
from ..operate.base import get_hf_client
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
def _add_whoami_subcommand(cli: click.Group) -> click.Group:
|
|
10
|
+
"""
|
|
11
|
+
Add the 'whoami' subcommand to the CLI.
|
|
12
|
+
|
|
13
|
+
This command displays the current identification.
|
|
14
|
+
|
|
15
|
+
:param cli: The Click CLI application.
|
|
16
|
+
:type cli: click.Group
|
|
17
|
+
:return: The modified Click CLI application.
|
|
18
|
+
:rtype: click.Group
|
|
19
|
+
"""
|
|
20
|
+
|
|
21
|
+
@cli.command('whoami', help='See the current identification.\n\n'
|
|
22
|
+
'Set environment $HF_TOKEN to use your own access token.',
|
|
23
|
+
context_settings=CONTEXT_SETTINGS)
|
|
24
|
+
def whoami():
|
|
25
|
+
"""
|
|
26
|
+
Display the current identification.
|
|
27
|
+
|
|
28
|
+
This function retrieves the current user's identification from the Hugging Face Hub API and displays it.
|
|
29
|
+
|
|
30
|
+
"""
|
|
31
|
+
hf_client = get_hf_client()
|
|
32
|
+
try:
|
|
33
|
+
info = hf_client.whoami()
|
|
34
|
+
username = info['name']
|
|
35
|
+
click.echo(f'Hi, {click.style(f"@{username}", fg="green", bold=True)} '
|
|
36
|
+
f'(full name: {click.style(info["fullname"], underline=True)}'
|
|
37
|
+
f'{", PRO" if info["isPro"] else ""}).')
|
|
38
|
+
click.echo(f'You can access all resources with this identification.')
|
|
39
|
+
if info['orgs']:
|
|
40
|
+
click.echo(f'You have entered {plural_word(len(info["orgs"]), "organizations")}:')
|
|
41
|
+
for i, org_item in enumerate(info['orgs'], start=1):
|
|
42
|
+
click.echo(f'{i}. {click.style("@" + org_item["name"], fg="blue", bold=True)} '
|
|
43
|
+
f'(full name: {click.style(org_item["fullname"], underline=True)})')
|
|
44
|
+
except LocalTokenNotFoundError:
|
|
45
|
+
click.echo(f'Hi, {click.style("Guest", fg="yellow", bold=True)} (not authenticated).')
|
|
46
|
+
click.echo(click.style(f'No token for huggingface authentication found.', underline=True))
|
|
47
|
+
click.echo(f'If you need to access more, just set `HF_TOKEN` environment variable, '
|
|
48
|
+
f'or use `huggingface-cli login`.')
|
|
49
|
+
|
|
50
|
+
return cli
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|