SchemaRegistry¶
- class lsst.alert.packet.SchemaRegistry¶
Bases:
object
A registry for alert schemas.
When a schema is registered, the registry allocates it an ID. We can subsequently retrieve the schema by either the ID or by a version number.
Attributes Summary
Return all the schema versions tracked by this registry.
Methods Summary
calculate_id
(schema)Calculate an ID for the given schema.
from_filesystem
([root, schema_root])Populate a schema registry based on the filesystem.
get_by_id
(schema_id)Return the schema corresponding to the given ID.
get_by_version
(version)Return the schema corresponding to the given version.
register_schema
(schema, version)Register a new schema in the registry.
Attributes Documentation
- known_versions¶
Return all the schema versions tracked by this registry.
Methods Documentation
- static calculate_id(schema)¶
Calculate an ID for the given schema.
- Parameters:
- schema
lsst.alert.packet.Schema
Schema for which an ID will be derived.
- schema
- Returns:
- schema_id
int
The calculated ID.
- schema_id
- classmethod from_filesystem(root=None, schema_root='lsst.v5_0.alert')¶
Populate a schema registry based on the filesystem.
Walk the directory tree from the root provided, locating files named according to
schema_root_file
, and load the corresponding schemas into the registry.
- get_by_id(schema_id)¶
Return the schema corresponding to the given ID.
- Returns:
- schema
lsst.alert.packet.Schema
The corresponding schema.
- schema
- get_by_version(version)¶
Return the schema corresponding to the given version.
- Returns:
- schema
lsst.alert.packet.Schema
The corresponding schema.
- schema
- register_schema(schema, version)¶
Register a new schema in the registry.
If an existing schema has the same ID, it is replaced.
If an existing schema has the same version, the new schema replaces the old one under that version, but the old schema can still be accessed by ID.
- Parameters:
- schema
lsst.alert.packet.Schema
Alert schema to register.
- version
str
Version of the schema being registered. By convention, this is of the form
MAJOR.MINOR
, but any string can be used.
- schema
- Returns:
- schema_id
int
The ID that has been allocated to the schema.
- schema_id