skip stage configured and working

This commit is contained in:
IGNY8 VPS (Salman)
2026-01-17 00:10:26 +00:00
parent cf755b23dc
commit 97f5ff8167
7 changed files with 253 additions and 38 deletions

View File

@@ -81,42 +81,64 @@ def run_automation_task(self, run_id: str):
try:
service = AutomationService.from_run_id(run_id)
config = service.config
# Run all stages sequentially, checking for pause/cancel between stages
service.run_stage_1()
if service.run.status in ['paused', 'cancelled']:
logger.info(f"[AutomationTask] Automation {service.run.status} after stage 1")
return
# Run all stages sequentially, checking for enabled status, pause/cancel between stages
if config.stage_1_enabled:
service.run_stage_1()
if service.run.status in ['paused', 'cancelled']:
logger.info(f"[AutomationTask] Automation {service.run.status} after stage 1")
return
else:
logger.info(f"[AutomationTask] Stage 1 is disabled, skipping")
service.run_stage_2()
if service.run.status in ['paused', 'cancelled']:
logger.info(f"[AutomationTask] Automation {service.run.status} after stage 2")
return
if config.stage_2_enabled:
service.run_stage_2()
if service.run.status in ['paused', 'cancelled']:
logger.info(f"[AutomationTask] Automation {service.run.status} after stage 2")
return
else:
logger.info(f"[AutomationTask] Stage 2 is disabled, skipping")
service.run_stage_3()
if service.run.status in ['paused', 'cancelled']:
logger.info(f"[AutomationTask] Automation {service.run.status} after stage 3")
return
if config.stage_3_enabled:
service.run_stage_3()
if service.run.status in ['paused', 'cancelled']:
logger.info(f"[AutomationTask] Automation {service.run.status} after stage 3")
return
else:
logger.info(f"[AutomationTask] Stage 3 is disabled, skipping")
service.run_stage_4()
if service.run.status in ['paused', 'cancelled']:
logger.info(f"[AutomationTask] Automation {service.run.status} after stage 4")
return
if config.stage_4_enabled:
service.run_stage_4()
if service.run.status in ['paused', 'cancelled']:
logger.info(f"[AutomationTask] Automation {service.run.status} after stage 4")
return
else:
logger.info(f"[AutomationTask] Stage 4 is disabled, skipping")
service.run_stage_5()
if service.run.status in ['paused', 'cancelled']:
logger.info(f"[AutomationTask] Automation {service.run.status} after stage 5")
return
if config.stage_5_enabled:
service.run_stage_5()
if service.run.status in ['paused', 'cancelled']:
logger.info(f"[AutomationTask] Automation {service.run.status} after stage 5")
return
else:
logger.info(f"[AutomationTask] Stage 5 is disabled, skipping")
service.run_stage_6()
if service.run.status in ['paused', 'cancelled']:
logger.info(f"[AutomationTask] Automation {service.run.status} after stage 6")
return
if config.stage_6_enabled:
service.run_stage_6()
if service.run.status in ['paused', 'cancelled']:
logger.info(f"[AutomationTask] Automation {service.run.status} after stage 6")
return
else:
logger.info(f"[AutomationTask] Stage 6 is disabled, skipping")
service.run_stage_7()
if service.run.status in ['paused', 'cancelled']:
logger.info(f"[AutomationTask] Automation {service.run.status} after stage 7")
return
if config.stage_7_enabled:
service.run_stage_7()
if service.run.status in ['paused', 'cancelled']:
logger.info(f"[AutomationTask] Automation {service.run.status} after stage 7")
return
else:
logger.info(f"[AutomationTask] Stage 7 is disabled, skipping")
logger.info(f"[AutomationTask] Completed automation run: {run_id}")
@@ -147,6 +169,7 @@ def resume_automation_task(self, run_id: str):
try:
service = AutomationService.from_run_id(run_id)
run = service.run
config = service.config
# Continue from current stage
stage_methods = [
@@ -159,9 +182,22 @@ def resume_automation_task(self, run_id: str):
service.run_stage_7,
]
# Run from current_stage to end
stage_enabled = [
config.stage_1_enabled,
config.stage_2_enabled,
config.stage_3_enabled,
config.stage_4_enabled,
config.stage_5_enabled,
config.stage_6_enabled,
config.stage_7_enabled,
]
# Run from current_stage to end, only if stage is enabled
for stage in range(run.current_stage - 1, 7):
stage_methods[stage]()
if stage_enabled[stage]:
stage_methods[stage]()
else:
logger.info(f"[AutomationTask] Stage {stage + 1} is disabled, skipping")
logger.info(f"[AutomationTask] Resumed automation run: {run_id}")