Spaces:
Sleeping
Sleeping
Fix indentation error in app.py - remove monkey patch since show_progress_on is already removed from wgp.py
Browse files
app.py
CHANGED
|
@@ -40,53 +40,6 @@ print("Attempting to import WanGP...")
|
|
| 40 |
try:
|
| 41 |
import gradio as gr
|
| 42 |
print("Gradio imported successfully")
|
| 43 |
-
|
| 44 |
-
# Monkey patch Gradio EventListener.change to ignore deprecated 'show_progress_on' argument (compat fix)
|
| 45 |
-
try:
|
| 46 |
-
from gradio.events import EventListener
|
| 47 |
-
|
| 48 |
-
# Patch EventListener._setup to wrap event_trigger and ignore show_progress_on
|
| 49 |
-
original_setup = EventListener._setup
|
| 50 |
-
|
| 51 |
-
def patched_setup(self, *args, **kwargs):
|
| 52 |
-
# Call original setup
|
| 53 |
-
result = original_setup(self, *args, **kwargs)
|
| 54 |
-
|
| 55 |
-
# Get the original event_trigger function
|
| 56 |
-
original_event_trigger = result
|
| 57 |
-
|
| 58 |
-
# Create wrapper that filters out show_progress_on
|
| 59 |
-
def wrapped_event_trigger(*args, **kwargs):
|
| 60 |
-
from gradio.components import Component
|
| 61 |
-
|
| 62 |
-
# Helper that pops deprecated kwarg
|
| 63 |
-
def _pop_show_progress_on(kwargs: dict):
|
| 64 |
-
if 'show_progress_on' in kwargs:
|
| 65 |
-
kwargs.pop('show_progress_on')
|
| 66 |
-
|
| 67 |
-
# Patch Component.change (where the kwarg is first passed)
|
| 68 |
-
if not hasattr(Component, '_original_change'):
|
| 69 |
-
Component._original_change = Component.change
|
| 70 |
-
|
| 71 |
-
def _patched_component_change(self, *args, **kwargs):
|
| 72 |
-
_pop_show_progress_on(kwargs)
|
| 73 |
-
return self._original_change(*args, **kwargs)
|
| 74 |
-
|
| 75 |
-
Component.change = _patched_component_change
|
| 76 |
-
print("Gradio Component.change patched to ignore 'show_progress_on'")
|
| 77 |
-
|
| 78 |
-
# Patch EventListener.change as additional safeguard (some objects return EventListener)
|
| 79 |
-
if not hasattr(EventListener, '_original_change'):
|
| 80 |
-
EventListener._original_change = EventListener.change
|
| 81 |
-
|
| 82 |
-
def _patched_listener_change(self, *args, **kwargs):
|
| 83 |
-
_pop_show_progress_on(kwargs)
|
| 84 |
-
return self._original_change(*args, **kwargs)
|
| 85 |
-
|
| 86 |
-
EventListener.change = _patched_listener_change
|
| 87 |
-
print("Gradio EventListener.change patched to ignore 'show_progress_on'")
|
| 88 |
-
except Exception as e:
|
| 89 |
-
print(f"Warning: could not patch Gradio EventListener.change: {e}")
|
| 90 |
except Exception as e:
|
| 91 |
print(f"Error importing Gradio: {e}")
|
| 92 |
traceback.print_exc()
|
|
|
|
| 40 |
try:
|
| 41 |
import gradio as gr
|
| 42 |
print("Gradio imported successfully")
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 43 |
except Exception as e:
|
| 44 |
print(f"Error importing Gradio: {e}")
|
| 45 |
traceback.print_exc()
|