Job Dependency Solver.
plainbox.impl.depmgr
¶
Warning
THIS MODULE DOES NOT HAVE STABLE PUBLIC API
-
class
plainbox.impl.depmgr.
Color
[source]¶ Bases:
plainbox.vendor.enum.Enum
Three classic colors for recursive graph visitor.
- WHITE:
- For nodes have not been visited yet.
- GRAY:
- For nodes that are currently being visited but the visit is not complete.
- BLACK:
- For nodes that have been visited and are complete.
-
BLACK
= <Color.BLACK: 'black'>¶
-
GRAY
= <Color.GRAY: 'gray'>¶
-
WHITE
= <Color.WHITE: 'white'>¶
-
exception
plainbox.impl.depmgr.
DependencyCycleError
(job_list)[source]¶ Bases:
plainbox.impl.depmgr.DependencyError
Exception raised when a cyclic dependency is detected.
-
affected_job
¶ job that is affected by the dependency error.
Here it is the job that has a cyclic dependency on itself.
-
affecting_job
¶ job that is affecting the
affected_job
.Here it’s always the same as
affected_job
-
args
¶
-
with_traceback
()¶ Exception.with_traceback(tb) – set self.__traceback__ to tb and return self.
-
-
exception
plainbox.impl.depmgr.
DependencyDuplicateError
(job, duplicate_job)[source]¶ Bases:
plainbox.impl.depmgr.DependencyError
Exception raised when two jobs have the same id.
-
affected_job
¶ job that is affected by the dependency error.
Here it is the job that is already known by the system.
-
affecting_job
¶ job that is affecting the
affected_job
.Here it is the job that is clashing with another job already present in the system.
-
args
¶
-
with_traceback
()¶ Exception.with_traceback(tb) – set self.__traceback__ to tb and return self.
-
-
exception
plainbox.impl.depmgr.
DependencyError
[source]¶ Bases:
Exception
Exception raised when a dependency error is detected.
-
affected_job
¶ job that is affected by the dependency error.
-
affecting_job
¶ job that is affecting the
affected_job
.This may be None in certain cases (eg, when the job does not exist and is merely referred to by id). If this job exists removing it SHOULD fix this problem from occurring.
This may be the same as
affected_job
-
args
¶
-
with_traceback
()¶ Exception.with_traceback(tb) – set self.__traceback__ to tb and return self.
-
-
exception
plainbox.impl.depmgr.
DependencyMissingError
(job, missing_job_id, dep_type)[source]¶ Bases:
plainbox.impl.depmgr.DependencyError
Exception raised when a job has an unsatisfied dependency.
-
DEP_TYPE_DIRECT
= 'direct'¶
-
DEP_TYPE_RESOURCE
= 'resource'¶
-
affected_job
¶ job that is affected by the dependency error.
Here it is the job that has a missing dependency.
-
affecting_job
¶ job that is affecting the
affected_job
.Here it is always None as we have not seen this job at all and that’s what’s causing the problem in the first place.
-
args
¶
-
with_traceback
()¶ Exception.with_traceback(tb) – set self.__traceback__ to tb and return self.
-
-
class
plainbox.impl.depmgr.
DependencySolver
(job_list)[source]¶ Bases:
object
Dependency solver for Jobs.
Uses a simple depth-first search to discover the sequence of jobs that can run. Use the resolve_dependencies() class method to get the solution.
-
COLOR_BLACK
= <Color.BLACK: 'black'>¶
-
COLOR_GRAY
= <Color.GRAY: 'gray'>¶
-
COLOR_WHITE
= <Color.WHITE: 'white'>¶
-
classmethod
resolve_dependencies
(job_list, visit_list=None)[source]¶ Solve the dependency graph expressed as a list of job definitions.
Parameters: The visit_list, if specified, allows to consider only a part of the graph while still having access and knowledge of all jobs.
Returns list: the solution (a list of jobs to execute in order)
Raises: - DependencyDuplicateError – if a duplicate job definition is present
- DependencyCycleError – if a cyclic dependency is present.
- DependencyMissingErorr – if a required job does not exist.
-
-
exception
plainbox.impl.depmgr.
DependencyUnknownError
(job)[source]¶ Bases:
plainbox.impl.depmgr.DependencyError
Exception raised when an unknown job is mentioned.
Note
This class differs from
DependencyMissingError
in that the unknown job is not a dependency of anything. It can only happen when the job is explicitly mentioned in the list of jobs to visit.-
affected_job
¶ job that is affected by the dependency error.
Here it’s a job that on the
visit_list
but not on thejob_list
.
-
affecting_job
¶ job that is affecting the
affected_job
.Here, it is always None.
-
args
¶
-
with_traceback
()¶ Exception.with_traceback(tb) – set self.__traceback__ to tb and return self.
-