sierra.core.graphs.sections#

Registry of the top-level sections of graphs.yaml.

graphs.yaml is a shared config file: several plugins each own one or more top-level sections of it. Rather than any one plugin hardcoding the full set (which would require it to import the others, and to be updated whenever a new plugin appears), each plugin declares the sections it owns by calling register() at import time.

sierra.core.graphs.gconfig then validates the whole file by consulting this registry, so:

  • No plugin needs to know about any other plugin's sections.

  • A section whose owning plugin is not installed is skipped rather than rejected: running stage 4 must not require the stage 5 plugin.

  • A section which no plugin owns is a config error, rather than being silently accepted and then never read.

Registration is idempotent so that repeated imports (which Python caches, but which can happen across test runs in one process) do not raise.

Classes#

Section

One top-level section of graphs.yaml, and how to validate it.

Shape

The structural shape of a section's contents.

Functions#

get(→ Optional[Section])

Look up one section by name, or None if its owner is not loaded.

is_known(→ bool)

Whether name is a section SIERRA ships a plugin for.

register(→ None)

Declare that a plugin owns a top-level section of graphs.yaml.

registered(→ dict[str, Section])

Return all currently-registered sections, keyed by name.

reset(→ None)

Drop all registrations. For tests only.

Module Contents#

class sierra.core.graphs.sections.Section[source]#
Inheritance diagram of sierra.core.graphs.sections.Section

One top-level section of graphs.yaml, and how to validate it.

name#

The key in graphs.yaml, e.g. intra-exp.

shape#

Whether the section's graphs are categorized or a flat list.

by_type#

Maps the value of a graph's type key to the schema which validates it. This is per-section, which serves two purposes: a section can accept only a subset of the graph types which exist (imagize supports only heatmaps and networks), and two sections can legitimately use the same schema object for the same type (imagize reuses the heatmap/network schemas verbatim).

owner#

Dotted name of the owning plugin, used in diagnostics so a config error names the plugin responsible for the section.

class sierra.core.graphs.sections.Shape[source]#
Inheritance diagram of sierra.core.graphs.sections.Shape

The structural shape of a section's contents.

Sections differ in whether their graphs are grouped into named categories (which the controller YAML can then enable/disable individually) or are a single flat list.

sierra.core.graphs.sections.get(name: str) → Section | None[source]#

Look up one section by name, or None if its owner is not loaded.

sierra.core.graphs.sections.is_known(name: str) → bool[source]#

Whether name is a section SIERRA ships a plugin for.

True even if that plugin is not loaded in this invocation; use get() to find out whether it can actually be validated.

sierra.core.graphs.sections.register(section: Section) → None[source]#

Declare that a plugin owns a top-level section of graphs.yaml.

Raises:

RuntimeError -- if a different plugin has already claimed this section name. Two plugins silently sharing a section would mean whichever imported last decided how it is validated.

sierra.core.graphs.sections.registered() → dict[str, Section][source]#

Return all currently-registered sections, keyed by name.

Which sections are present depends on which plugins have been imported, so callers should treat an absent section as "that plugin is not loaded" rather than "that section is invalid".

sierra.core.graphs.sections.reset() → None[source]#

Drop all registrations. For tests only.