Feature/resolve timelines#62
Conversation
Signature accepts a Sequence, but the logic previously only worked when providing a list. Other sequences silently didn't work.
Add `parent` property and `relative_to` (inspired by pathlib.Path)
N.B. Resolving imports doesn't rename components (only models) and therefore shouldn't rename timelines. Edit: thinking a bit more about this, I'm not sure if we must rename timelines when flattening the hierarchical models:
|
Include information on the conduits instead of just the components. Example error message: > Detected a dependency cycle in model 'cycle'. The component 'first' has an F_INIT port that depends on data produced by one of its own O_F or O_I ports: Conduit(first.final -> second.init) -> Conduit(second.final -> third.init) -> Conduit(third.final -> first.init). You may have an error in the conduits or may need a different coupling schema.
|
N.B. I've improved the cyclic dependency error, hopefully this is clear enough without writing and pointing to a new documentation page. |
Imagine a top-level model with two components After flattening, we have a flat model with components
Timelines on ports are usually relative timelines, and those shouldn't be a problem as long as the absolute timeline they're appended to is correct. They can interact with components outside the model just fine though, we can have a component |
LourensVeen
left a comment
There was a problem hiding this comment.
Definitely headed in the right direction, nice work!
| o_f: final | ||
| ports: | ||
| f_init: init | ||
| timeline macro:meso: |
There was a problem hiding this comment.
Oh, that final colon could be confusing. I never considered that. Not for this PR, but would it make sense to quote the timeline to clarify that?
timeline "macro:meso":
There was a problem hiding this comment.
| ConduitTimelineError, | ||
| CyclicDependency, | ||
| InconsistentTimelines, | ||
| TooManyReducerFilters, |
There was a problem hiding this comment.
Can we have too many repeaters as well? If I connect an init component to a micro with two repeaters? Or would that come out as InconsistentTimelines? But there aren't two known timelines in this case, so that's not what I would expect...
There was a problem hiding this comment.
That would indeed come out as InconsistentTimelines (which then suggests to add a reducer, or remove a repeater).
Note that TooManyReducerFilters only triggers when trying to reduce "above" the root timeline. You can also have too many reducers and end up with an InconsistentTimelines error (which will suggest to remove a reducer or add a repeater).
There was a problem hiding this comment.
Would it make sense to rename this exception to ReducerFilterOnRootTimeline (or similar) to avoid this confusion?
| second.final: third.init | ||
| third.final: first.init | ||
|
|
||
| reducer: |
There was a problem hiding this comment.
Can we have this also without the connection from first.o_f to second.f_init? That should work too, but does it?
There was a problem hiding this comment.
Yes, we can, and it works 😄
I've added a testcase for this.
| """Determine timelines for each component and their O_I and S ports in this model. | ||
|
|
||
| An exception will be raised when the model timelines are not consistent. This | ||
| function updates the timeline attributes of the components and ports in the model. |
There was a problem hiding this comment.
It would be useful for people building tools on top to know exactly which exceptions are raised under which circumstances.
There was a problem hiding this comment.
Good point, I've updated the documentation to point to the exception classes. The docstring of the exceptions explain the cases where they're raised.
Based on PR feedback
Yes, fully agreed! For complete correctness you'd have to rename these internal timelines. My point (which I didn't describe clearly, sorry for that!) was that timeline renaming isn't required for the checks in this PR. The flattened model is more of an internal MUSCLE3 state and I expect it's not required to have the renaming functionality in to get a properly behaving simulation. We'll have to test though 🙂 |

Continuation of PR #27
Update timeline annotations when importing/resolving (components are renamed tox.y.<component>and timeline annotations should as well to prevent clashes)v0_2.validation.timelines. Function:resolve_timelines()because it updates the timelines on the data objects