thoth.adviser.python package

Subpackages

Submodules

thoth.adviser.python.advise module

Recommendation engine based on scoring of a software stack.

class thoth.adviser.python.advise.Adviser(count: int = None, limit: int = None, recommendation_type: thoth.adviser.enums.RecommendationType = <RecommendationType.STABLE: 1>, computed_stacks_heap: thoth.common.config.runtime_environment.RuntimeEnvironment = NOTHING, visited: int = 0)[source]

Bases: object

Implementation of adviser - the core of recommendation engine in Thoth.

compute(graph: thoth.storages.graph.postgres.GraphDatabase, project: thoth.python.project.Project, limit_latest_versions: int = None, library_usage: dict = None) → Tuple[Tuple[List[Tuple[Dict, thoth.python.project.Project, float]], List[Dict]], Dict][source]

Compute recommendations for the given project.

classmethod compute_on_project(project: thoth.python.project.Project, *, recommendation_type: thoth.adviser.enums.RecommendationType, library_usage: dict = None, count: int = None, limit: int = None, limit_latest_versions: int = None, graph: thoth.storages.graph.postgres.GraphDatabase = None) → tuple[source]

Compute recommendations for the given project, a syntax sugar for the compute method.

compute_using_pipeline(pipeline: thoth.adviser.python.pipeline.pipeline.Pipeline) → Tuple[List[Tuple[Dict, thoth.python.project.Project, float]], List[Dict]][source]

Compute recommendations using a custom pipeline configuration.

count
limit
recommendation_type

thoth.adviser.python.builder module

Dynamic constructor of stack generation pipeline.

class thoth.adviser.python.builder.PipelineBuilder(graph: thoth.storages.graph.postgres.GraphDatabase, project: thoth.python.project.Project, library_usage: dict = None)[source]

Bases: object

Dynamic constructor of stack generation pipeline.

static get_adviser_pipeline_config(recommendation_type: thoth.adviser.enums.RecommendationType, *, limit_latest_versions: int = None) → thoth.adviser.python.builder.PipelineConfig[source]

Get pipeline configuration for an adviser run.

static get_dependency_monkey_pipeline_config(decision_type: thoth.adviser.enums.DecisionType, *, limit_latest_versions: int = None) → thoth.adviser.python.builder.PipelineConfig[source]

Get pipeline configuration for a dependency monkey run.

graph
library_usage
project
class thoth.adviser.python.builder.PipelineConfig(sieves, steps, strides)

Bases: tuple

property sieves

Alias for field number 0

property steps

Alias for field number 1

property strides

Alias for field number 2

thoth.adviser.python.dependency_monkey module

Dependency Monkey traverses dependency graph and generates stacks.

thoth.adviser.python.dependency_monkey.dependency_monkey(project: thoth.python.project.Project, output: str = None, *, seed: int = None, decision_type: thoth.adviser.enums.DecisionType = <DecisionType.ALL: 1>, dry_run: bool = False, context: str = None, count: int = None, limit_latest_versions: int = None, library_usage: dict = None) → dict[source]

Run Dependency Monkey on the given stack.

@param project: a Python project to be used for generating software stacks (lockfile is not needed) @param output: output (Amun API, directory or ‘-‘ for stdout) where stacks should be written to @param seed: a seed to be used in case of random stack generation @param decision_type: decision to be used when filtering out undesired stacks @param dry_run: do not perform actual writing to output, just run the dependency monkey report back computed stacks @param context: context to be sent to Amun, if output is set to be Amun @param count: generate upto N stacks @param limit_latest_versions: number of latest versions considered for each package when generation is done @library_usage: library usage to supply additional configuration in stack generation pipeline

thoth.adviser.python.dependency_monkey.dm_amun_inspect_wrapper(output: str, context: dict, generated_project: thoth.python.project.Project, count: int) → Optional[str][source]

A wrapper around Amun inspection call.

thoth.adviser.python.digests_fetcher module

Fetcher for fetching digests from the graph database.

class thoth.adviser.python.digests_fetcher.GraphDigestsFetcher(graph: thoth.storages.graph.postgres.GraphDatabase = None)[source]

Bases: thoth.python.digests_fetcher.DigestsFetcherBase

Fetch digests from the graph database.

fetch_digests(package_name: str, package_version: str) → dict[source]

Fetch digests for the given package in specified version as stored in the graph database.

thoth.adviser.python.exceptions module

Exceptions related to Python recommendations.

exception thoth.adviser.python.exceptions.ConstraintClashError[source]

Bases: thoth.adviser.exceptions.ThothAdviserException

An exception raised if there is a clash with constraints (see dependency graph for more info).

exception thoth.adviser.python.exceptions.DirectDependencyRemoval[source]

Bases: thoth.adviser.exceptions.ThothAdviserException

Raised if trying to remove direct dependency from application stack.

Or there is no option to remove the given dependency from application stack.

exception thoth.adviser.python.exceptions.UnableLock[source]

Bases: thoth.adviser.exceptions.ThothAdviserException

Raised if trying to lock invalid application stack or resolution cannot be done.

thoth.adviser.python.solver module

Definition of package resolution based on precomputed data available in graph.

There are defined primitives required for offline resolution. This off-line resolution is done based on data aggregated in the graph database so thereis no need to perform resolving by actually installing Python packages (as this version resolution is dynamic in case of Python).

class thoth.adviser.python.solver.GraphReleasesFetcher(runtime_environment: thoth.common.config.runtime_environment.RuntimeEnvironment = None, graph_db=None)[source]

Bases: thoth.solver.python.base.ReleasesFetcher

Fetch releases for packages from the graph database.

fetch_releases(package_name: str)[source]

Fetch releases for the given package name.

property graph_db

Get instance of graph database adapter, lazily.

class thoth.adviser.python.solver.PackageVersionDependencyParser(**parser_kwargs)[source]

Bases: thoth.solver.python.base.DependencyParser

Parse an instance of PackageVersion to Dependency object needed by solver.

parse(dependencies: List[thoth.python.package_version.PackageVersion])[source]

Parse the given list of PackageVersion objects.

class thoth.adviser.python.solver.PythonGraphSolver(*, parser_kwargs: dict = None, graph_db=None, runtime_environment=None, solver_kwargs: dict = None)[source]

Bases: thoth.solver.python.base.Solver

Solve Python dependencies based on data available in the graph database.

class thoth.adviser.python.solver.PythonPackageGraphSolver(*, parser_kwargs: dict = None, graph_db: dict = None, solver_kwargs: dict = None, runtime_environment: thoth.common.config.runtime_environment.RuntimeEnvironment = None)[source]

Bases: object

A wrapper to manipulate with Python packages using pure PackageVersion object interface.

solve(dependencies: List[thoth.python.package_version.PackageVersion], graceful: bool = True, all_versions: bool = False) → List[thoth.python.package_version.PackageVersion][source]

Solve the given dependencies and return object representation of packages.

Module contents

Recommendation engine for Python packages.