thoth.adviser.python.dependency_graph.adaptation package

Submodules

thoth.adviser.python.dependency_graph.adaptation.elements module

Elements of dependency graph adaptation.

class thoth.adviser.python.dependency_graph.adaptation.elements.Edge(source: Optional[thoth.adviser.python.dependency_graph.adaptation.elements.Node], target: thoth.adviser.python.dependency_graph.adaptation.elements.Node, score: float = 0.0)[source]

Bases: object

An edge in dependency graph which is weighted (weight is score).

get_edge_key() → Tuple[Optional[Tuple[str, str, str]], Tuple[str, str, str]][source]

Get key which identifies edge.

score
source
target
class thoth.adviser.python.dependency_graph.adaptation.elements.Node(package_tuple: Tuple[str, str, str], incoming_edges: Dict[Optional[str], Dict[Tuple[str, str, str], Edge]] = NOTHING, outgoing_edges: Dict[Optional[str], Dict[Tuple[str, str, str], Edge]] = NOTHING)[source]

Bases: object

A node in constructed dependency graph.

property all_dependency_package_tuples

Iterate over all packages which are dependencies for this node.

property all_dependent_package_tuples

Iterate over all package tuples which depend on this node.

property all_incoming_edges

Iterate over all incoming edges regardless of the source package.

property all_outgoing_edges

Iterate over all outgoing edges regardless of the destination package.

incoming_edges
outgoing_edges
package_tuple

thoth.adviser.python.dependency_graph.adaptation.exceptions module

Exceptions hierarchy for dependency graph adaptation.

exception thoth.adviser.python.dependency_graph.adaptation.exceptions.CannotRemovePackage[source]

Bases: thoth.adviser.python.dependency_graph.adaptation.exceptions.DependencyGraphAdaptationException

Raised if the given package cannot be removed.

exception thoth.adviser.python.dependency_graph.adaptation.exceptions.DependencyGraphAdaptationException[source]

Bases: Exception

A top-class exception in dependency graph hierarchy.

exception thoth.adviser.python.dependency_graph.adaptation.exceptions.PackageNotFound[source]

Bases: thoth.adviser.python.dependency_graph.adaptation.exceptions.DependencyGraphAdaptationException

Raised if the given package cannot be removed.

exception thoth.adviser.python.dependency_graph.adaptation.exceptions.RemoveMultiplePackages[source]

Bases: thoth.adviser.python.dependency_graph.adaptation.exceptions.DependencyGraphAdaptationException

Raised if requested to remove a single package but multiple would be removed.

exception thoth.adviser.python.dependency_graph.adaptation.exceptions.TransactionExpired[source]

Bases: thoth.adviser.python.dependency_graph.adaptation.exceptions.DependencyGraphAdaptationException

Raised if the given transaction has been committed or rolled back.

thoth.adviser.python.dependency_graph.adaptation.graph module

Adaptation of dependency graph based on scoring and package removals.

class thoth.adviser.python.dependency_graph.adaptation.graph.DependencyGraph(packages_map: Dict[Tuple[str, str, str], thoth.adviser.python.dependency_graph.adaptation.elements.Node] = NOTHING, edges_map: Dict[Tuple[Optional[Tuple[str, str, str]], Tuple[str, str, str]], thoth.adviser.python.dependency_graph.adaptation.elements.Edge] = NOTHING, direct_dependencies_map: Dict[Tuple[str, str, str], thoth.adviser.python.dependency_graph.adaptation.elements.Node] = NOTHING, packages_score: Dict[Tuple[str, str, str], float] = NOTHING)[source]

Bases: object

A constructed dependency graph based on paths.

direct_dependencies_map
edges_map
classmethod from_paths(direct_dependencies: List[Tuple[str, str, str]], paths: List[Tuple[Tuple[str, str, str], Tuple[str, str, str]]]) → thoth.adviser.python.dependency_graph.adaptation.graph.DependencyGraph[source]

Construct dependency graph from paths.

iter_direct_dependencies_tuple() → Generator[[Tuple[str, str, str], None], None][source]

Iterate over all direct dependencies.

iter_transitive_dependencies_tuple() → Generator[[Tuple[str, str, str], None], None][source]

Get all transitive dependencies found in dependency graph.

packages_map
packages_score
perform_transaction(to_remove_nodes: List[thoth.adviser.python.dependency_graph.adaptation.elements.Node], to_remove_edges: List[thoth.adviser.python.dependency_graph.adaptation.elements.Edge]) → None[source]

Perform the actual transaction.

remove_package_tuples(*package_tuples: Tuple[str, str, str]) → thoth.adviser.python.dependency_graph.adaptation.transaction.DependencyGraphTransaction[source]

Remove a package from dependency graph, ensure the given package can be removed.

This methods acts as a transaction - if any package from package tuples cannot be removed, it raises an exception and leaves the dependency graph untouched.

score_package_tuple(package_tuple: Tuple[str, str, str], score_adjustment: float) → None[source]

Adjust score of a package tuple in dependency graph to modify its precedence.

sort_paths(comparision_func: Callable[[Tuple[str, str, str], Tuple[str, str, str]], int], reverse: bool = True) → None[source]

Sort paths in the dependency graph.

to_scored_package_tuple_pairs() → List[Tuple[float, Tuple[Optional[Tuple[str, str, str]], Tuple[str, str, str]]]][source]

Construct pairs respecting package dependencies with corresponding score of these dependencies.

thoth.adviser.python.dependency_graph.adaptation.transaction module

Transactional changes in dependency graph.

class thoth.adviser.python.dependency_graph.adaptation.transaction.DependencyGraphTransaction(dependency_graph, to_remove_edges: List[thoth.adviser.python.dependency_graph.adaptation.elements.Edge] = NOTHING, to_remove_nodes: List[thoth.adviser.python.dependency_graph.adaptation.elements.Node] = NOTHING)[source]

Bases: object

A transaction on top of Dependency Graph keeping state.

any_positive_score() → bool[source]

Check if positive score will be affected in this transaction once committed.

commit() → None[source]

Commit the given pending transaction.

dependency_graph
iter_package_tuples() → Generator[[Tuple[str, str, str], None], None][source]

Iterate over package tuples which are about to be removed from dependency graph in this transaction.

rollback() → None[source]

Rollback the given pending transaction.

score_summary() → float[source]

Compute summary for the score that will result in the current transaction.

to_remove_edges
to_remove_nodes

Module contents

Adaptation of dependency graph based on scoring and package removals.