ButlerAttributeManager¶
- class lsst.daf.butler.registry.interfaces.ButlerAttributeManager(*, registry_schema_version: VersionTuple | None = None)¶
- Bases: - VersionedExtension- An interface for managing butler attributes in a - Registry.- Parameters:
- registry_schema_versionVersionTupleorNone, optional
- Version of registry schema. 
 
- registry_schema_version
 - Notes - Attributes are represented in registry as a set of name-value pairs, both have string type. Any non-string data types (e.g. integers) need to be converted to/from strings on client side. Attribute names can be arbitrary strings, no particular structure is enforced by this interface. Attribute names are globally unique, to avoid potential collision clients should follow some common convention for attribute names, e.g. dot-separated components ( - config.managers.opaque).- One of the critical pieces of information that will be stored as attribute is the version of database schema which needs to be known before registry can do any operations on database. For that reasons it is likely there will be only one implementation of this interface which uses database table with a stable schema. - Methods Summary - clone(db)- Make an independent copy of this manager instance bound to a new - Databaseinstance.- delete(name)- Delete an attribute. - empty()- Check whether attributes set is empty. - get(name[, default])- Retrieve value of a given attribute. - initialize(db, context[, ...])- Construct an instance of the manager. - items()- Iterate over attributes and yield their names and values. - set(name, value, *[, force])- Set value for a given attribute. - Methods Documentation - abstract clone(db: Database) ButlerAttributeManager¶
- Make an independent copy of this manager instance bound to a new - Databaseinstance.- Parameters:
- Returns:
- instanceButlerAttributeManager
- New manager instance with the same configuration as this instance, but bound to a new Database object. 
 
- instance
 
 - abstract empty() bool¶
- Check whether attributes set is empty. - Returns:
- emptybool
- True if there are no any attributes defined. 
 
- empty
 
 - abstract get(name: str, default: str | None = None) str | None¶
- Retrieve value of a given attribute. 
 - abstract classmethod initialize(db: Database, context: StaticTablesContext, registry_schema_version: VersionTuple | None = None) ButlerAttributeManager¶
- Construct an instance of the manager. - Parameters:
- dbDatabase
- Interface to the underlying database engine and namespace. 
- contextStaticTablesContext
- Context object obtained from - Database.declareStaticTables; used to declare any tables that should always be present in a layer implemented with this manager.
- registry_schema_versionVersionTupleorNone
- Schema version of this extension as defined in registry. 
 
- db
- Returns:
- managerButlerAttributeManager
- An instance of - ButlerAttributeManager.
 
- manager
 
 - abstract items() Iterable[tuple[str, str]]¶
- Iterate over attributes and yield their names and values. 
 - abstract set(name: str, value: str, *, force: bool = False) None¶
- Set value for a given attribute. - Parameters:
- namestr
- Attribute name, arbitrary non-empty string. 
- valuestr
- New value for an attribute, an arbitrary string. Due to deficiencies of some database engines we are not allowing empty strings to be stored in the database, and - valuecannot be an empty string.
- forcebool, optional
- Controls handling of existing attributes. With default - Falsevalue an exception is raised if attribute- namealready exists, if- Trueis passed then value of the existing attribute will be updated.
 
- name
- Raises:
- ButlerAttributeExistsError
- Raised if attribute already exists but - forceoption is false.
- ValueError
- Raised if name or value parameters are empty.