spack.solver package¶
Submodules¶
spack.solver.asp module¶
- spack.solver.asp.DEFAULT_OUTPUT_CONFIGURATION = OutputConfiguration(timers=False, stats=False, out=None, setup_only=False)¶
Default output configuration for a solve
- class spack.solver.asp.DeclaredVersion(version, idx, origin)¶
Bases:
tuple
- property idx¶
Alias for field number 1
- property origin¶
Alias for field number 2
- property version¶
Alias for field number 0
- exception spack.solver.asp.InternalConcretizerError(provided, conflicts)[source]¶
Bases:
UnsatisfiableSpecError
Subclass for new constructor signature for new concretizer
- class spack.solver.asp.OutputConfiguration(timers, stats, out, setup_only)¶
Bases:
tuple
Data class that contain configuration on what a clingo solve should output.
- Parameters
- property out¶
Alias for field number 2
- property setup_only¶
Alias for field number 3
- property stats¶
Alias for field number 1
- property timers¶
Alias for field number 0
- class spack.solver.asp.Provenance(value)[source]¶
Bases:
IntEnum
Enumeration of the possible provenances of a version.
- DEV_SPEC = 2¶
- EXTERNAL = 3¶
- INSTALLED = 7¶
- PACKAGES_YAML = 4¶
- PACKAGE_PY = 6¶
- PACKAGE_REQUIREMENT = 5¶
- SPEC = 1¶
- class spack.solver.asp.PyclingoDriver(cores=True)[source]¶
Bases:
object
- fact(head)[source]¶
ASP fact (a rule without a body).
- Parameters
head (AspFunction) – ASP function to generate as fact
- solve(setup, specs, reuse=None, output=None, control=None)[source]¶
Set up the input and solve for dependencies of
specs
.- Parameters
setup (SpackSolverSetup) – An object to set up the ASP problem.
specs (list) – List of
Spec
objects to solve for.reuse (None or list) – list of concrete specs that can be reused
output (None or OutputConfiguration) – configuration object to set the output of this solve.
control (clingo.Control) – configuration for the solver. If None, default values will be used
- Returns
A tuple of the solve result, the timer for the different phases of the solve, and the internal statistics from clingo.
- class spack.solver.asp.RequirementKind(value)[source]¶
Bases:
Enum
Purpose / provenance of a requirement
- DEFAULT = 1¶
Default requirement expressed under the ‘all’ attribute of packages.yaml
- PACKAGE = 3¶
Requirement expressed on a specific package
- VIRTUAL = 2¶
Requirement expressed on a virtual package
- class spack.solver.asp.RequirementRule(pkg_name, policy, requirements, condition, kind, message)¶
Bases:
tuple
Data class to collect information on a requirement
- property condition¶
Alias for field number 3
- property kind¶
Alias for field number 4
- property message¶
Alias for field number 5
- property pkg_name¶
Alias for field number 0
- property policy¶
Alias for field number 1
- property requirements¶
Alias for field number 2
- class spack.solver.asp.Result(specs, asp=None)[source]¶
Bases:
object
Result of an ASP solve.
- format_core(core)[source]¶
Format an unsatisfiable core for human readability
Returns a list of strings, where each string is the human readable representation of a single fact in the core, including a newline.
Modeled after traceback.format_stack.
- format_cores()[source]¶
List of facts for each core
Separate cores are separated by an empty line Cores are not minimized
- format_minimal_cores()[source]¶
List of facts for each core
Separate cores are separated by an empty line
- minimize_core(core)[source]¶
Return a subset-minimal subset of the core.
Clingo cores may be thousands of lines when two facts are sufficient to ensure unsatisfiability. This algorithm reduces the core to only those essential facts.
- raise_if_unsat()[source]¶
Raise an appropriate error if the result is unsatisfiable.
The error is an InternalConcretizerError, and includes the minimized cores resulting from the solve, formatted to be human readable.
- property specs¶
List of concretized specs satisfying the initial abstract request.
- property specs_by_input¶
- property unsolved_specs¶
List of abstract input specs that were not solved.
- class spack.solver.asp.Solver[source]¶
Bases:
object
This is the main external interface class for solving.
It manages solver configuration and preferences in one place. It sets up the solve and passes the setup method to the driver, as well.
Properties of interest:
reuse (bool)
Whether to try to reuse existing installs/binaries
- solve(specs, out=None, timers=False, stats=False, tests=False, setup_only=False)[source]¶
- Parameters
specs (list) – List of
Spec
objects to solve for.out – Optionally write the generate ASP program to a file-like object.
timers (bool) – Print out coarse fimers for different solve phases.
stats (bool) – Print out detailed stats from clingo.
tests (bool or tuple) – If True, concretize test dependencies for all packages. If a tuple of package names, concretize test dependencies for named packages (defaults to False: do not concretize test dependencies).
setup_only (bool) – if True, stop after setup and don’t solve (default False).
- solve_in_rounds(specs, out=None, timers=False, stats=False, tests=False)[source]¶
Solve for a stable model of specs in multiple rounds.
This relaxes the assumption of solve that everything must be consistent and solvable in a single round. Each round tries to maximize the reuse of specs from previous rounds.
The function is a generator that yields the result of each round.
- class spack.solver.asp.SpackSolverSetup(tests=False)[source]¶
Bases:
object
Class to set up and run a Spack concretization solve.
- add_concrete_versions_from_specs(specs, origin)[source]¶
Add concrete versions to possible versions from lists of CLI/dev specs.
- condition(required_spec, imposed_spec=None, name=None, msg=None, node=False)[source]¶
Generate facts for a dependency or virtual provider condition.
- Parameters
required_spec (spack.spec.Spec) – the spec that triggers this condition
imposed_spec (spack.spec.Spec or None) – the spec with constraints that are imposed when this condition is triggered
name (str or None) – name for required_spec (required if required_spec is anonymous, ignored if not)
msg (str or None) – description of the condition
node (bool) – if False does not emit “node” or “virtual_node” requirements from the imposed spec
- Returns
id of the condition created by this function
- Return type
- define_variant_values()[source]¶
Validate variant values from the command line.
Also add valid variant values from the command line to the possible values for a variant.
- define_virtual_constraints()[source]¶
Define versions for constraints on virtuals.
Must be called before define_version_constraints().
- emit_facts_from_requirement_rules(rules: List[RequirementRule])[source]¶
Generate facts to enforce requirements.
- Parameters
rules – rules for which we want facts to be emitted
- pkg_version_rules(pkg)[source]¶
Output declared versions of a package.
This uses self.declared_versions so that we include any versions that arise from a spec.
- preferred_variants(pkg_name)[source]¶
Facts on concretization preferences, as read from packages.yaml
- setup(driver, specs, reuse=None)[source]¶
Generate an ASP program with relevant constraints for specs.
This calls methods on the solve driver to set up the problem with facts and rules from all possible dependencies of the input specs, as well as constraints from the specs themselves.
- Parameters
driver (PyclingoDriver) – driver instance of this solve
specs (list) – list of Specs to solve
reuse (None or list) – list of concrete specs that can be reused
- spec_clauses(*args, **kwargs)[source]¶
Wrap a call to _spec_clauses() into a try/except block that raises a comprehensible error message in case of failure.
- class spack.solver.asp.SpecBuilder(specs, hash_lookup=None)[source]¶
Bases:
object
Class with actions to rebuild a spec from ASP results.
- external_spec_selected(pkg, idx)[source]¶
This means that the external spec and index idx has been selected for this package.
- ignored_attributes = re.compile('^.*_propagate$|^.*_satisfies$|^.*_set$|^package_hash$|^root$|^virtual_node$|^virtual_root$')¶
Regex for attributes that don’t need actions b/c they aren’t used to construct specs.
- reorder_flags()[source]¶
Order compiler flags on specs in predefined order.
We order flags so that any node’s flags will take priority over those of its dependents. That is, the deepest node in the DAG’s flags will appear last on the compile line, in the order they were specified.
The solver determines which flags are on nodes; this routine imposes order afterwards.
- static sort_fn(function_tuple)[source]¶
Ensure attributes are evaluated in the correct order.
hash attributes are handled first, since they imply entire concrete specs node attributes are handled next, since they instantiate nodes external_spec_selected attributes are handled last, so that external extensions can find the concrete specs on which they depend because all nodes are fully constructed before we consider which ones are external.
- exception spack.solver.asp.UnsatisfiableSpecError(msg)[source]¶
Bases:
UnsatisfiableSpecError
Subclass for new constructor signature for new concretizer
- spack.solver.asp.ast_sym(node)¶
- spack.solver.asp.ast_type(node)¶
- spack.solver.asp.build_criteria_names(costs, arg_tuples)[source]¶
Construct an ordered mapping from criteria names to costs.
- spack.solver.asp.build_priority_offset = 200¶
Priority offset for “build” criteria (regular criterio shifted to higher priority for specs we have to build)
- spack.solver.asp.default_clingo_control()[source]¶
Return a control object with the default settings used in Spack
- spack.solver.asp.extend_flag_list(flag_list, new_flags)[source]¶
Extend a list of flags, preserving order and precedence.
Add new_flags at the end of flag_list. If any flags in new_flags are already in flag_list, they are moved to the end so that they take higher precedence on the compile line.
- spack.solver.asp.extract_args(model, predicate_name)[source]¶
Extract the arguments to predicates with the provided name from a model.
Pull out all the predicates with name
predicate_name
from the model, and return their stringified arguments as tuples.
- spack.solver.asp.fixed_priority_offset = 100¶
Priority offset of “fixed” criteria (those w/o build criteria)
- spack.solver.asp.high_fixed_priority_offset = 300¶
High fixed priority offset for criteria that supersede all build criteria