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

known_ids

Return all the schema ids tracked by this registry.

known_versions

Return all the schema versions tracked by this registry.

Methods Summary

all_schemas_from_filesystem([root])

Populate a schema registry based on the filesystem.

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_ids

Return all the schema ids tracked by this registry.

Returns:
schemaslist of int

List of schema ids.

known_versions

Return all the schema versions tracked by this registry.

Returns:
schemasset of str

Set of schema versions.

Methods Documentation

classmethod all_schemas_from_filesystem(root=None)

Populate a schema registry based on the filesystem.

Walk the directory tree from the root provided, locating all schemas.

classmethod from_filesystem(root=None, schema_root='lsst.v7_1.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:
schemalsst.alert.packet.Schema

The corresponding schema.

get_by_version(version)

Return the schema corresponding to the given version.

Returns:
schemalsst.alert.packet.Schema

The corresponding 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:
schemalsst.alert.packet.Schema

Alert schema to register.

versionstr

Version of the schema being registered. By convention, this is of the form MAJOR.MINOR, but any string can be used.

Returns:
schema_idint

The ID that has been allocated to the schema.