GitHub user mohammadrezwankhan added a comment to the discussion: Serialization issues with external_python decorator
Yes — your diagnosis is correct. I can reproduce this on `bdsim==1.2.2`, and it is a false positive caused by how subsystem boundary ports are represented, not a real algebraic loop in your model. **Cause** During `compile()`, the `SUBSYSTEM` is flattened and its `INPORT`/`OUTPORT` blocks become multiport pass-through function blocks. The loop detector then walks dependencies per block (`block.sources`), not per output port. The scheduler is block-based as well. That matters for a shared `OUTPORT(acceleration, velocity, position)`: although the position output only depends on the second integrator's state, `bdsim` conservatively treats the whole `OUTPORT` as depending on all three inputs. It therefore invents a dependency from the position feedback path to the direct-feedthrough acceleration branch. With a minimal version of your topology, 1.2.2 reports this artificial cycle: ```text plant/force_in -> gravity -> plant/outputs -> plant/acceleration -> plant/force_in ``` The real position path passes through the integrators, so that cycle does not exist mathematically. **Workarounds** Your workaround is valid: keep the direct-feedthrough acceleration signal out of the shared subsystem `OUTPORT`, and recompute or route it in the parent diagram. I verified that this compiles while retaining velocity and position as subsystem outputs. Flattening just this affected chain into the parent diagram also compiles, because the integrator state then explicitly breaks the dependency graph. **Why simply suppressing the loop check is not enough** The execution scheduler also waits for all sources of the whole `OUTPORT`, so a complete fix needs either per-output dependency metadata/scheduling or removal of these pass-through boundary blocks during flattening. Skipping only the DFS check would merely move the failure to schedule generation. **Status** I could not find an existing issue or PR for this mixed feedthrough/non-feedthrough `OUTPORT` case, so I cannot confirm that a patch is currently planned. This Discussion plus a minimal reproducer would make a good bug report/regression test. Relevant source: [`_subsystem_import`](https://github.com/petercorke/bdsim/blob/v1.2.2/src/bdsim/blockdiagram.py#L617-L684), [loop detection](https://github.com/petercorke/bdsim/blob/v1.2.2/src/bdsim/blockdiagram.py#L526-L565), and [schedule generation](https://github.com/petercorke/bdsim/blob/v1.2.2/src/bdsim/blockdiagram.py#L852-L910). GitHub link: https://github.com/apache/airflow/discussions/71281#discussioncomment-17962155 ---- This is an automatically sent email for [email protected]. To unsubscribe, please send an email to: [email protected]
