Fix pipeline component mismatch fallback - use boolean flag instead of locals()

- Replace locals().get('goto_after_loading', False) with properly initialized boolean flag
- The locals() approach failed because locals() returns a copy, not a reference
- Now the fallback correctly skips error handling when pipeline loads successfully via detected class
parent 5a37d9d2
Pipeline #231 canceled with stages
......@@ -3486,6 +3486,9 @@ def main(args):
debug = getattr(args, 'debug', False)
# Initialize flag for pipeline mismatch fallback
pipeline_loaded_successfully = False
if debug:
print(f"\n🔍 [DEBUG] Model Loading Details:")
print(f" [DEBUG] Model ID to load: {model_id_to_load}")
......@@ -3507,6 +3510,7 @@ def main(args):
try:
pipe = PipelineClass.from_pretrained(model_id_to_load, **pipe_kwargs)
pipeline_loaded_successfully = True
except Exception as e:
error_str = str(e)
......@@ -3555,12 +3559,10 @@ def main(args):
pipe = CorrectPipelineClass.from_pretrained(model_id_to_load, **pipe_kwargs)
# Success! Update the model info for future runs
print(f" ✅ Successfully loaded with {detected_class}")
# Continue with the loaded pipeline
timing.end_step() # model_loading
# Update PipelineClass for the rest of the code
PipelineClass = CorrectPipelineClass
# Skip to after the error handling
goto_after_loading = True
# Mark as successfully loaded
pipeline_loaded_successfully = True
except Exception as retry_e:
print(f" ❌ Retry with {detected_class} also failed: {retry_e}")
# Continue with normal error handling
......@@ -3568,7 +3570,7 @@ def main(args):
error_str = str(retry_e)
# If we successfully loaded with the corrected pipeline, skip error handling
if not locals().get('goto_after_loading', False):
if not pipeline_loaded_successfully:
# Check if we should retry with an alternative model (auto mode)
# This applies to ALL error types - we try alternatives before giving up
if getattr(args, '_auto_mode', False):
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment