Blob

class lsst.verify.Blob(name, **datums)

Bases: lsst.verify.jsonmixin.JsonSerializationMixin

Blob is a flexible container of data, as lsst.verify.Datum s, that are serializable to JSON.

Parameters
namestr

Name of this type of blob. Blobs from one pipeline Job execution to another that share the same name generally share the same schema of lsst.verify.Datums.

datumsdict of lsst.verify.Datum-types, optional

Keys are names of datums. Values are Datum-types. Each Datum can be later retrived from the Blob instance by key.

Attributes Summary

identifier

Unique UUID4-based identifier for this blob (str).

json

Job data as a JSON-serializable dict.

name

Name of this blob (str).

Methods Summary

deserialize([identifier, name, data])

Deserialize fields from a blob JSON object into a Blob instance.

items()

Get pairs of keys and values in the Blob.

jsonify_dict(d)

Recursively build JSON-renderable objects on all values in a dict.

keys()

Get keys of blob items.

write_json(filepath)

Write JSON to a file.

Attributes Documentation

identifier

Unique UUID4-based identifier for this blob (str).

json

Job data as a JSON-serializable dict.

name

Name of this blob (str).

Methods Documentation

classmethod deserialize(identifier=None, name=None, data=None)

Deserialize fields from a blob JSON object into a Blob instance.

Parameters
identifierstr

Blob identifier.

namestr

Name of the blob type.

datadict

Dictionary of named name: datum object key-value pairs.

Returns
blobBlob

The Blob instance deserialied from a blob JSON object.

Examples

This class method is designed to roundtrip JSON objects created a Blob instance. For example:

>>> import astropy.units as u
>>> blob = Blob('demo')
>>> blob['a_mag'] = Datum(28 * u.mag, label='i')
>>> json_data = blob.json
>>> new_blob = Blob.deserialize(**json_data)
items()

Get pairs of keys and values in the Blob.

Yields
keyvaltuple

Tuple of:

static jsonify_dict(d)

Recursively build JSON-renderable objects on all values in a dict.

Parameters
ddict

Dictionary to convert into a JSON-serializable object. Values are recursively JSON-ified.

Returns
json_dictdict

Dictionary that can be serialized to JSON.

Examples

Subclasses can use this method to prepare output in their json-method implementation. For example:

def json(self):
    return JsonSerializationMixin.jsonify_dict({
        'value': self.value,
    })
keys()

Get keys of blob items.

Returns
keyssequence of str

Sequence of keys to items in the Blob.

write_json(filepath)

Write JSON to a file.

Parameters
filepathstr

Destination file name for JSON output.