experiment! borrow pip's resolvelib debug reporter

pull/81693/head
Sviatoslav Sydorenko 1 year ago
parent 6f65397871
commit f9f459001b
No known key found for this signature in database
GPG Key ID: 9345E8FEA89CA455

@ -21,6 +21,9 @@ if t.TYPE_CHECKING:
from ansible.galaxy.collection.galaxy_api_proxy import MultiGalaxyAPIProxy
from ansible.galaxy.dependency_resolution.providers import CollectionDependencyProvider
from ansible.galaxy.dependency_resolution.reporters import CollectionDependencyReporter
from ansible.galaxy.dependency_resolution.reporters import CollectionDependencyDebuggingReporter
from ansible.galaxy.dependency_resolution.reporters import CollectionDependencyReporter
from ansible.galaxy.dependency_resolution.resolvers import CollectionDependencyResolver
@ -51,5 +54,6 @@ def build_collection_dependency_resolver(
upgrade=upgrade,
include_signatures=include_signatures,
),
CollectionDependencyReporter(),
CollectionDependencyDebuggingReporter(),
# CollectionDependencyReporter(),
)

@ -19,3 +19,46 @@ class CollectionDependencyReporter(BaseReporter):
This is a proxy class allowing us to abstract away importing resolvelib
outside of the `ansible.galaxy.dependency_resolution` Python package.
"""
from logging import basicConfig, DEBUG, getLogger
from sys import stdout
basicConfig(stream=stdout, level=DEBUG)
logger = getLogger(__name__)
logger.info('INFO THING')
logger.debug('DEBUG THING')
from typing import Any
from .dataclasses import Candidate, Requirement
class CollectionDependencyDebuggingReporter(CollectionDependencyReporter):
"""A reporter that does an info log for every event it sees."""
def starting(self) -> None:
logger.info("Reporter.starting()")
def starting_round(self, index: int) -> None:
logger.info("Reporter.starting_round(%r)", index)
def ending_round(self, index: int, state: Any) -> None:
logger.info("Reporter.ending_round(%r, %r)", index, state)
def ending(self, state: Any) -> None:
logger.info("Reporter.ending(%r)", state)
def adding_requirement(self, requirement: Requirement, parent: Candidate) -> None:
logger.info("Reporter.adding_requirement(%r, %r)", requirement, parent)
def rejecting_candidate(self, criterion: Any, candidate: Candidate) -> None:
logger.info("Reporter.rejecting_candidate(%r, %r)", criterion, candidate)
backtracking = rejecting_candidate # Old pre-v0.9.0 resolvelib hook name
def pinning(self, candidate: Candidate) -> None:
logger.info("Reporter.pinning(%r)", candidate)
def pinning(self, candidate: Candidate) -> None:
logger.info("Reporter.pinning(%r)", candidate)

Loading…
Cancel
Save