Spaces:
Runtime error
Runtime error
Peter Michael Gits
Fix Dockerfile directory permissions - create /app as root before switching users
26096f4 | #!/usr/bin/env python3 | |
| from huggingface_hub import HfApi | |
| import os | |
| # Migrate working code to the correct Space name as requested | |
| api = HfApi() | |
| try: | |
| print("Migrating working code to stt-gpu-service-python-v4...") | |
| # Use the working app code with updated version | |
| working_app = '''import gradio as gr | |
| import time | |
| # Semantic versioning - updated for correct Space | |
| VERSION = "1.0.1" | |
| COMMIT_SHA = "TBD" # Will be updated after push | |
| def health_check(): | |
| return { | |
| "status": "healthy", | |
| "timestamp": time.time(), | |
| "version": VERSION, | |
| "commit_sha": COMMIT_SHA, | |
| "message": "STT Service - Ready for model integration", | |
| "space_name": "stt-gpu-service-python-v4" | |
| } | |
| def placeholder_transcribe(audio): | |
| if audio is None: | |
| return "No audio provided" | |
| return f"Placeholder: Audio received (type: {type(audio)}) - STT model integration pending" | |
| # Create interface with version display | |
| with gr.Blocks(title="STT GPU Service Python v4") as demo: | |
| gr.Markdown("# ποΈ STT GPU Service Python v4") | |
| gr.Markdown("Working deployment! Ready for STT model integration.") | |
| with gr.Tab("Health Check"): | |
| health_btn = gr.Button("Check Health") | |
| health_output = gr.JSON() | |
| health_btn.click(health_check, outputs=health_output) | |
| with gr.Tab("Audio Test"): | |
| audio_input = gr.Audio(type="numpy") | |
| transcribe_btn = gr.Button("Test Transcribe") | |
| output_text = gr.Textbox() | |
| transcribe_btn.click(placeholder_transcribe, inputs=audio_input, outputs=output_text) | |
| # Version display in small text at bottom as requested | |
| gr.Markdown(f"<small>v{VERSION} (SHA: {COMMIT_SHA})</small>", elem_id="version-info") | |
| if __name__ == "__main__": | |
| demo.launch()''' | |
| # Simple requirements | |
| working_requirements = '''gradio''' | |
| # Updated README for correct Space | |
| correct_readme = '''--- | |
| title: STT GPU Service Python v4 | |
| emoji: ποΈ | |
| colorFrom: blue | |
| colorTo: green | |
| sdk: gradio | |
| app_file: app.py | |
| pinned: false | |
| --- | |
| # STT GPU Service Python v4 | |
| Working deployment ready for STT model integration with kyutai/stt-1b-en_fr. | |
| ''' | |
| # Write files locally | |
| with open('app_correct.py', 'w') as f: | |
| f.write(working_app) | |
| with open('requirements_correct.txt', 'w') as f: | |
| f.write(working_requirements) | |
| with open('README_correct.md', 'w') as f: | |
| f.write(correct_readme) | |
| print("Created corrected files locally") | |
| # Upload to the CORRECT Space name | |
| files = [ | |
| ("app_correct.py", "app.py"), | |
| ("requirements_correct.txt", "requirements.txt"), | |
| ("README_correct.md", "README.md") | |
| ] | |
| for local_file, repo_file in files: | |
| print(f"Uploading {local_file} as {repo_file} to stt-gpu-service-python-v4...") | |
| api.upload_file( | |
| path_or_fileobj=local_file, | |
| path_in_repo=repo_file, | |
| repo_id="pgits/stt-gpu-service-python-v4", | |
| repo_type="space", | |
| revision="main", | |
| commit_message=f"Migrate working code: Deploy {repo_file} v1.0.1 to correct Space" | |
| ) | |
| print(f"β {repo_file} deployed to stt-gpu-service-python-v4") | |
| print(f"\nπ MIGRATION COMPLETED!") | |
| print(f"π Correct Space URL: https://huggingface.co/spaces/pgits/stt-gpu-service-python-v4") | |
| print("π Working code now deployed to the originally requested Space name") | |
| except Exception as e: | |
| print(f"β Error: {e}") |