-
Notifications
You must be signed in to change notification settings - Fork 0
Fix GitHub Action Docker build and push #10
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
Changes from all commits
799ec70
011e170
c6faa53
897a174
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||||||||||||||||||||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -277,6 +277,13 @@ def _check_llama_cpp_available(): | |||||||||||||||||||||||||||||||||||||||||||||
| def _download_model(model_id: str, cache_dir: str, logger: QuantizationLogger) -> str: | ||||||||||||||||||||||||||||||||||||||||||||||
| """Download HuggingFace model to local cache.""" | ||||||||||||||||||||||||||||||||||||||||||||||
| from huggingface_hub import snapshot_download | ||||||||||||||||||||||||||||||||||||||||||||||
| from huggingface_hub.errors import ( | ||||||||||||||||||||||||||||||||||||||||||||||
| HfHubHTTPError, | ||||||||||||||||||||||||||||||||||||||||||||||
| RepositoryNotFoundError, | ||||||||||||||||||||||||||||||||||||||||||||||
| GatedRepoError, | ||||||||||||||||||||||||||||||||||||||||||||||
| LocalEntryNotFoundError, | ||||||||||||||||||||||||||||||||||||||||||||||
| ) | ||||||||||||||||||||||||||||||||||||||||||||||
| from requests.exceptions import ConnectionError, Timeout | ||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||
| logger.info(f"Downloading model {model_id} to cache...") | ||||||||||||||||||||||||||||||||||||||||||||||
| try: | ||||||||||||||||||||||||||||||||||||||||||||||
|
|
@@ -287,8 +294,47 @@ def _download_model(model_id: str, cache_dir: str, logger: QuantizationLogger) - | |||||||||||||||||||||||||||||||||||||||||||||
| ) | ||||||||||||||||||||||||||||||||||||||||||||||
| logger.info(f"Model downloaded to {local_path}") | ||||||||||||||||||||||||||||||||||||||||||||||
| return local_path | ||||||||||||||||||||||||||||||||||||||||||||||
| except GatedRepoError as e: | ||||||||||||||||||||||||||||||||||||||||||||||
| # Must be before RepositoryNotFoundError since it's a subclass | ||||||||||||||||||||||||||||||||||||||||||||||
| raise RuntimeError( | ||||||||||||||||||||||||||||||||||||||||||||||
| f"Model '{model_id}' is gated and requires authentication. " | ||||||||||||||||||||||||||||||||||||||||||||||
| f"Please log in with 'huggingface-cli login' and ensure you have access." | ||||||||||||||||||||||||||||||||||||||||||||||
| ) from e | ||||||||||||||||||||||||||||||||||||||||||||||
| except LocalEntryNotFoundError as e: | ||||||||||||||||||||||||||||||||||||||||||||||
| # Must be before HfHubHTTPError since it's a subclass | ||||||||||||||||||||||||||||||||||||||||||||||
| raise RuntimeError( | ||||||||||||||||||||||||||||||||||||||||||||||
| f"Model files not found for '{model_id}'. " | ||||||||||||||||||||||||||||||||||||||||||||||
| f"The repository may be empty or misconfigured." | ||||||||||||||||||||||||||||||||||||||||||||||
| ) from e | ||||||||||||||||||||||||||||||||||||||||||||||
| except RepositoryNotFoundError as e: | ||||||||||||||||||||||||||||||||||||||||||||||
| raise RuntimeError( | ||||||||||||||||||||||||||||||||||||||||||||||
| f"Model '{model_id}' not found on HuggingFace Hub. " | ||||||||||||||||||||||||||||||||||||||||||||||
| f"Please verify the model ID is correct." | ||||||||||||||||||||||||||||||||||||||||||||||
| ) from e | ||||||||||||||||||||||||||||||||||||||||||||||
| except HfHubHTTPError as e: | ||||||||||||||||||||||||||||||||||||||||||||||
| if e.response.status_code == 401: | ||||||||||||||||||||||||||||||||||||||||||||||
| raise RuntimeError( | ||||||||||||||||||||||||||||||||||||||||||||||
| f"Authentication failed for model '{model_id}'. " | ||||||||||||||||||||||||||||||||||||||||||||||
| f"Please log in with 'huggingface-cli login'." | ||||||||||||||||||||||||||||||||||||||||||||||
| ) from e | ||||||||||||||||||||||||||||||||||||||||||||||
| elif e.response.status_code == 403: | ||||||||||||||||||||||||||||||||||||||||||||||
| raise RuntimeError( | ||||||||||||||||||||||||||||||||||||||||||||||
| f"Access denied for model '{model_id}'. " | ||||||||||||||||||||||||||||||||||||||||||||||
| f"You may need to accept the model's license agreement on HuggingFace Hub." | ||||||||||||||||||||||||||||||||||||||||||||||
| ) from e | ||||||||||||||||||||||||||||||||||||||||||||||
| else: | ||||||||||||||||||||||||||||||||||||||||||||||
|
Comment on lines
+315
to
+325
|
||||||||||||||||||||||||||||||||||||||||||||||
| if e.response.status_code == 401: | |
| raise RuntimeError( | |
| f"Authentication failed for model '{model_id}'. " | |
| f"Please log in with 'huggingface-cli login'." | |
| ) from e | |
| elif e.response.status_code == 403: | |
| raise RuntimeError( | |
| f"Access denied for model '{model_id}'. " | |
| f"You may need to accept the model's license agreement on HuggingFace Hub." | |
| ) from e | |
| else: | |
| if hasattr(e, 'response') and e.response and e.response.status_code == 401: | |
| raise RuntimeError( | |
| f"Authentication failed for model '{model_id}'. " | |
| f"Please log in with 'huggingface-cli login'." | |
| ) from e | |
| elif hasattr(e, 'response') and e.response and e.response.status_code == 403: | |
| raise RuntimeError( | |
| f"Access denied for model '{model_id}'. " | |
| f"You may need to accept the model's license agreement on HuggingFace Hub." | |
| ) from e | |
| elif hasattr(e, 'response') and e.response and hasattr(e.response, 'status_code'): |
Copilot
AI
Nov 4, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
[nitpick] The nested condition on line 507 can be combined with line 506 for better readability: if os.path.exists(intermediate_file) and os.path.exists(final_file) and not os.path.samefile(intermediate_file, final_file):
| if os.path.exists(intermediate_file) and os.path.exists(final_file): | |
| if not os.path.samefile(intermediate_file, final_file): | |
| logger.info(f"Cleaning up intermediate file: {intermediate_file}") | |
| os.remove(intermediate_file) | |
| if os.path.exists(intermediate_file) and os.path.exists(final_file) and not os.path.samefile(intermediate_file, final_file): | |
| logger.info(f"Cleaning up intermediate file: {intermediate_file}") | |
| os.remove(intermediate_file) |
Copilot
AI
Nov 4, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
[nitpick] The fallback logic duplicates the cleanup code from lines 500-501. Consider extracting the cleanup logic into a helper function or restructuring to avoid duplication.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
[nitpick] The error handling combines multiple operations on a single line with
&&, making it harder to read and debug. Consider splitting into multiple RUN commands or separate lines within the same RUN for better clarity.