Migrating Python from Holoscan SDK 4.x
Holoscan SDK 5.x Python is an application-authoring API over the same graph,
compiler, plan, and runtime used by C++. It is not a compatibility layer over
the 4.x Application, Fragment, condition, scheduler, or Python operator
classes.
Use this page as an initial porting checklist. Migrate the application shape first, verify the compiled plan, and then port operator implementations to 5.x Python operators or to the C++ operator and registration model.
- How the major 4.x Python concepts map to 5.x
- Which changes are mechanical and which require design work
- A practical order for porting and verifying an application
Concept map
Port in this order
- Inventory operators and payloads. Identify every custom Python operator,
4.x domain operator,
TensorMap, and metadata dependency. Confirm that a registered 5.x provider exists, or plan a port to a 5.x Python or C++ operator. - Rebuild the topology as an
hs.Graph. Import proxies from the module package that ships them, create instances with schema-backed keyword parameters, and wire reflected ports. - Move runtime choices into authoring policy. Replace conditions, scheduler selection, and resource objects with operator contracts, graph clocks, queue policy, partitions, regions, and deployment options.
- Move file configuration onto the graph. Load the document, bind sparse
paths to handles, call
params.set_params(), and retain provenance if the application audits configuration. - Compile before running. Treat a rejected
Planas structured evidence; resolve every error diagnostic before creating a session. - Make shutdown explicit. Choose blocking
run()only for finite plans. For services and recurring graphs, ownrun_async()with a context manager and route control events torequest_stop(). - Compare plan artifacts. Save
plan.json()for representative graphs and review the topology, policies, endpoints, and diagnostics before testing live devices.
Minimal before-and-after shape
4.x pattern
5.x pattern
The snippets show application shape, not equivalent operator semantics. In
5.x, the source’s C++ temporal contract determines activation and the caller
owns run termination; limit is operator configuration, not a graph-stopping
condition.
Current boundaries to plan for
- 4.x Python operators do not have a 5.x compatibility shim. Rewrite each one
as an
hs.Operatorsubclass with typed ports and an explicitcontract(), or port it to the registered C++ model. Do not wrap the oldsetup()orcompute()methods. - Runtime parameter-control transactions are separate from cold graph
configuration. Use
params.set_params()before compile; do not expect a live replacement for every 4.x dynamic parameter pattern. - Python external topics cover scalar, inline-schema, raw Tensor, and descriptor-backed Tensor authoring. Tensor topics require the matching payload token and complete boundary contracts.
- Provider modules are explicit imports. Import the package that ships an operator before looking up its proxy; the core package does not scan the environment automatically.
See Python for current application-authoring guidance and the broader 4.x migration map for the C++ runtime and operator model.
Recap
- Migrate to
Graph→Plan→RunSession; do not search for 4.x application, condition, or scheduler compatibility classes. - Rewrite custom Python operators as
hs.Operatorsubclasses, or port them to registered C++ operators. - Make configuration, shutdown, payload metadata, and deployment constraints explicit, then verify the canonical plan before running.