ButlerLogRecords

class lsst.daf.butler.ButlerLogRecords(root: RootModelRootType = PydanticUndefined)

Bases: _ButlerLogRecords

Class representing a collection of ButlerLogRecord.

Attributes Summary

log_format

model_config

Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].

model_fields

Metadata about the fields defined on the model, mapping of field names to [FieldInfo][pydantic.fields.FieldInfo].

Methods Summary

append(value)

clear()

extend(records)

from_file(filename)

Read records from file.

from_raw(serialized)

Parse raw serialized form and return records.

from_records(records)

Create collection from iterable.

from_stream(stream)

Read records from I/O stream.

insert(index, value)

model_post_init(__context)

This function is meant to behave like a BaseModel method to initialise private attributes.

pop([index])

reverse()

set_log_format(format)

Set the log format string for these records.

Attributes Documentation

log_format
model_config: ClassVar[ConfigDict] = {}

Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].

model_fields: ClassVar[dict[str, FieldInfo]] = {'root': FieldInfo(annotation=list[ButlerLogRecord], required=True)}

Metadata about the fields defined on the model, mapping of field names to [FieldInfo][pydantic.fields.FieldInfo].

This replaces Model.__fields__ from Pydantic V1.

Methods Documentation

append(value: LogRecord | ButlerLogRecord) None
clear() None
extend(records: Iterable[LogRecord | ButlerLogRecord]) None
classmethod from_file(filename: str) ButlerLogRecords

Read records from file.

Parameters:
filenamestr

Name of file containing the JSON records.

Notes

Works with one-record-per-line format JSON files and a direct serialization of the Pydantic model.

classmethod from_raw(serialized: str | bytes) ButlerLogRecords

Parse raw serialized form and return records.

Parameters:
serializedbytes or str

Either the serialized JSON of the model created using .model_dump_json() or a streaming format of one JSON ButlerLogRecord per line. This can also support a zero-length string.

classmethod from_records(records: Iterable[ButlerLogRecord]) ButlerLogRecords

Create collection from iterable.

Parameters:
recordsiterable of ButlerLogRecord

The records to seed this class with.

classmethod from_stream(stream: IO) ButlerLogRecords

Read records from I/O stream.

Parameters:
streamtyping.IO

Stream from which to read JSON records.

Notes

Works with one-record-per-line format JSON files and a direct serialization of the Pydantic model.

insert(index: int, value: LogRecord | ButlerLogRecord) None
model_post_init(__context: Any) None

This function is meant to behave like a BaseModel method to initialise private attributes.

It takes context as an argument since that’s what pydantic-core passes when calling it.

Args:

self: The BaseModel instance. __context: The context.

pop(index: int = -1) ButlerLogRecord
reverse() None
set_log_format(format: str | None) str | None

Set the log format string for these records.

Parameters:
formatstr, optional

The new format string to use for converting this collection of records into a string. If None the default format will be used.

Returns:
old_formatstr, optional

The previous log format.