pittgoogle.schema

Classes to manage alert schemas.

Schema(*, name, description, origin[, ...])

Class for an individual schema.

SchemaHelpers()

Class to organize helper functions.


class pittgoogle.schema.Schema(*, name: str, description: str, origin: str, definition: dict | None = None, helper: str = 'default_schema_helper', path: Path | None = None, filter_map: dict = NOTHING, survey: str | None = None)[source]

Class for an individual schema.

Do not call this class’s constructor directly. Instead, load a schema using the registry pittgoogle.registry.Schemas.


definition: dict | None

The schema definition used to serialize and deserialize the alert bytes, if one is required.

description: str

A description of the schema.

filter_map: dict

Mapping of the filter name as stored in the alert (often an int) to the common name (often a string).

property map: dict

Mapping of Pitt-Google’s generic field names to survey-specific field names.

name: str

Name of the schema.

origin: str

Pointer to the schema’s origin. Typically this is a URL to a repo maintained by the survey.

path: Path | None

Path where the helper can find the schema, if needed.

property survey: str

Name of the survey. This is usually the first part of the schema’s name.

class pittgoogle.schema.SchemaHelpers[source]

Class to organize helper functions.

This class is not intended to be used directly, except by developers adding support for a new schema.

For Developers:

When a user requests a schema from the registry, the class method Schema._from_yaml() is called. The method will pass schema_name’s dict entry from the registry’s schemas.yml file to one of these helper methods, which will then construct the Schema object.

If you are adding support for a new schema, you will need to point to the appropriate helper method for your schema using the helper field in the registry’s schemas.yml file. If an appropriate method does not exist in this class, you will need to add one.


static default_schema_helper(schema_dict: dict) Schema[source]

Resolve schema.path. If it points to a valid “.avsc” file, load it into schema.avsc.

static lsst_auto_schema_helper(schema_dict: dict) Schema[source]

Load the Avro schema definition using the lsst.alert.packet package.

Raises:

SchemaError – If an LSST schema called schema.name cannot be loaded. An error is raised because the LSST alert bytes are schemaless, so schema.definition will be required in order to deserialize the alert.

static lsst_schema_helper(schema_dict: dict) Schema[source]

Load the Avro schema definition for lsst.v7_1.alert.