Job

class lsst.validate.base.Job(measurements=None, blobs=None)[source]

Bases: lsst.validate.base.jsonmixin.JsonSerializationMixin

A Job wraps all measurements and blob metadata associated with a validation run.

Measurements and blobs can be added both during initialization, or anytime afterwards with the register_measurement and register_blob methods.

The get_measurement method lets you search for a stored measurement based on the Metric name (and filter or specification name, if the measurement is dependent on those).

Use the Job.json attribute to access a json-serializable dict of all measurements and blobs associated with the Job.

A Job can only contain measurements against one dataset at a time. Typically, Jobs are uploaded to SQUASH separately for each tested dataset.

Parameters:

measurements : list, optional

List of MeasurementBase-derived objects. Additional measurements can be added with the register_measurement method.

blobs : list, optional

List of BlobBase-derived objects. Additional blobs can be added with the register_blob method.

Attributes Summary

blobs Blob iterator.
json Job data as a JSON-serialiable dict.
measurements Measurement iterator.
metric_names Names of Metrics measured in this Job (list).
spec_levels list of names of specification levels that are available for

Methods Summary

from_json(json_data) Construct a Job and constituent objects from a JSON dataset.
get_measurement(metric_name[, spec_name, ...]) Get a measurement corresponding to the given criteria.
jsonify_dict(d) Recursively build JSON-renderable objects on all values in a dict.
register_blob(b) Add a blob object to the Job.
register_measurement(m) Add a measurement object to the Job.
write_json(filepath) Write JSON to a file.

Attributes Documentation

blobs

Blob iterator.

json

Job data as a JSON-serialiable dict.

measurements

Measurement iterator.

metric_names

Names of Metrics measured in this Job (list).

spec_levels

list of names of specification levels that are available for Metrics measured in this Job.

Methods Documentation

classmethod from_json(json_data)[source]

Construct a Job and constituent objects from a JSON dataset.

Parameters:

json_data : dict

Job JSON object (as produced by json).

Returns:

job : Job-type

Job from JSON.

get_measurement(metric_name, spec_name=None, filter_name=None)[source]

Get a measurement corresponding to the given criteria.

Parameters:

metric_name : str

Name of the Metric for the requested measurement.

spec_name : str, optional

Name of the specification level if the measurement algorithm is dependent on the specification level of a metric.

filter_name : str, optional

Name of the optical filter if the measurement is specific to a filter.

Returns:

measurement : MeasurementBase-type object

The single measurement instance that fulfills the search criteria.

Raises:

RuntimeError

Raised when a measurement cannot be found, either because no such measurement exists or because the request is ambiguous (spec_name or filter_name need to be set).

jsonify_dict(d)

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

Parameters:

d : dict

Dictionary ito 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,
    })
register_blob(b)[source]

Add a blob object to the Job.

Parameters:

b : BlobBase-type object

A blob object.

register_measurement(m)[source]

Add a measurement object to the Job.

Registering a measurement also automatically registers all linked blobs.

Parameters:

m : MeasurementBase-type object

A measurement object.

write_json(filepath)

Write JSON to a file.

Parameters:

filepath : str

Destination file name for JSON output.