Bases: builtins.object
Session context specific to a given device.
This class exposes access to a “world view” unique to a specific device. The view is composed of the following attributes:
Attr _provider_list: | |
---|---|
A list of providers known by this device. All of those providers are compatible with the device. | |
Attr _unit_list: | |
A list of all the units known by this device. Initially it is idenitcal to the union of all the units from _provider_list but it is in fact mutable and can be grown (or shrunk in some cases) when jobs are created at runtime. | |
Attr _test_plan_list: | |
A list of test plans that this device will be executing. This is stored so that all job changes can automatically apply field overrides to job state. | |
Attr _device: | Always None, this is a future extension point |
Attr _state: | A SessionState object that holds all of the job results and also exposes some legacy API for computing the run list and the desired job list |
Add a provider to the context
Parameters: |
|
---|---|
Raises ValueError: | |
If the provider is already in the context |
This method can be used to add a provider to the context. It also adds all of the units of that provider automatically.
Note
This method fires the on_provider_added() signal but it does so before any of the units from that provider are added.
Add a unit to the context
Parameters: | unit – The Unit to add. |
---|---|
Raises ValueError: | |
If the unit is already in the context |
This method can be used to register both the initially-known units as well as units generated at runtime.
This method fires the on_unit_added() signal
Compute a shared helper.
Parameters: |
|
---|---|
Returns: | Return value of func(self, *args, **kwargs) (possibly computed earlier). |
Compute something that can be shared by all users of the device context This allows certain expensive computations to be performed only once.
Note
The caller is responsible for ensuring that args and kwargs match the cache_key each time this function is called.
The device associated with this context.
Warning
Currently this method will always return None. In the future it will return an object that describes the device.
A list of execution controllers applicable in this context.
Returns: | A list of IExecutionController objects |
---|
Note
The return value is different whenever a provider is added to the context. If you have obtained this value in the past it may be no longer accurate.
Get the execution controller most applicable to run this job
Parameters: | job – A job definition to run |
---|---|
Returns: | An execution controller instance |
Raises LookupError: | |
if no execution controller capable of running the specified job can be found |
The best controller is the controller that has the highest score (as computed by :meth:`IExecutionController.get_score()) for the job in question.
Basic signal that supports arbitrary listeners.
While this class can be used directly it is best used with the helper decorator Signal.define on a function or method. See the documentation for the plainbox.vendor.morris module for details.
Attr _name: | Name of the signal, typically accessed via name(). |
---|---|
Attr _listeners: | |
List of signal listeners. Each item is a tuple (listener, pass_signal) that encodes how to call the listener. |
Basic signal that supports arbitrary listeners.
While this class can be used directly it is best used with the helper decorator Signal.define on a function or method. See the documentation for the plainbox.vendor.morris module for details.
Attr _name: | Name of the signal, typically accessed via name(). |
---|---|
Attr _listeners: | |
List of signal listeners. Each item is a tuple (listener, pass_signal) that encodes how to call the listener. |
Basic signal that supports arbitrary listeners.
While this class can be used directly it is best used with the helper decorator Signal.define on a function or method. See the documentation for the plainbox.vendor.morris module for details.
Attr _name: | Name of the signal, typically accessed via name(). |
---|---|
Attr _listeners: | |
List of signal listeners. Each item is a tuple (listener, pass_signal) that encodes how to call the listener. |
Basic signal that supports arbitrary listeners.
While this class can be used directly it is best used with the helper decorator Signal.define on a function or method. See the documentation for the plainbox.vendor.morris module for details.
Attr _name: | Name of the signal, typically accessed via name(). |
---|---|
Attr _listeners: | |
List of signal listeners. Each item is a tuple (listener, pass_signal) that encodes how to call the listener. |
A list of execution controllers applicable in this context.
Returns: | A list of IExecutionController objects |
---|
Note
The return value is different whenever a provider is added to the context. If you have obtained this value in the past it may be no longer accurate.
The list of providers currently available in this context.
Note
You must not modify the return value.
This is not enforced but please use the add_provider() method if you want to add a provider. Currently you cannot remove providers or reorder the list of providers.
Remove an unit from the context
Parameters: | unit – The Unit to remove. |
---|
This method fires the on_unit_removed() signal
Compute all of the effective job state values.
Parameters: | test_plan_list – The list of test plans to consider |
---|
This method is intended to be called exactly once per session, after the application determines the set of test plans it intends to execute.
The method will collect all of the override values expoxed by all of the test plans and apply them in sequence. Note that correct applications must also pefrorm micro-updates whenever a new test job is added to the system.
The session state object associated with this context.
Note
You can use both the session state and the session device context to query and monitor the changes to all the participating units
The list of units currently available in this context.
Note
You must not modify the return value.
This is not enforced but please use the add_unit() or remove_unit() if you want to manipulate the list. Currently you cannot reorder the list of units.
Bases: builtins.object
Class representing non-critical state of the session.
The data held here allows applications to reason about sessions in general but is not relevant to the runner or the core in general
Custom, application specific binary blob.
The type and value of this property is irrelevant as it is not inspected by plainbox at all. Reasonable applications will not make use of this property for storing large amounts of data. If you are tempted to do that, please redesign your application or propose changes to plainbox.
Application identifier
A string identifying the application that stored app_blob. It is recommended to use reverse domain names or UUIDs.
a set of flags that are associated with this session.
This set is persisted by persistent_save() and can be used to keep track of how the application wants to interpret this session state.
Intended usage is to keep track of “testing finished” and “results submitted” flags. Some flags are added as constants to this class.
id of the running job
Note
This property has a confusing name. It actually refers to job ID, not name.
This property should be updated to keep track of the name of the job that is being executed. When either plainbox or the machine it was running on crashes during the execution of a job this value should be preserved and can help the GUI to resume and provide an error message.
The property MUST be set before starting the job itself.
Bases: builtins.object
Class representing all state needed during a single program session.
This is the central glue/entry-point for applications. It connects user intents to the rest of the system / plumbing and keeps all of the state in one place.
The set of utility methods and properties allow applications to easily handle the lower levels of dependencies, resources and ready states.
SessionState has the following instance variables, all of which are currently exposed as properties.
Variables: |
|
---|
Add a new job to the session
Parameters: |
|
---|---|
Returns: | The job that was actually added or an existing, identical job if a perfect clash was silently ignored. |
Raises DependencyDuplicateError: | |
if a duplicate, clashing job definition is detected |
The new_job gets added to all the state tracking objects of the session. The job is initially not selected to run (it is not in the desired_job_list and has the undesired inhibitor).
The new_job may clash with an existing job with the same id. Unless both jobs are identical this will cause DependencyDuplicateError to be raised. Identical jobs are silently discarded.
Note
This method recomputes job readiness for all jobs
Deprecated since version 0.9: use the add_unit() method instead
Add a new unit to the session
Parameters: |
|
---|---|
Returns: | The unit that was actually added or an existing, identical unit if a perfect clash was silently ignored. |
Raises DependencyDuplicateError: | |
if a duplicate, clashing job definition is detected |
Note
The following applies only to newly added job units:
The new_unit gets added to all the state tracking objects of the session. The job unit is initially not selected to run (it is not in the desired_job_list and has the undesired inhibitor).
The new_unit job may clash with an existing job with the same id. Unless both jobs are identical this will cause DependencyDuplicateError to be raised. Identical jobs are silently discarded.
Note
This method recomputes job readiness for all jobs unless the recompute=False argument is used. Recomputing takes a while so if you want to add a lot of units consider setting that to False and only recompute at the last call.
List of jobs that are on the “desired to run” list
This is a list, not a set, because the dependency solver algorithm retains as much of the original ordering as possible. Having said that, the actual order can differ widely (for instance, be reversed)
Provide the estimated duration of the jobs that have been selected to run in this session (maintained by calling update_desired_job_list).
Manual jobs have an arbitrary figure added to their runtime to allow for execution of the test steps and verification of the result.
Returns: | (estimate_automated, estimate_manual) |
---|
where estimate_automated is the value for automated jobs only and estimate_manual is the value for manual jobs only. These can be easily combined. Either value can be None if the value could not be calculated due to any job lacking the required estimated_duration field.
List of all known jobs.
Not necessarily all jobs from this list can be, or are desired to run. For API simplicity this variable is read-only, if you wish to alter the list of all jobs re-instantiate this class please.
Basic signal that supports arbitrary listeners.
While this class can be used directly it is best used with the helper decorator Signal.define on a function or method. See the documentation for the plainbox.vendor.morris module for details.
Attr _name: | Name of the signal, typically accessed via name(). |
---|---|
Attr _listeners: | |
List of signal listeners. Each item is a tuple (listener, pass_signal) that encodes how to call the listener. |
Basic signal that supports arbitrary listeners.
While this class can be used directly it is best used with the helper decorator Signal.define on a function or method. See the documentation for the plainbox.vendor.morris module for details.
Attr _name: | Name of the signal, typically accessed via name(). |
---|---|
Attr _listeners: | |
List of signal listeners. Each item is a tuple (listener, pass_signal) that encodes how to call the listener. |
Basic signal that supports arbitrary listeners.
While this class can be used directly it is best used with the helper decorator Signal.define on a function or method. See the documentation for the plainbox.vendor.morris module for details.
Attr _name: | Name of the signal, typically accessed via name(). |
---|---|
Attr _listeners: | |
List of signal listeners. Each item is a tuple (listener, pass_signal) that encodes how to call the listener. |
Basic signal that supports arbitrary listeners.
While this class can be used directly it is best used with the helper decorator Signal.define on a function or method. See the documentation for the plainbox.vendor.morris module for details.
Attr _name: | Name of the signal, typically accessed via name(). |
---|---|
Attr _listeners: | |
List of signal listeners. Each item is a tuple (listener, pass_signal) that encodes how to call the listener. |
Basic signal that supports arbitrary listeners.
While this class can be used directly it is best used with the helper decorator Signal.define on a function or method. See the documentation for the plainbox.vendor.morris module for details.
Attr _name: | Name of the signal, typically accessed via name(). |
---|---|
Attr _listeners: | |
List of signal listeners. Each item is a tuple (listener, pass_signal) that encodes how to call the listener. |
Basic signal that supports arbitrary listeners.
While this class can be used directly it is best used with the helper decorator Signal.define on a function or method. See the documentation for the plainbox.vendor.morris module for details.
Attr _name: | Name of the signal, typically accessed via name(). |
---|---|
Attr _listeners: | |
List of signal listeners. Each item is a tuple (listener, pass_signal) that encodes how to call the listener. |
Remove an existing unit from the session
Parameters: |
|
---|
Note
This method recomputes job readiness for all jobs unless the recompute=False argument is used. Recomputing takes a while so if you want to add a lot of units consider setting that to False and only recompute at the last call.
List of jobs that were intended to run, in the proper order
The order is a result of topological sorting of the desired_job_list. This value is recomputed when change_desired_run_list() is called. It may be shorter than desired_run_list due to dependency errors.
Add or change a resource with the given id.
Resources silently overwrite any old resources with the same id.
Discard jobs that are selected by the given qualifier.
Parameters: | qualifier – A qualifier that selects jobs to be removed |
---|---|
Ptype qualifier: | |
IJobQualifier | |
Raises ValueError: | |
If any of the jobs selected by the qualifier is on the desired job list (or the run list) |
This function correctly and safely discards certain jobs from the job list. It also removes the associated job state (and referenced job result) and results (for jobs that were resource jobs)
Update the set of desired jobs (that ought to run)
This method can be used by the UI to recompute the dependency graph. The argument ‘desired_job_list’ is a list of jobs that should run. Those jobs must be a sub-collection of the job_list argument that was passed to the constructor.
It never fails although it may reduce the actual permitted desired_job_list to an empty list. It returns a list of problems (all instances of DependencyError class), one for each job that had to be removed.
Notice the specified test result and update readiness state.
This function updates the internal result collection with the data from the specified test result. Results can safely override older results. Results also change the ready map (jobs that can run) because of dependency relations.
Some results have deeper meaning, those are results for local and resource jobs. They are discussed in detail below:
Resource jobs produce resource records which are used as data to run requirement expressions against. Each time a result for a resource job is presented to the session it will be parsed as a collection of RFC822 records. A new entry is created in the resource map (entirely replacing any old entries), with a list of the resources that were parsed from the IO log.
Local jobs produce more jobs. Like with resource jobs, their IO log is parsed and interpreted as additional jobs. Unlike in resource jobs local jobs don’t replace anything. They cannot replace an existing job with the same id.