Metadata

class lsst.verify.Metadata(measurement_set, data=None)

Bases: lsst.verify.jsonmixin.JsonSerializationMixin

Container for verification framework job metadata.

Metadata are key-value terms. Both keys and values should be JSON-serializable.

Parameters:
measurement_set : lsst.verify.MeasurementSet, optional

When provided, metadata with keys prefixed by metric names are deferred to Metadata instances attached to measurements (lsst.verify.Measurement.notes).

data : dict, optional

Dictionary to seed metadata.

Attributes Summary

json A dict that can be serialized as semantic SQUASH JSON.

Methods Summary

items() Iterate over key-value metadata pairs.
jsonify_dict(d) Recursively build JSON-renderable objects on all values in a dict.
keys() Get a list of metadata keys.
update(data) Update metadata with key-value pairs from a dict-like object.
write_json(filepath) Write JSON to a file.

Attributes Documentation

json

A dict that can be serialized as semantic SQUASH JSON.

Keys in the dict are metadata keys (see Metadata.keys). Values are the associated metadata values as JSON-serializable objects.

Methods Documentation

items()

Iterate over key-value metadata pairs.

Yields:
item : tuple

A metadata item is a tuple of:

  • Key (str).
  • Value (object).
static jsonify_dict(d)

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

Parameters:
d : dict

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

Returns:
json_dict : dict

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 a list of metadata keys.

Returns:
keys : list of str

These keys keys can be used to access metadata values (like a dict).

update(data)

Update metadata with key-value pairs from a dict-like object.

Parameters:
data : dict-like

The data object needs to provide an items method to iterate over its key-value pairs. If this Metadata instance already has a key, the value will be overwritten with the value from data.

write_json(filepath)

Write JSON to a file.

Parameters:
filepath : str

Destination file name for JSON output.