VersionedExtension

class lsst.daf.butler.registry.interfaces.VersionedExtension(*, registry_schema_version: VersionTuple | None = None)

Bases: ABC

Interface for extension classes with versions.

Parameters:
registry_schema_versionVersionTuple or None

Schema version of this extension as defined in registry. If None, it means that registry schema was not initialized yet and the extension should expect that schema version returned by newSchemaVersion method will be used to initialize the registry database. If not None, it is guaranteed that this version has passed compatibility check.

Methods Summary

checkCompatibility(registry_schema_version, ...)

Check that schema version defined in registry is compatible with current implementation.

checkNewSchemaVersion(schema_version)

Verify that requested schema version can be created by an extension.

clsNewSchemaVersion(schema_version)

Class method which returns schema version to use for newly created registry database.

currentVersions()

Return schema version(s) supported by this extension class.

extensionName()

Return full name of the extension.

newSchemaVersion()

Return schema version for newly created registry.

Methods Documentation

classmethod checkCompatibility(registry_schema_version: VersionTuple, update: bool) None

Check that schema version defined in registry is compatible with current implementation.

Parameters:
registry_schema_versionVersionTuple

Schema version that exists in registry or defined in a configuration for a registry to be created.

updatebool

If True then read-write access is expected.

Raises:
IncompatibleVersionError

Raised if schema version is not supported by implementation.

Notes

Default implementation uses VersionTuple.checkCompatibility on the versions returned from currentVersions method. Subclasses that support different compatibility model will overwrite this method.

classmethod checkNewSchemaVersion(schema_version: VersionTuple) None

Verify that requested schema version can be created by an extension.

Parameters:
schema_versionVersionTuple

Schema version that this extension is asked to create.

Notes

This method may be used only occasionally when a specific schema version is given in a regisitry config file. This can be used with an extension that supports multiple schem versions to make it create new schema with a non-default version number. Default implementation compares requested version with one of the version returned from currentVersions.

classmethod clsNewSchemaVersion(schema_version: VersionTuple | None) VersionTuple | None

Class method which returns schema version to use for newly created registry database.

Parameters:
schema_versionVersionTuple or None

Configured schema version or None if default schema version should be created. If not None then it is guaranteed to be compatible with currentVersions.

Returns:
versionVersionTuple or None

Schema version created by this extension. None is returned if an extension does not require its version to be saved or checked.

Notes

Default implementation of this method can work in simple cases. If the extension only supports single schema version than that version is returned. If the extension supports multiple schema versions and schema_version is not None then schema_version is returned. If the extension supports multiple schema versions, but schema_version is None it calls _newDefaultSchemaVersion method which needs to be reimplemented in a subsclass.

abstract classmethod currentVersions() list[lsst.daf.butler.registry.interfaces._versioning.VersionTuple]

Return schema version(s) supported by this extension class.

Returns:
versionlist [VersionTuple]

Schema versions for this extension. Empty list is returned if an extension does not require its version to be saved or checked.

classmethod extensionName() str

Return full name of the extension.

This name should match the name defined in registry configuration. It is also stored in registry attributes. Default implementation returns full class name.

Returns:
namestr

Full extension name.

newSchemaVersion() VersionTuple | None

Return schema version for newly created registry.

Returns:
versionVersionTuple or None

Schema version created by this extension. None is returned if an extension does not require its version to be saved or checked.

Notes

Extension classes that support multiple schema versions need to override _newDefaultSchemaVersion method.