Skip to content

Commit

Permalink
Update constants imports with backward compatibility #1172, #2453
Browse files Browse the repository at this point in the history
  • Loading branch information
WizKnight committed Aug 19, 2024
1 parent e782532 commit 5bb271c
Show file tree
Hide file tree
Showing 5 changed files with 175 additions and 146 deletions.
15 changes: 7 additions & 8 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -7,19 +7,18 @@ check_dirs := contrib src tests utils setup.py
quality:
ruff check $(check_dirs) # linter
ruff format --check $(check_dirs) # formatter
python3 utils/check_inference_input_params.py
python3 utils/check_contrib_list.py
python3 utils/check_static_imports.py
python3 utils/generate_async_inference_client.py
python utils/check_inference_input_params.py
python utils/check_contrib_list.py
python utils/check_static_imports.py
python utils/generate_async_inference_client.py
mypy src

style:
ruff format $(check_dirs) # formatter
ruff check --fix $(check_dirs) # linter
python3 utils/check_contrib_list.py --update
python3 utils/check_static_imports.py --update
python3 utils/generate_async_inference_client.py --update
ruff format src/huggingface_hub/hf_api.py
python utils/check_contrib_list.py --update
python utils/check_static_imports.py --update
python utils/generate_async_inference_client.py --update

inference_types_check:
python utils/generate_inference_types.py
Expand Down
8 changes: 8 additions & 0 deletions src/huggingface_hub/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -143,11 +143,14 @@
"CommitOperationAdd",
"CommitOperationCopy",
"CommitOperationDelete",
"DatasetInfo",
"GitCommitInfo",
"GitRefInfo",
"GitRefs",
"HfApi",
"ModelInfo",
"RepoUrl",
"SpaceInfo",
"User",
"UserLikes",
"WebhookInfo",
Expand Down Expand Up @@ -199,6 +202,7 @@
"get_space_runtime",
"get_space_variables",
"get_token_permission",
"get_user_overview",
"get_webhook",
"grant_access",
"like",
Expand Down Expand Up @@ -643,11 +647,14 @@ def __dir__():
CommitOperationAdd, # noqa: F401
CommitOperationCopy, # noqa: F401
CommitOperationDelete, # noqa: F401
DatasetInfo, # noqa: F401
GitCommitInfo, # noqa: F401
GitRefInfo, # noqa: F401
GitRefs, # noqa: F401
HfApi, # noqa: F401
ModelInfo, # noqa: F401
RepoUrl, # noqa: F401
SpaceInfo, # noqa: F401
User, # noqa: F401
UserLikes, # noqa: F401
WebhookInfo, # noqa: F401
Expand Down Expand Up @@ -699,6 +706,7 @@ def __dir__():
get_space_runtime, # noqa: F401
get_space_variables, # noqa: F401
get_token_permission, # noqa: F401
get_user_overview, # noqa: F401
get_webhook, # noqa: F401
grant_access, # noqa: F401
like, # noqa: F401
Expand Down
4 changes: 2 additions & 2 deletions src/huggingface_hub/fastai_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
from packaging import version

from huggingface_hub import snapshot_download
from huggingface_hub.constants import CONFIG_NAME
from huggingface_hub import constants
from huggingface_hub.hf_api import HfApi
from huggingface_hub.utils import (
SoftTemporaryDirectory,
Expand Down Expand Up @@ -272,7 +272,7 @@ def _save_pretrained_fastai(
if config is not None:
if not isinstance(config, dict):
raise RuntimeError(f"Provided config should be a dict. Got: '{type(config)}'")
path = os.path.join(save_directory, CONFIG_NAME)
path = os.path.join(save_directory, constants.CONFIG_NAME)
with open(path, "w") as f:
json.dump(config, f)

Expand Down
Loading

0 comments on commit 5bb271c

Please sign in to comment.