SpecificationSet¶
-
class
lsst.verify.SpecificationSet(specifications=None, partials=None)[source]¶ Bases:
lsst.verify.jsonmixin.JsonSerializationMixinA collection of
Specifications.Parameters: specifications :
listortupleofSpecificationinstancesA sequence of
Specification-type instances.partials :
listortupleofSpecificationPartialinstancesA sequence of
SpecificationPartialinstances. These partials can be used as bases for specification definitions.Attributes Summary
jsonMethods Summary
deserialize([specifications])Deserialize a specification set from a JSON serialization. insert(spec)Insert a Specificationinto the set.items()Iterate over name, specification pairs. jsonify_dict(d)Recursively build JSON-renderable objects on all values in a dict. keys()Get a sequence of specification names, which are keys to the set. load_metrics_package([package_name_or_path, ...])Create a SpecificationSetfrom an Verification Framework metrics package.load_single_package(package_specs_dirname)Create a SpecificationSetfrom a filesystem directory containing specification YAML files for a single package.report(measurements[, name, meta, ...])Create a report that details specification tests against the given measurements. resolve_document(spec_doc)Resolve inherited properties in a specification document using specifications available in the repo. subset([name, meta, spec_tags, metric_tags, ...])Create a new SpecificationSetwith specifications belonging to a single package or metric, and that apply to the given metadata.update(other)Merge another SpecificationSetinto this one.write_json(filepath)Write JSON to a file. Attributes Documentation
-
json¶
Methods Documentation
-
classmethod
deserialize(specifications=None)[source]¶ Deserialize a specification set from a JSON serialization.
Parameters: specifications :
list, optionalList of specification JSON objects.
Returns: spec_set :
SpecificationSetSpecificationSetinstance.
-
insert(spec)[source]¶ Insert a
Specificationinto the set.A pre-existing specification with the same name is replaced.
Parameters: spec :
Specification-typeA specification.
-
items()[source]¶ Iterate over name, specification pairs.
Yields: item :
tupleTuple containing:
Nameof the specification.Specification-type object.
-
jsonify_dict(d)¶ Recursively build JSON-renderable objects on all values in a dict.
Parameters: d :
dictDictionary to convert into a JSON-serializable object. Values are recursively JSON-ified.
Returns: json_dict :
dictDictionary 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()[source]¶ Get a sequence of specification names, which are keys to the set.
Returns: keys : sequence of
NameKeys to the specification set.
-
classmethod
load_metrics_package(package_name_or_path='verify_metrics', subset=None)[source]¶ Create a
SpecificationSetfrom an Verification Framework metrics package.Parameters: package_name_or_path :
str, optionalName of an EUPS package that hosts metric and specification definition YAML files or the file path to a metrics package.
verify_metricsis the default package, and is where metrics and specifications are defined for most packages.subset :
str, optionalIf set, only specifications defined for this package are loaded. For example, if
subset='validate_drp', onlyvalidate_drpspecifications are included in the SpecificationSet. This argument is equivalent to theSpecificationSet.subsetmethod. Default isNone.Returns: spec_set :
SpecificationSetA
SpecificationSetcontainingSpecificationinstances.Notes
EUPS packages that host metrics and specification definitions for the Verification Framework have top-level directories named
'metrics'and'specs'.Within
'specs/', directories are named after packages that have defined metrics. Contained within these directories are YAML files defining specifications for those metrics.To make a
SpecificationSetfrom a single package’s YAML definition directory that is not contained in a metrics package, useload_single_packageinstead.
-
classmethod
load_single_package(package_specs_dirname)[source]¶ Create a
SpecificationSetfrom a filesystem directory containing specification YAML files for a single package.Parameters: package_specs_dirname :
strDirectory containing specification definition YAML files for metrics of a single package. The name of this directory (final path component) is taken as the name of the package.
Returns: spec_set :
SpecificationSetA
SpecificationSetcontainingSpecificationinstances.Notes
This SpecificationSet constructor is useful for loading specifications from a directory containing specification definitions for a single package. The directory name is interpreted as a package name for fully-qualified metric and specification names.
To load a Verification Framework metrics package, like
verify_metrics, with specifications for multple packages, useload_metrics_packgeinstead.
-
report(measurements, name=None, meta=None, spec_tags=None, metric_tags=None, metrics=None)[source]¶ Create a report that details specification tests against the given measurements.
Parameters: measurements :
lsst.verify.MeasurementSetMeasurements to test.
name :
strorlsst.verify.Name, optionalA package or metric name to subset specifications by. When set, only measurement and specification combinations belonging to that package or metric are included in the report.
meta :
lsst.verifify.Metadata, optionalJob metadata to ensure the specifications are relevant to the measurements. Typically accessed as
Job.meta.spec_tags : sequence of
str, optionalA set of specification tag strings. when given, only specifications that have all the given tags are included in the report. For example,
spec_tags=['LPM-17', 'minimum'].metric_tags : sequence of
str, optionalA set of metric tag strings. When given, only specifications belonging to metrics that posess all given tags are included in the report. For example,
metric_tags=['LPM-17', 'photometry']selects sepifications that have both the'LPM-17'and'photometry'tags. If set, also provide alsst.verify.MetricSetwith themetricsargument.metrics :
lsst.verify.MetricSetMetricSetwith metric definitions. This is only needed if ametric_tagsargument is provided.Returns: report :
lsst.verify.ReportReport instance. In a Jupyter notebook, you can view the report by calling
Report.show.See also
-
resolve_document(spec_doc)[source]¶ Resolve inherited properties in a specification document using specifications available in the repo.
Parameters: spec_doc :
dictA specification document. A document is typically either a YAML document, where the specification is defined, or a JSON object that was serialized from a
Specificationinstance.Returns: spec_doc :
OrderedDictThe specification document is returned with bases resolved.
Raises: SpecificationResolutionError
Raised when a document’s bases cannot be resolved (an inherited
Specificationcannot be found in the repo).
-
subset(name=None, meta=None, spec_tags=None, metric_tags=None, metrics=None)[source]¶ Create a new
SpecificationSetwith specifications belonging to a single package or metric, and that apply to the given metadata.Parameters: name :
strorlsst.verify.Name, optionalName to subset specifications by. If this is the name of a package, then all specifications for that package are included in the subset. If this is a metric name, then only specifications for that metric are included in the subset. The metric name must be fully-qualified (that is, it includes a package component).
meta :
lsst.verify.Metadata, optionalspec_tags : sequence of
str, optionalA set of specification tag strings. when given, only specifications that have all the given tags are included in the report. For example,
spec_tags=['LPM-17', 'minimum'].metric_tags : sequence of
str, optionalA set of metric tag strings. When given, only specifications belonging to metrics that posess all given tags are included in the report. For example,
metric_tags=['LPM-17', 'photometry']selects sepifications that have both the'LPM-17'and'photometry'tags. If set, also provide alsst.verify.MetricSetwith themetricsargument.metrics :
lsst.verify.MetricSetMetricSetwith metric definitions. This is only needed if ametric_tagsargument is provided.Returns: spec_subset :
SpecificationSetSubset of this
SpecificationSetcontaining only specifications belonging to the indicated package or metric, and/or that are compatible with the job metadata.. Any partials in the SpecificationSet are also included inspec_subset.
-
update(other)[source]¶ Merge another
SpecificationSetinto this one.Parameters: other :
SpecificationSetAnother
SpecificationSet.Specifications inotherthat do not exist in this set are added to this one.Specifications inotherreplace specifications of the same name in this one.
-