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_versions

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.

Returns:
schemasset of str

Set of schema versions.

Methods Documentation

static calculate_id(schema)

Calculate an ID for the given schema.

Parameters:
schemalsst.alert.packet.Schema

Schema for which an ID will be derived.

Returns:
schema_idint

The calculated 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:
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.