Skip to content

Commit 589ff64

Browse files
committed
Fixed some errors
1 parent c3a0a92 commit 589ff64

File tree

5 files changed

+40
-18
lines changed

5 files changed

+40
-18
lines changed

CHANGELOG.md

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,16 @@ All notable changes to LocalLab will be documented in this file.
1616
- Added informative messages before and after model downloads for better user experience
1717
- Ensured consistent progress bar display across different model types and sizes
1818

19+
## [0.6.4] - 2025-05-16
20+
21+
### Fixed
22+
23+
- Fixed critical error with Hugging Face progress bars display
24+
- Corrected function naming and imports for better compatibility
25+
- Improved early configuration system to properly set up logging
26+
- Enhanced error handling during model downloads
27+
- Fixed AttributeError with huggingface_hub module
28+
1929
## [0.6.3] - 2025-05-16
2030

2131
### Improved

locallab/__init__.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,18 +4,18 @@
44

55
# Import early configuration first to set up logging and environment variables
66
# This ensures Hugging Face's progress bars are displayed correctly
7-
from .utils.early_config import enable_hf_progress_bars
7+
from .utils.early_config import configure_hf_logging
88

9-
__version__ = "0.6.4" # Updated to improve model downloading experience and fix CLI settings
9+
__version__ = "0.6.4" # Fixed Hugging Face progress bars display and improved model downloading experience
1010

1111
# Only import what's necessary initially, lazy-load the rest
1212
from .logger import get_logger
1313

1414
# Explicitly expose start_server for direct import
1515
from .server import start_server, cli
1616

17-
# Enable Hugging Face progress bars with native display
18-
enable_hf_progress_bars()
17+
# Configure Hugging Face logging early
18+
configure_hf_logging()
1919

2020
# Other imports will be lazy-loaded when needed
2121
# from .config import MODEL_REGISTRY, DEFAULT_MODEL

locallab/model_manager.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# Import early configuration module first to set up logging and environment variables
22
# This ensures Hugging Face's progress bars are displayed correctly
3-
from .utils.early_config import enable_hf_progress_bars, StdoutRedirector
3+
from .utils.early_config import configure_hf_progress_bars, StdoutRedirector
44

55
from .config import HF_TOKEN_ENV, get_env_var, set_env_var
66
import os
@@ -26,7 +26,7 @@
2626

2727
# Enable Hugging Face progress bars with native display
2828
# This ensures we see the visually appealing progress bars from HuggingFace
29-
enable_hf_progress_bars()
29+
configure_hf_progress_bars()
3030

3131
# Import transformers after configuring logging to ensure proper display
3232
from transformers import AutoTokenizer, AutoModelForCausalLM, BitsAndBytesConfig
@@ -278,7 +278,7 @@ async def _load_model_with_optimizations(self, model_id: str):
278278
print(f"\n{Fore.CYAN}Starting model download - native progress bars will appear below{Style.RESET_ALL}\n")
279279

280280
# Enable Hugging Face progress bars again to ensure they're properly configured
281-
enable_hf_progress_bars()
281+
configure_hf_progress_bars()
282282

283283
# Use a context manager to ensure proper display of Hugging Face progress bars
284284
with StdoutRedirector(disable_logging=True):
@@ -1093,7 +1093,7 @@ async def load_custom_model(self, model_name: str, fallback_model: Optional[str]
10931093
print(f"\n{Fore.CYAN}Starting custom model download - native progress bars will appear below{Style.RESET_ALL}\n")
10941094

10951095
# Enable Hugging Face progress bars again to ensure they're properly configured
1096-
enable_hf_progress_bars()
1096+
configure_hf_progress_bars()
10971097

10981098
# Use a context manager to ensure proper display of Hugging Face progress bars
10991099
with StdoutRedirector(disable_logging=True):

locallab/utils/early_config.py

Lines changed: 21 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -26,17 +26,17 @@ def configure_hf_logging():
2626
"""
2727
# Disable all warnings
2828
warnings.filterwarnings("ignore")
29-
29+
3030
# Configure logging for Hugging Face libraries
3131
for logger_name in ["transformers", "huggingface_hub", "accelerate", "tqdm", "filelock"]:
3232
hf_logger = logging.getLogger(logger_name)
3333
hf_logger.setLevel(logging.WARNING) # Only show warnings and errors
3434
hf_logger.propagate = False # Don't propagate to parent loggers
35-
35+
3636
# Remove any existing handlers
3737
for handler in hf_logger.handlers[:]:
3838
hf_logger.removeHandler(handler)
39-
39+
4040
# Add a null handler to prevent warnings about no handlers
4141
hf_logger.addHandler(logging.NullHandler())
4242

@@ -54,17 +54,17 @@ def __init__(self, disable_logging=True):
5454
self.original_stdout = sys.stdout
5555
self.original_stderr = sys.stderr
5656
self.original_log_levels = {}
57-
57+
5858
def __enter__(self):
5959
# Store original log levels
6060
if self.disable_logging:
6161
for logger_name in ["transformers", "huggingface_hub", "accelerate", "tqdm", "filelock"]:
6262
logger = logging.getLogger(logger_name)
6363
self.original_log_levels[logger_name] = logger.level
6464
logger.setLevel(logging.WARNING)
65-
65+
6666
return self
67-
67+
6868
def __exit__(self, exc_type, exc_val, exc_tb):
6969
# Restore original log levels
7070
if self.disable_logging:
@@ -83,18 +83,30 @@ def enable_hf_progress_bars():
8383
tqdm.tqdm.monitor_interval = 0 # Disable monitor thread
8484
except ImportError:
8585
pass
86-
86+
8787
# Configure huggingface_hub
8888
try:
8989
import huggingface_hub
90-
huggingface_hub.enable_progress_bars()
90+
# The correct way to enable progress bars in huggingface_hub
91+
from huggingface_hub.utils import logging as hf_logging
92+
hf_logging.enable_progress_bars()
93+
94+
# Also enable HF Transfer for better download experience
95+
if hasattr(huggingface_hub, "constants"):
96+
huggingface_hub.constants.HF_HUB_ENABLE_HF_TRANSFER = True
9197
except ImportError:
9298
pass
93-
99+
94100
# Configure transformers
95101
try:
96102
import transformers
97103
transformers.utils.logging.enable_progress_bar()
98104
transformers.logging.set_verbosity_warning()
99105
except ImportError:
100106
pass
107+
108+
# Alias for backward compatibility
109+
configure_hf_progress_bars = enable_hf_progress_bars
110+
111+
# Export the configure_hf_logging function for use in __init__.py
112+
__all__ = ["enable_hf_progress_bars", "configure_hf_progress_bars", "configure_hf_logging", "StdoutRedirector"]

setup.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@
5959
},
6060
author="Utkarsh Tiwari",
6161
author_email="utkarshweb2023@gmail.com",
62-
description="LocalLab: Run language models locally or in Google Collab with a friendly API",
62+
description="LocalLab: A lightweight AI inference server for running LLMs locally or in Google Colab with a friendly API.",
6363
long_description=long_description,
6464
long_description_content_type="text/markdown",
6565
url="https://github.com/UtkarshTheDev/LocalLab",

0 commit comments

Comments
 (0)