Skip to article frontmatterSkip to article content
Site not loading correctly?

This may be due to an incorrect BASE_URL configuration. See the MyST Documentation for reference.

model navigation

This notebook introduces model.find() and model.get() for navigating model elements by qualified name; after running it you can inspect any named element in the cumulative model directly.

Chapter 5 shifts from defining the model to inspecting and extending it. The cumulative model now carries dozens of named elements: part definitions, part usages, ports, an allocation, a requirement, and item definitions. Navigating by position in a query result is fragile; navigating by qualified name (package::element) is stable as the model grows.

model.find(name) returns a Symbol or None for a short or fully-qualified name. model.get(fqn) returns a Symbol and raises if the name is absent. Together they are the navigation layer the rest of this chapter, and Chapter 6, build on.

The containment skeleton of everything built so far, before the chapter adds a port and an allocation. The one solid, hollow-triangle edge is Toaster’s own specialization of ToastingSystem (Chapter 1), not containment.

Loading...

model.find() and model.get() only resolve elements that parsed. The negative control below loads a model with an unresolved specialization and confirms it fails before navigation is attempted.

Neg control diagnostics: 'unresolved reference: UndefinedBase'

The diagnostic reports an unresolved reference: UndefinedBase is not a name in scope, so the model fails to load before any navigation can run.

ApplyHeat was already drawn in Chapter 4’s own action-flow diagram, nested inside ToastBread; the containment diagram above shows parts, not actions.

find result: id='ToasterDemo::HeatingSystem', kind='partDef'
get result: id='ToasterDemo::ApplyHeat', kind='actionDef'
missing element: None

The qualified names printed above resolve to the same HeatingSystem and ApplyHeat declared in models/ch05-cumulative.sysml, confirmed by the Symbol each call returns.

Try the chapter exercise in exercises/ch05/exercise.ipynb: use model.find() to navigate to CoffeeDemo::CoffeeFlow after building the assembly, then confirm model.find() returns None for an element that does not exist.