diff --git a/ymmsl/v0_2/__init__.py b/ymmsl/v0_2/__init__.py index 3646590..6fb04b8 100644 --- a/ymmsl/v0_2/__init__.py +++ b/ymmsl/v0_2/__init__.py @@ -33,6 +33,7 @@ InconsistentTimelines, ResolveTimelineException, TooManyReducerFilters, + check_timelines, resolve_timelines, ) @@ -41,6 +42,7 @@ "CheckpointRule", "CheckpointRangeRule", "CheckpointAtRule", + "check_timelines", "Checkpoints", "Component", "Ports", diff --git a/ymmsl/v0_2/timeline_resolver.py b/ymmsl/v0_2/timeline_resolver.py index efd4fa2..a97c1a4 100644 --- a/ymmsl/v0_2/timeline_resolver.py +++ b/ymmsl/v0_2/timeline_resolver.py @@ -13,6 +13,26 @@ MUSCLE_SETTINGS_IN = Identifier("muscle_settings_in") +def check_timelines(model: Model) -> "TimelineChecker": + """Check that timelines for this model are consistent. + + This function checks that the timelines are consistent, and raises any of below + subclasses of :class:`ResolveTimelineException` if they are not. + + Raises: + CyclicDependency: When messages to an F_INIT port of a component depend in some + way on the output of that component. + TooManyReducerFilters: When a conduit filter is applied to messages in the root + timeline. + InconsistentTimelines: When a component's F_INIT ports are not all connected to + the same timeline. + ConduitTimelineError: When a conduit connects incompatible timelines. + """ + checker = TimelineChecker(model) + checker.check_consistent() + return checker + + def resolve_timelines(model: Model) -> None: """Determine timelines for each component and their O_I and S ports in this model. @@ -29,8 +49,7 @@ def resolve_timelines(model: Model) -> None: the same timeline. ConduitTimelineError: When a conduit connects incompatible timelines. """ - checker = TimelineChecker(model) - checker.check_consistent() + checker = check_timelines(model) # Update timeline attributes for component in model.components.values():