exopy.measurement.measurement module¶
Main objects used to represent all the aspects of a measurement (main task, attached tools, dependencies, …)
-
class
exopy.measurement.measurement.
MeasurementDependencies
[source]¶ Bases:
atom.atom.Atom
Container used to store the dependencies of a measurement.
-
measurement
¶ Reference to the Measurement this object is linked to.
-
collect_runtimes
()[source]¶ Collect all the runtime needed to execute the measurement.
Those can then be accessed using get_runtime_dependencies
- Returns
result (bool) – Boolean indicating whether or not the collection succeeded. Note that even if the collection failed, some dependencies may have been collected (other being unavailable) and must hence be released.
msg (unicode) – String explaning why the operation failed if it failed.
errors (dict) – Dictionary describing in details the errors. If some dependencies does exist but cannot be accessed at the time of the query an entry ‘unavailable’ will be present.
-
get_build_dependencies
()[source]¶ Get the build dependencies associated with the main task.
- Returns
dependencies – BuildContainer as returned by ‘exopy.app.dependencies.collect’. The errors member should be checked to detect errors.
- Return type
-
get_runtime_dependencies
(id)[source]¶ Access the runtime dependencies associated with a hook or the main task
- Parameters
id (unicode) – Id of the hook for which to retrieve the runtimes or ‘main’ for the main task.
- Returns
dependencies – Dependencies for the requested measurement component.
- Return type
- Raises
RuntimeError : – Raised if this method is called before collect_runtimes.
-
-
class
exopy.measurement.measurement.
Measurement
(**kwargs)[source]¶ Bases:
exopy.utils.atom_util.HasPrefAtom
Object representing all the aspects of a measurement.
-
name
¶ Name of the measurement.
-
id
¶ Id of that particular iteration of the measurement. This value is used when saving the measurement before running it. It is also communicated to the root task
-
status
¶ Current measurement status.
-
infos
¶ Detailed information about the measurement status.
-
path
¶ Path to the last file in which that measurement was saved.
-
root_task
¶ Root task holding the measurement logic.
-
monitors
¶ Dict of active monitor for this measurement.
-
pre_hooks
¶ Dict of pre-measurement execution routines.
-
post_hooks
¶ Dict of post-measurement execution routines.
-
plugin
¶ Reference to the measurement plugin managing this measurement.
-
forced_enqueued
¶ Flag signaling whether the user chose to enqueue the measurement knowing some tests are failing.
-
dependencies
¶ Object handling the collection and access to the measurement dependencies.
-
task_execution_result
¶ Result object returned by the engine when the root_task has been executed. Can be used by post-execution hook to adapt their behavior.
-
save
(path)[source]¶ Save the measurement as a ConfigObj object.
- Parameters
path (unicode) – Path of the file to which save the measurement.
-
classmethod
load
(measurement_plugin, path, build_dep=None)[source]¶ Build a measurement from a ConfigObj file.
- Parameters
measurement_plugin (MeasurementPlugin) – Instance of the MeasurementPlugin storing all declarations.
path (unicode) – Path of the file from which to load the measurement.
build_dep (dict, optional) – Build dependencies of the main task.
- Returns
measurement (Measurement | None) – Measurement buil from the config or None if and error occurred.
errors (dict) – Dictionary describing the errors that occured.
-
run_checks
(**kwargs)[source]¶ Run all measurement checks.
This is done at enqueueing time and before actually executing a measurement save it it was forcibly enqueued. The dependencies needs to be collected before calling this method.
- Parameters
**kwargs – Keyword arguments to pass to the pre-operations.
- Returns
result (bool) – Boolean indicating whether or not the operations succeeded.
report (dict) – Dict storing the errors (as dict) by id of the operation in which they occured.
-
add_tool
(kind, id, tool=None)[source]¶ Add a tool to the measurement.
Newly added tools are always appended to the list of existing ones.
- Parameters
kind ({'monitor', 'pre-hook', 'post-hook'}) – Kind of tool being added to the measurement.
id (unicode) – Id of the tool being added.
tool (MeasureTool, optional) – Tool being added, if not specified a new instance will be created.
-