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
andregister_blob
methods.The
get_measurement
method lets you search for a stored measurement based on theMetric
name (and filter or specification name, if the measurement is dependent on those).Use the
Job.json
attribute to access a json-serializabledict
of all measurements and blobs associated with theJob
.A
Job
can only contain measurements against one dataset at a time. Typically,Job
s are uploaded to SQUASH separately for each tested dataset.Parameters: measurements :
list
, optionalList of
MeasurementBase
-derived objects. Additional measurements can be added with theregister_measurement
method.blobs :
list
, optionalList of
BlobBase
-derived objects. Additional blobs can be added with theregister_blob
method.Attributes Summary
blobs
Blob iterator. json
Job
data as a JSON-serialiabledict
.measurements
Measurement iterator. metric_names
Names of Metric
s measured in thisJob
(list
).spec_levels
list
of names of specification levels that are available forMethods 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.
-
measurements
¶ Measurement iterator.
-
spec_levels
¶ list
of names of specification levels that are available forMetric
s measured in thisJob
.
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
-typeJob 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
, optionalName of the specification level if the measurement algorithm is dependent on the specification level of a metric.
filter_name :
str
, optionalName of the optical filter if the measurement is specific to a filter.
Returns: measurement :
MeasurementBase
-type objectThe 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
orfilter_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 objectA 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 objectA measurement object.
-