registry
export.registry
Export-format registry.
Single source of truth for all SimulationExperiment export backends: serialisation formats (YAML, openMINDS), reports (markdown, PDF), and code generators (TVB, JAX, tvboptim, Julia, NeuroML/LEMS, …).
A backend self-registers an :class:ExportFormat describing:
- canonical key + aliases (resolution)
- human label, file extension, MIME type (UI / API)
- a renderer callable (dispatch)
- optional flags (
supports_with_data, …)
Adding a new backend = importing this module and calling :func:register once. Dispatch (SimulationExperiment.render), discovery (/api/v1/experiments/formats, OntologyAPI), and the extension/UI dropdown all light up automatically.
Attributes
| Name | Description |
|---|---|
| Importer | |
| Renderer |
Classes
| Name | Description |
|---|---|
| ExportFormat | Descriptor for an export backend. |
ExportFormat
export.registry.ExportFormat(
key,
label,
extension,
media_type,
renderer,
aliases=(),
supports_with_data=False,
description='',
importer=None,
extensions=(),
language='',
)Descriptor for an export backend.
Methods
| Name | Description |
|---|---|
| to_public_dict | Serialisable view (without the renderer callable). |
to_public_dict
export.registry.ExportFormat.to_public_dict()Serialisable view (without the renderer callable).
Functions
| Name | Description |
|---|---|
| has | Report whether a format is registered under the given key or alias. |
| keys | Return a view of every registered key and alias. |
| list_format_dicts | Public dict view of all formats — for API/UI dropdowns. |
| list_formats | Return all registered formats (deduplicated, ordered by canonical key). |
| load | Resolve fmt_key and invoke its importer on path. |
| register | Register fmt under its canonical key and all aliases. |
| render | Resolve fmt_key, invoke its renderer, prune its dead imports, and format it. |
| resolve | Look up an :class:ExportFormat by canonical key or alias. |
| resolve_by_extension | Look up a format by file suffix (e.g. '.yaml', '.nml'). |
has
export.registry.has(key)Report whether a format is registered under the given key or alias.
Parameters
| Name | Type | Description | Default |
|---|---|---|---|
| key | str | Canonical key or alias to check (matched case-insensitively). | required |
Returns
| Name | Type | Description |
|---|---|---|
| bool | True if a format is registered under key, otherwise False. |
keys
export.registry.keys()Return a view of every registered key and alias.
Returns
| Name | Type | Description |
|---|---|---|
| Iterable[str] | A view over all lookup keys, including canonical keys and aliases | |
| Iterable[str] | (all lowercased). The same format may appear under several keys. |
list_format_dicts
export.registry.list_format_dicts()Public dict view of all formats — for API/UI dropdowns.
list_formats
export.registry.list_formats()Return all registered formats (deduplicated, ordered by canonical key).
load
export.registry.load(fmt_key, path, **kwargs)Resolve fmt_key and invoke its importer on path.
Raises ValueError if the format has no importer registered.
register
export.registry.register(fmt, *, overwrite=False)Register fmt under its canonical key and all aliases.
Raises ValueError if a key is already taken (unless overwrite).
render
export.registry.render(experiment, fmt_key, **kwargs)Resolve fmt_key, invoke its renderer, prune its dead imports, and format it.
All three happen here rather than in each renderer so that every backend — including the ones that render through an adapter and never touch the template helpers — is held to the same house style. Pruning precedes formatting because it edits statements and black only edits layout. See :mod:tvbo.codegen.prune and :mod:tvbo.codegen.style.
resolve
export.registry.resolve(key)Look up an :class:ExportFormat by canonical key or alias.
resolve_by_extension
export.registry.resolve_by_extension(suffix)Look up a format by file suffix (e.g. '.yaml', '.nml').
Raises ValueError if no format claims the suffix or if multiple formats claim it ambiguously.