Exemple #1
0
    MissingParameterTypeAnnotation,
    MissingReturnTypeAnnotation,
    QueryRule,
    RuleIndex,
    UnrecognizedRuleArgument,
    _RuleVisitor,
    goal_rule,
    rule,
)
from pants.engine.unions import UnionMembership
from pants.option.global_options import DEFAULT_EXECUTION_OPTIONS, DEFAULT_LOCAL_STORE_OPTIONS
from pants.testutil.rule_runner import MockGet, run_rule_with_mocks
from pants.util.enums import match
from pants.util.logging import LogLevel

_EXECUTOR = PyExecutor(core_threads=2, max_threads=4)


def create_scheduler(rules, validate=True):
    """Create a Scheduler."""
    return Scheduler(
        ignore_patterns=[],
        use_gitignore=False,
        build_root=str(Path.cwd()),
        local_execution_root_dir="./.pants.d",
        named_caches_dir="./.pants.d/named_caches",
        ca_certs_path=None,
        rules=rules,
        union_membership=UnionMembership({}),
        executor=_EXECUTOR,
        execution_options=DEFAULT_EXECUTION_OPTIONS,
Exemple #2
0
 def __init__(self):
     self.externs = Externs(self.lib)
     self.lib.externs_set(self.externs)
     self._executor = PyExecutor()
Exemple #3
0
from pants.util.dirutil import (
    recursive_dirname,
    safe_file_dump,
    safe_mkdir,
    safe_mkdtemp,
    safe_open,
)
from pants.util.ordered_set import FrozenOrderedSet

# -----------------------------------------------------------------------------------------------
# `RuleRunner`
# -----------------------------------------------------------------------------------------------

_O = TypeVar("_O")

_EXECUTOR = PyExecutor(core_threads=multiprocessing.cpu_count(),
                       max_threads=multiprocessing.cpu_count() * 4)


@dataclass(frozen=True)
class GoalRuleResult:
    exit_code: int
    stdout: str
    stderr: str

    @staticmethod
    def noop() -> GoalRuleResult:
        return GoalRuleResult(0, stdout="", stderr="")


# This is not frozen because we need to update the `scheduler` when setting options.
@dataclass
from pants.util.dirutil import (
    recursive_dirname,
    safe_file_dump,
    safe_mkdir,
    safe_mkdtemp,
    safe_open,
)
from pants.util.ordered_set import FrozenOrderedSet

# -----------------------------------------------------------------------------------------------
# `RuleRunner`
# -----------------------------------------------------------------------------------------------

_O = TypeVar("_O")

_EXECUTOR = PyExecutor(multiprocessing.cpu_count(),
                       multiprocessing.cpu_count() * 4)


@dataclass(frozen=True)
class GoalRuleResult:
    exit_code: int
    stdout: str
    stderr: str

    @staticmethod
    def noop() -> GoalRuleResult:
        return GoalRuleResult(0, stdout="", stderr="")


# This is not frozen because we need to update the `scheduler` when setting options.
@dataclass
Exemple #5
0
            raise AssertionError("Expected value not found in exception.\n"
                                 f"expected: {contains}\n\n"
                                 f"exception: {underlying}")


# -----------------------------------------------------------------------------------------------
# `RuleRunner`
# -----------------------------------------------------------------------------------------------

_I = TypeVar("_I")
_O = TypeVar("_O")

# Use the ~minimum possible parallelism since integration tests using RuleRunner will already be run
# by Pants using an appropriate Parallelism. We must set max_threads > core_threads; so 2 is the
# minimum, but, via trial and error, 3 minimizes test times on average.
_EXECUTOR = PyExecutor(core_threads=1, max_threads=3)

# Environment variable names required for locating Python interpreters, for use with RuleRunner's
# env_inherit arguments.
# TODO: This is verbose and redundant: see https://github.com/pantsbuild/pants/issues/13350.
PYTHON_BOOTSTRAP_ENV = {"PATH", "PYENV_ROOT", "HOME"}


@dataclass(frozen=True)
class GoalRuleResult:
    exit_code: int
    stdout: str
    stderr: str

    @staticmethod
    def noop() -> GoalRuleResult:
Exemple #6
0
    MissingParameterTypeAnnotation,
    MissingReturnTypeAnnotation,
    QueryRule,
    RuleIndex,
    UnrecognizedRuleArgument,
    _RuleVisitor,
    goal_rule,
    rule,
)
from pants.engine.unions import UnionMembership
from pants.option.global_options import DEFAULT_EXECUTION_OPTIONS
from pants.testutil.rule_runner import MockGet, run_rule_with_mocks
from pants.util.enums import match
from pants.util.logging import LogLevel

_EXECUTOR = PyExecutor(2, 4)


def create_scheduler(rules, validate=True, native=None):
    """Create a Scheduler."""
    native = native or Native()
    return Scheduler(
        native=native,
        ignore_patterns=[],
        use_gitignore=False,
        build_root=str(Path.cwd()),
        local_store_dir="./.pants.d/lmdb_store",
        local_execution_root_dir="./.pants.d",
        named_caches_dir="./.pants.d/named_caches",
        ca_certs_path=None,
        rules=rules,