Python
replace uuid plan id system with linear
Chris Maloned5bede943b61
diff --git a/shared/utils/self_refiner.py b/shared/utils/self_refiner.pyindex 3754592..26d3d26 100644--- a/shared/utils/self_refiner.py+++ b/shared/utils/self_refiner.py@@ -1,6 +1,5 @@import torchimport copy-import uuidfrom diffusers.utils.torch_utils import randn_tensordefault_plan = [@@ -51,8 +50,6 @@ def ensure_refiner_list(plan_data):if not isinstance(plan_data, list):return []for rule in plan_data:- if "id" not in rule:- rule["id"] = str(uuid.uuid4())if "phase" not in rule:rule["phase"] = 0return plan_data@@ -87,29 +84,30 @@ def add_refiner_rule(current_rules, range_val, steps_val, phase_val=None, max_phphases_overlap = (phase_idx == -1) or (r_phase == -1) or (phase_idx == r_phase)- if phases_overlap:- if new_start <= rule['end'] and new_end >= rule['start']:- from gradio import Info-- p_name_existing = "All Phases" if r_phase == -1 else f"Phase/Stage {r_phase+1}"- p_name_new = "All Phases" if phase_idx == -1 else f"Phase/Stage {phase_idx+1}"-- Info(f"Overlap detected! {p_name_new} steps {new_start}-{new_end} conflict with existing {p_name_existing} rule.")- return current_rules+ if phases_overlap and new_start <= rule['end'] and new_end >= rule['start']:+ from gradio import Info+ p_name_existing = "All Phases" if r_phase == -1 else f"Phase/Stage {r_phase+1}"+ p_name_new = "All Phases" if phase_idx == -1 else f"Phase/Stage {phase_idx+1}"+ Info(f"Overlap detected! {p_name_new} steps {new_start}-{new_end} conflict with existing {p_name_existing} rule.")+ return current_rulesnew_rule = {- "id": str(uuid.uuid4()),"start": new_start,"end": new_end,"steps": int(steps_val),"phase": phase_idx}-+updated_list = current_rules + [new_rule]return sorted(updated_list, key=lambda x: (x.get('phase', 0), x['start']))-def remove_refiner_rule(current_rules, rule_id):- return [r for r in current_rules if r["id"] != rule_id]+def remove_refiner_rule(current_rules, index):+ try:+ updated_list = list(current_rules)+ updated_list.pop(int(index))+ return updated_list+ except:+ return current_rulesclass PnPHandler:def __init__(self, stochastic_plans, ths_uncertainty=0.0, p_norm=1, certain_percentage=0.999, channel_dim: int = 1):diff --git a/wgp.py b/wgp.pyindex 1d7a16b..970cbbc 100644--- a/wgp.py+++ b/wgp.py@@ -10485,7 +10485,7 @@ def generate_video_tab(update_form = False, state_dict = None, ui_defaults = Nonif not plans:gr.Markdown("<I style='padding: 8px;'>No plans defined. Using defaults: Steps 2-5 (3x), Steps 6-13 (1x).</I>")return- for plan in plans:+ for idx, plan in enumerate(plans):with gr.Row(elem_classes="rule-row"):p_idx = plan.get('phase', 0)if p_idx == -1:@@ -10497,7 +10497,7 @@ def generate_video_tab(update_form = False, state_dict = None, ui_defaults = Nongr.Markdown(text_display, elem_classes="rule-card")gr.Button("✖", variant="stop", scale=0, elem_classes="delete-btn").click(fn=remove_refiner_rule,- inputs=[self_refiner_plan, gr.State(plan["id"])],+ inputs=[self_refiner_plan, gr.State(idx)],outputs=[self_refiner_plan])