Spaces:
Runtime error
Runtime error
Commit ·
8214b7d
1
Parent(s): bef288f
Update Modal function call to use professional_reception_function and simplify response handling
Browse files128 unmodified lines12913013113213213313418 unmodified lines1531541551571581561571581591604 unmodified lines165166167169170171168173174175176177178179180181182183184185186187169170171172254 unmodified lines427428429448430431432433128 unmodified lines
try: # 1. Setup Modal app and volume moderation_app = modal.App("Content-Moderation") _ = os.environ.get('MODAL_TOKEN_ID') # Read to ensure environment readiness (kept for parity with process_audio) _ = os.environ.get('MODAL_TOKEN_SECRET') _ = os.environ.get('MODAL_ENVIRONMENT')18 unmodified lines
# 4. Call Modal function synchronously try: moderation_function = modal.Function.from_name("Content-Moderation", "reception_function") processed_remote_path = moderation_function.remote( moderation_function = modal.Function.from_name("Content-Moderation", "professional_reception_function") moderation_function.spawn( input_text=str(notes) if notes is not None else "", video_path=remote_input_path, size=(int(width), int(height)),4 unmodified lines logger.error(f"Error calling Modal reception_function: {e}") return "Error calling Outpost to trigger processing."
if not processed_remote_path or not isinstance(processed_remote_path, str): logger.error("Modal function did not return a valid path to the processed video.") return "Processing failed to return an output path."
# 5. Download the processed video to /tmp with UUID filename local_ext = os.path.splitext(processed_remote_path)[1] or ext or ".mp4" local_output_path = f"/tmp/{uuid.uuid4().hex}{local_ext}" try: # Use Modal Volume.read_file to stream the remote file to the local path with open(local_output_path, "wb") as dst: for chunk in volume.read_file(processed_remote_path): if chunk: dst.write(chunk) except Exception as e: logger.error(f"Error downloading processed video from Modal Storage using read_file: {e}") return "Error downloading processed video from Cloud Storage."
# 6. Return local path return local_output_path return "Video Request Obtained"
except Exception as e: logger.error(f"Unexpected error in process_video: {e}")254 unmodified lines
# Third Row: Single Video Output with gr.Row(elem_classes="output-section"): cm_video_out = gr.Video(label="Video Output") cm_video_out = gr.Textbox(label="Output")
# Final Row: Process button with gr.Row():app.py+4-22