easybuild.framework.easyconfig.easyconfig module

Easyconfig module that contains the EasyConfig class.

author:Stijn De Weirdt (Ghent University)
author:Dries Verdegem (Ghent University)
author:Kenneth Hoste (Ghent University)
author:Pieter De Baets (Ghent University)
author:Jens Timmerman (Ghent University)
author:Toon Willems (Ghent University)
author:Ward Poelmans (Ghent University)
author:Alan O’Cais (Juelich Supercomputing Centre)
author:Bart Oldeman (McGill University, Calcul Quebec, Compute Canada)
author:Maxime Boissonneault (Universite Laval, Calcul Quebec, Compute Canada)
author:Victor Holanda (CSCS, ETH Zurich)
class easybuild.framework.easyconfig.easyconfig.ActiveMNS(*args, **kwargs)

Bases: abc.BaseActiveMNS

Wrapper class for active module naming scheme.

check_ec_type(ec, raise_error=True)

Obtain a full parsed easyconfig file to pass to naming scheme methods if provided keys are insufficient.

Parameters:
  • ec – available easyconfig parameter specifications (EasyConfig instance or dict value)
  • raise_error – boolean indicating whether or not an error should be raised if a full easyconfig is required but not found
det_devel_module_filename(ec, force_visible=False)

Determine devel module filename.

det_full_module_name(ec, force_visible=False, require_result=True)

Determine full module name by selected module naming scheme, based on supplied easyconfig.

det_init_modulepaths(ec)

Determine initial modulepaths according to module naming scheme.

det_install_subdir(ec)

Determine name of software installation subdirectory.

det_modpath_extensions(ec)

Determine modulepath extensions according to module naming scheme.

det_module_subdir(ec)

Determine module subdirectory according to module naming scheme.

Determine list of paths in which symlinks to module files must be created.

det_short_module_name(ec, force_visible=False)

Determine short module name according to module naming scheme.

det_user_modpath_extensions(ec)

Determine user-specific modulepath extensions according to module naming scheme.

expand_toolchain_load(ec=None)

Determine whether load statements for a toolchain should be expanded to load statements for its dependencies. This is useful when toolchains are not exposed to users.

is_short_modname_for(short_modname, name)

Determine whether the specified (short) module name is a module for software with the specified name.

requires_full_easyconfig(keys)

Check whether specified list of easyconfig parameters is sufficient for active module naming scheme.

class easybuild.framework.easyconfig.easyconfig.EasyConfig(path, extra_options=None, build_specs=None, validate=True, hidden=None, rawtxt=None, auto_convert_value_types=True, local_var_naming_check=None)

Bases: object

Class which handles loading, reading, validation of easyconfigs

all_dependencies

Return list of all dependencies, incl. hidden/build deps & toolchain, but excluding filtered deps.

asdict()

Return dict representation of this EasyConfig instance.

builddependencies()

Return a flat list of the parsed build dependencies When builddependencies are iterable they are flattened lists with duplicates removed outside of the iterating process, because the callers want simple lists.

check_deprecated(path)

Check whether this easyconfig file is deprecated.

copy(validate=None)

Return a copy of this EasyConfig instance.

dep_is_filtered(dep, filter_deps_specs)

Returns True if a dependency is filtered according to the filter_deps_specs

dependencies(build_only=False)

Returns an array of parsed dependencies (after filtering, if requested) dependency = {‘name’: ‘’, ‘version’: ‘’, ‘system’: (False|True), ‘versionsuffix’: ‘’, ‘toolchain’: ‘’} Iterable builddependencies are flattened when not iterating.

Parameters:build_only – only return build dependencies, discard others
disable_templating()

Temporarily disable templating on the given EasyConfig

Usage:
with ec.disable_templating():
# Do what you want without templating

# Templating set to previous value

dump(fp, always_overwrite=True, backup=False, explicit_toolchains=False)

Dump this easyconfig to file, with the given filename.

Parameters:
  • always_overwrite – overwrite existing file at specified location without use of –force
  • backup – create backup of existing file before overwriting it
extend_params(extra, overwrite=True)

Extend list of known parameters via provided list of extra easyconfig parameters.

filename()

Determine correct filename for this easyconfig file.

filter_deps(deps)

Filter dependencies according to ‘filter-deps’ configuration setting.

filter_hidden_deps()

Replace dependencies by hidden dependencies in list of (build) dependencies, where appropriate.

generate_template_values()

Try to generate all template values.

get(key, *args, **kwargs)

Check whether any replace easyconfig parameters are still used

get_cuda_cc_template_value(key)

Get template value based on –cuda-compute-capabilities EasyBuild configuration option and cuda_compute_capabilities easyconfig parameter. Returns user-friendly error message in case neither are defined, or if an unknown key is used.

get_parsed_multi_deps()

Get list of lists of parsed dependencies that correspond with entries in multi_deps easyconfig parameter.

get_ref(key)

Obtain reference to original/untemplated value of specified easyconfig parameter rather than a copied value with templated values.

handle_external_module_metadata(mod_name)

Helper function for _parse_dependency; collects metadata for external module dependencies.

Parameters:mod_name – name of external module to collect metadata for
handle_multi_deps()

Handle lists of dependency versions of which we should iterate specified in ‘multi_deps’ easyconfig parameter.

This is basically just syntactic sugar to prevent having to specify a list of lists in ‘builddependencies’.

is_mandatory_param(key)

Check whether specified easyconfig parameter is mandatory.

local_var_naming(local_var_naming_check)

Deal with local variables that do not follow the recommended naming scheme (if any).

name

returns name

parse()

Parse the file and set options mandatory requirements are checked here

parse_filter_deps()

Parse specifications for which dependencies should be filtered.

parse_version_range(version_spec)

Parse provided version specification as a version range.

probe_external_module_metadata(mod_name, existing_metadata=None)

Helper function for handle_external_module_metadata.

Tries to determine metadata for external module when there is not entry in the metadata file, by looking at the variables defined by the module file.

This is mainly intended for modules provided in the Cray Programming Environment, but it could also be useful in other contexts.

The following pairs of variables are considered (in order, first hit wins), where ‘XXX’ is the software name in capitals:

1. $CRAY_XXX_PREFIX and $CRAY_XXX_VERSION 1. $CRAY_XXX_PREFIX_DIR and $CRAY_XXX_VERSION 2. $CRAY_XXX_DIR and $CRAY_XXX_VERSION 2. $CRAY_XXX_ROOT and $CRAY_XXX_VERSION 5. $XXX_PREFIX and $XXX_VERSION 4. $XXX_DIR and $XXX_VERSION 5. $XXX_ROOT and $XXX_VERSION 3. $XXX_HOME and $XXX_VERSION

If none of the pairs is found, then an empty dictionary is returned.

Parameters:
  • mod_name – name of the external module
  • metadata – already available metadata for this external module (if any)
set_keys(params)

Set keys in this EasyConfig instance based on supplied easyconfig parameter values.

If any unknown easyconfig parameters are encountered here, an error is raised.

Parameters:params – a dict value with names/values of easyconfig parameters to set
start_iterating()

Start iterative mode.

stop_iterating()

Stop iterative mode.

toolchain

returns the Toolchain used

update(key, value, allow_duplicate=True)

Update an easyconfig parameter with the specified value (i.e. append to it). Note: For dictionary easyconfig parameters, ‘allow_duplicate’ is ignored (since it’s meaningless).

validate(check_osdeps=True)

Validate this easyonfig - ensure certain easyconfig parameters are set to a known value (see self.validations) - check OS dependencies - check license

validate_iterate_opts_lists()

Configure/build/install options specified as lists should have same length.

validate_license()

Validate the license

validate_os_deps()

validate presence of OS dependencies osdependencies should be a single list

version

returns version

easybuild.framework.easyconfig.easyconfig.clean_up_easyconfigs(paths)

Clean up easyconfigs (in place) by filtering out comments/buildstats included by EasyBuild in archived easyconfigs (cfr. FileRepository.add_easyconfig in easybuild.tools.repository.filerepo)

Parameters:paths – list of paths to easyconfigs to clean up
easybuild.framework.easyconfig.easyconfig.copy_easyconfigs(paths, target_dir)

Copy easyconfig files to specified directory, in the ‘right’ location and using the filename expected by robot.

Parameters:
  • paths – list of paths to copy to git working dir
  • target_dir – target directory
Returns:

dict with useful information on copied easyconfig files (corresponding EasyConfig instances, paths, status)

easybuild.framework.easyconfig.easyconfig.copy_patch_files(patch_specs, target_dir)

Copy patch files to specified directory, in the ‘right’ location according to the software name they relate to.

Parameters:
  • patch_specs – list of tuples with patch file location and name of software they are for
  • target_dir – target directory
easybuild.framework.easyconfig.easyconfig.create_paths(path, name, version)

Returns all the paths where easyconfig could be located <path> is the basepath <name> should be a string <version> can be a ‘*’ if you use glob patterns, or an install version otherwise

easybuild.framework.easyconfig.easyconfig.det_file_info(paths, target_dir)

Determine useful information on easyconfig files relative to a target directory, before any actual operation (e.g. copying) is performed

Parameters:
  • paths – list of paths to easyconfig files
  • target_dir – target directory
Returns:

dict with useful information on easyconfig files (corresponding EasyConfig instances, paths, status) relative to a target directory

easybuild.framework.easyconfig.easyconfig.det_installversion(version, toolchain_name, toolchain_version, prefix, suffix)

Deprecated ‘det_installversion’ function, to determine exact install version, based on supplied parameters.

easybuild.framework.easyconfig.easyconfig.det_location_for(path, target_dir, soft_name, target_file)

Determine path to easyconfigs directory for specified software name, using specified target file name.

Parameters:
  • path – path of file to copy
  • target_dir – (parent) target directory, should contain easybuild/easyconfigs subdirectory
  • soft_name – software name (to determine location to copy to)
  • target_file – target file name
Returns:

full path to the right location

easybuild.framework.easyconfig.easyconfig.det_subtoolchain_version(current_tc, subtoolchain_names, optional_toolchains, cands, incl_capabilities=False)

Returns unique version for subtoolchain, in tc dict. If there is no unique version: * use ‘’ for system, if system is not skipped. * return None for skipped subtoolchains, that is,

optional toolchains or system toolchain without add_system_to_minimal_toolchains.
  • in all other cases, raises an exception.
easybuild.framework.easyconfig.easyconfig.disable_templating(ec)

Temporarily disable templating on the given EasyConfig

Usage:
with disable_templating(ec):
# Do what you want without templating

# Templating set to previous value

easybuild.framework.easyconfig.easyconfig.fix_deprecated_easyconfigs(paths)

Fix use of deprecated functionality in easyconfigs at specified locations.

easybuild.framework.easyconfig.easyconfig.get_easyblock_class(easyblock, name=None, error_on_failed_import=True, error_on_missing_easyblock=None, **kwargs)

Get class for a particular easyblock (or use default)

easybuild.framework.easyconfig.easyconfig.get_module_path(name, generic=None, decode=True)

Determine the module path for a given easyblock or software name, based on the encoded class name.

Parameters:
  • generic – whether or not the easyblock is generic (if None: auto-derive from specified class name)
  • decode – whether or not to decode the provided class name
easybuild.framework.easyconfig.easyconfig.get_toolchain_hierarchy(parent_toolchain, incl_capabilities=False)

Determine list of subtoolchains for specified parent toolchain. Result starts with the most minimal subtoolchains first, ends with specified toolchain.

The system toolchain is considered the most minimal subtoolchain only if the add_system_to_minimal_toolchains build option is enabled.

The most complex hierarchy we have now is goolfc which works as follows:

goolfc /
gompic golfc(*)

/ (*) optional toolchains, not compulsory for backwards compatibility gcccuda golf(*)

/
GCC

/ |

GCCcore(*) |
|

(system: only considered if –add-system-to-minimal-toolchains configuration option is enabled)

Parameters:
  • parent_toolchain – dictionary with name/version of parent toolchain
  • incl_capabilities – also register toolchain capabilities in result
easybuild.framework.easyconfig.easyconfig.handle_deprecated_or_replaced_easyconfig_parameters(ec_method)

Decorator to handle deprecated/replaced easyconfig parameters.

easybuild.framework.easyconfig.easyconfig.is_generic_easyblock(easyblock)

Return whether specified easyblock name is a generic easyblock or not.

easybuild.framework.easyconfig.easyconfig.is_local_var_name(name)

Determine whether provided variable name can be considered as the name of a local variable:

One of the following suffices to be considered a name of a local variable: * name starts with ‘local_’ or ‘_’ * name consists of a single letter * name is __builtins__ (which is always defined)

easybuild.framework.easyconfig.easyconfig.letter_dir_for(name)

Determine ‘letter’ directory for specified software name. This usually just the 1st letter of the software name (in lowercase), except for funky software names, e.g. ones starting with a digit.

easybuild.framework.easyconfig.easyconfig.process_easyconfig(path, build_specs=None, validate=True, parse_only=False, hidden=None)

Process easyconfig, returning some information for each block :param path: path to easyconfig file :param build_specs: dictionary specifying build specifications (e.g. version, toolchain, …) :param validate: whether or not to perform validation :param parse_only: only parse easyconfig superficially (faster, but results in partial info) :param hidden: indicate whether corresponding module file should be installed hidden (‘.’-prefixed)

easybuild.framework.easyconfig.easyconfig.resolve_template(value, tmpl_dict)

Given a value, try to susbstitute the templated strings with actual values. - value: some python object (supported are string, tuple/list, dict or some mix thereof) - tmpl_dict: template dictionary

easybuild.framework.easyconfig.easyconfig.robot_find_easyconfig(name, version)

Find an easyconfig for module in path, returns (absolute) path to easyconfig file (or None, if none is found).

easybuild.framework.easyconfig.easyconfig.robot_find_subtoolchain_for_dep(dep, modtool, parent_tc=None, parent_first=False)

Find the subtoolchain to use for a dependency

Parameters:
  • dep – dependency target dict (long and short module names may not exist yet)
  • parent_tc – toolchain from which to derive the toolchain hierarchy to search (default: use dep’s toolchain)
  • parent_first – reverse order in which subtoolchains are considered: parent toolchain, then subtoolchains
Returns:

minimal toolchain for which an easyconfig exists for this dependency (and matches build_options)

easybuild.framework.easyconfig.easyconfig.toolchain_hierarchy_cache(func)

Function decorator to cache (and retrieve cached) toolchain hierarchy queries.

easybuild.framework.easyconfig.easyconfig.triage_easyconfig_params(variables, ec)

Triage supplied variables into known easyconfig parameters and other variables.

Unknown easyconfig parameters that have a single-letter name, or of which the name starts with ‘local_’ are considered to be local variables.

Parameters:
  • variables – dictionary with names/values of variables that should be triaged
  • ec – dictionary with set of known easyconfig parameters
Returns:

2-tuple with dict of names/values for known easyconfig parameters + unknown (non-local) variables

easybuild.framework.easyconfig.easyconfig.verify_easyconfig_filename(path, specs, parsed_ec=None)

Check whether parsed easyconfig at specified path matches expected specs; this basically verifies whether the easyconfig filename corresponds to its contents

Parameters:
  • path – path to easyconfig file
  • specs – expected specs (dict with easyconfig parameter values)
  • parsed_ec – (list of) EasyConfig instance(s) corresponding to easyconfig file