DimensionRecord¶
- class lsst.daf.butler.DimensionRecord(**kwargs: Any)¶
Bases:
object
Base class for the Python representation of database records.
- Parameters:
- **kwargs
Field values for this record. Unrecognized keys are ignored. If this is the record for a
Dimension
, its primary key value may be provided with the actual name of the field (e.g. “id” or “name”), the name of theDimension
, or both. If this record class has a “timespan” attribute, “datetime_begin” and “datetime_end” keyword arguments may be provided instead of a single “timespan” keyword argument (but are ignored if a “timespan” argument is provided).
Notes
DimensionRecord
subclasses are created dynamically for eachDimensionElement
in aDimensionUniverse
, and are accessible via theDimensionElement.RecordClass
attribute. TheDimensionRecord
base class itself is pure abstract, but does not use theabc
module to indicate this because it does not have overridable methods.Record classes have attributes that correspond exactly to the
standard
fields in the related database table, plus “region” and “timespan” attributes for spatial and/or temporal elements (respectively).Instances are usually obtained from a
Registry
, but can be constructed directly from Python as well.DimensionRecord
instances are immutable.Attributes Summary
A dict-like identifier for this record's primary keys (
DataCoordinate
).Methods Summary
from_json
(json_str[, universe, registry])Convert from JSON to a pydantic model.
from_simple
(simple[, universe, registry, ...])Construct a new object from the simplified form.
toDict
([splitTimespan])Return a vanilla
dict
representation of this record.to_json
([minimal])Convert this class to JSON assuming that the
to_simple()
returns a pydantic model.to_simple
([minimal])Convert this class to a simple python type.
Attributes Documentation
- dataId: DataCoordinate¶
A dict-like identifier for this record’s primary keys (
DataCoordinate
).
Methods Documentation
- classmethod from_json(json_str: str, universe: DimensionUniverse | None = None, registry: Registry | None = None) SupportsSimple ¶
Convert from JSON to a pydantic model.
- Parameters:
- cls_
type
ofSupportsSimple
The Python type being created.
- json_str
str
The JSON string representing this object.
- universe
DimensionUniverse
orNone
, optional The universe required to instantiate some models. Required if
registry
isNone
.- registry
Registry
orNone
, optional Registry from which to obtain the dimension universe if an explicit universe has not been given.
- cls_
- Returns:
- model
SupportsSimple
Pydantic model constructed from JSON and validated.
- model
- classmethod from_simple(simple: SerializedDimensionRecord, universe: DimensionUniverse | None = None, registry: Registry | None = None, cacheKey: Hashable | None = None) DimensionRecord ¶
Construct a new object from the simplified form.
This is generally data returned from the
to_simple
method.- Parameters:
- simple
SerializedDimensionRecord
Value return from
to_simple
.- universe
DimensionUniverse
The special graph of all known dimensions of which this graph will be a subset. Can be
None
ifRegistry
is provided.- registry
lsst.daf.butler.Registry
, optional Registry from which a universe can be extracted. Can be
None
if universe is provided explicitly.- cacheKey
Hashable
orNone
If this is not None, it will be used as a key for any cached reconstruction instead of calculating a value from the serialized format.
- simple
- Returns:
- record
DimensionRecord
Newly-constructed object.
- record
- toDict(splitTimespan: bool = False) dict[str, Any] ¶
Return a vanilla
dict
representation of this record.
- to_json(minimal: bool = False) str ¶
Convert this class to JSON assuming that the
to_simple()
returns a pydantic model.- Parameters:
- minimal
bool
Return minimal possible representation.
- minimal
- to_simple(minimal: bool = False) SerializedDimensionRecord ¶
Convert this class to a simple python type.
This makes it suitable for serialization.