From 62de353cedc9cf0f56854291e655cec02f833a6b Mon Sep 17 00:00:00 2001 From: Yinhr <110515845+Yinhaoran1128@users.noreply.github.com> Date: Sat, 15 Jun 2024 12:43:44 +0800 Subject: [PATCH] Fix: Move 0 validator & limit need_synthesize (#518) * Fix: move 0 validator from val_value to from_config * Fix: need_synthesize limit to calyx & trace * Fix: change order in from_config * Fix: change exception to log * Fix: delete InvalidPlannerRow --- tasks/planner/model.py | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/tasks/planner/model.py b/tasks/planner/model.py index 4bb596683..ba14f3d4b 100644 --- a/tasks/planner/model.py +++ b/tasks/planner/model.py @@ -99,10 +99,6 @@ SET_ROW_EXCLUDE = { } -class InvalidPlannerRow(Exception): - pass - - class StoredPlannerProxy(BaseModelWithFallback): item: ITEM_TYPES value: int | MultiValue = 0 @@ -133,8 +129,6 @@ class StoredPlannerProxy(BaseModelWithFallback): logger.warning(f'Planner item {self.item} has_group_base ' f'but given synthesize={self.synthesize} is not a MultiValue') self.synthesize = MultiValue() - if self.total.equivalent_green() <= 0: - raise InvalidPlannerRow(f'Planner item {self.item} has invalid total={self.total}, drop') else: if not isinstance(self.value, int): logger.warning(f'Planner item {self.item} has no group base ' @@ -148,8 +142,6 @@ class StoredPlannerProxy(BaseModelWithFallback): logger.warning(f'Planner item {self.item} has no group base ' f'but given synthesize={self.synthesize} is not an int') self.synthesize = 0 - if self.total <= 0: - raise InvalidPlannerRow(f'Planner item {self.item} has invalid total={self.total}, drop') if self.synthesize != 0: logger.warning(f'Planner item {self.item} has no group base ' f'its synthesize={self.synthesize} should be 0') @@ -425,7 +417,7 @@ class StoredPlannerProxy(BaseModelWithFallback): return self.progress < 100 def need_synthesize(self): - if self.item.has_group_base: + if self.item.is_ItemCalyx or self.item.is_ItemTrace: return self.synthesize.green > 0 or self.synthesize.blue > 0 or self.synthesize.purple > 0 else: return False @@ -502,12 +494,20 @@ class PlannerProgressParser: continue try: row = StoredPlannerProxy(**row) - except (ScriptError, ValidationError, InvalidPlannerRow) as e: + except (ScriptError, ValidationError) as e: logger.error(e) continue if not row.item.is_group_base: logger.error(f'from_config: item is not group base {row}') continue + if row.item.has_group_base: + if row.total.equivalent_green() <= 0: + logger.error(f'Planner item {row.item} has invalid total={row.total}, drop') + continue + else: + if row.total <= 0: + logger.error(f'Planner item {row.item} has invalid total={row.total}, drop') + continue row.update(time=False) self.rows[row.item.name] = row return self