owner_ids.add(id_)
return [self.__class__.by_id(db_conn, id_) for id_ in owner_ids]
- def get_steps(self, db_conn: DatabaseConnection, external_owner:
- Process | None = None) -> list[ProcessStepsNode]:
+ def get_steps(self,
+ db_conn: DatabaseConnection,
+ external_owner: Process | None = None
+ ) -> list[ProcessStepsNode]:
"""Return tree of depended-on explicit and implicit ProcessSteps."""
def make_node(step: ProcessStep, suppressed: bool) -> ProcessStepsNode:
- is_explicit = False
- if external_owner is not None:
- is_explicit = step.owner_id == external_owner.id_
+ is_explicit = step.owner_id == top_owner.id_
process = self.__class__.by_id(db_conn, step.step_process_id)
step_steps = []
if not suppressed:
- step_steps = process.get_steps(db_conn, external_owner)
+ # exclude implicit siblings to explicit steps of same process
+ step_steps = [n for n in process.get_steps(db_conn, top_owner)
+ if not [s for s in top_owner.explicit_steps
+ if s.parent_step_id == step.id_
+ and s.step_process_id == n.process.id_]]
return ProcessStepsNode(step, process, is_explicit, step_steps,
False, suppressed)
step_nodes: list[ProcessStepsNode] = []
seen_step_ids: Set[int] = set()
- if external_owner is None:
- external_owner = self
+ top_owner = external_owner or self
for step in [s for s in self.explicit_steps
if s.parent_step_id is None]:
assert isinstance(step.id_, int)
- new_node = make_node(step, step in external_owner.suppressed_steps)
+ new_node = make_node(step, step in top_owner.suppressed_steps)
step_nodes += [new_node]
for step_node in step_nodes:
walk_steps(step_node)