Spaces:
Running
on
Zero
Running
on
Zero
| #!/usr/bin/env python3 | |
| """ | |
| Script to verify Hugging Face Spaces configuration | |
| """ | |
| import os | |
| import sys | |
| import logging | |
| # Configure logging | |
| logging.basicConfig(level=logging.INFO) | |
| logger = logging.getLogger(__name__) | |
| def check_required_files(): | |
| """Check if all required files for HF Spaces deployment exist""" | |
| required_files = [ | |
| "app.py", | |
| "requirements.txt", | |
| "README.md", | |
| "build.py", | |
| "download_model.py", | |
| ".gitignore" | |
| ] | |
| missing_files = [] | |
| for file in required_files: | |
| if not os.path.exists(file): | |
| missing_files.append(file) | |
| if missing_files: | |
| logger.error(f"Missing required files: {missing_files}") | |
| return False | |
| logger.info("β All required files present") | |
| return True | |
| def check_app_imports(): | |
| """Check if app.py can be imported without errors""" | |
| try: | |
| # Test basic imports | |
| import gradio as gr | |
| import torch | |
| from transformers import AutoModelForCausalLM, AutoTokenizer | |
| logger.info("β Basic imports successful") | |
| return True | |
| except Exception as e: | |
| logger.error(f"β Import error: {e}") | |
| return False | |
| def check_download_script(): | |
| """Check if download script can be imported""" | |
| try: | |
| from download_model import main as download_main | |
| logger.info("β Download script import successful") | |
| return True | |
| except Exception as e: | |
| logger.error(f"β Download script import error: {e}") | |
| return False | |
| def main(): | |
| """Main verification function""" | |
| logger.info("π Verifying Hugging Face Spaces configuration...") | |
| checks = [ | |
| ("Required Files", check_required_files), | |
| ("App Imports", check_app_imports), | |
| ("Download Script", check_download_script) | |
| ] | |
| all_passed = True | |
| for check_name, check_func in checks: | |
| logger.info(f"Checking {check_name}...") | |
| if check_func(): | |
| logger.info(f"β {check_name} passed") | |
| else: | |
| logger.error(f"β {check_name} failed") | |
| all_passed = False | |
| if all_passed: | |
| logger.info("π All checks passed! Ready for Hugging Face Spaces deployment.") | |
| else: | |
| logger.error("β Some checks failed. Please fix the issues above.") | |
| return all_passed | |
| if __name__ == "__main__": | |
| success = main() | |
| sys.exit(0 if success else 1) |