ramble.language namespace
Submodules
ramble.language.application_language module
- class ramble.language.application_language.ApplicationMeta(name, bases, attr_dict)[source]
Bases:
SharedMeta
- ramble.language.application_language.environment_variable(name, value, description, workload=None, workloads=None, workload_group=None, **kwargs)[source]
Define an environment variable to be used in experiments
- ramble.language.application_language.executable(name, template, **kwargs)[source]
Adds an executable to this application
Defines a new executable that can be used to configure workloads and experiments with.
Executables may or may not use MPI.
- Required Args:
name (str): Name of the executable template (list[str] or str): The template command this executable should generate from
- Optional Args:
- use_mpi or mpi (boolean): determines if this executable should be
wrapped with an mpirun like command or not.
- variables (dict): Dictionary of variable definitions to use for this
executable only
- redirect (str): Optional, sets the path for outputs to be written to.
defaults to {log_file}
- output_capture (str): Optional, Declare which output (stdout, stderr,
both) to capture. Defaults to stdout
- run_in_background (boolean): Optional, Declare if the command should
run in the background. Defaults to False
- ramble.language.application_language.input_file(name, url, description, target_dir='{workload_input_dir}', sha256=None, extension=None, expand=True, **kwargs)[source]
Adds an input file definition to this application
Defines a new input file. An input file must define it’s name, and a url where the input can be fetched from.
- Parameters:
url (str) – Path to the input file / archive
description (str) – Description of this input file
target_dir (str) – Optional, the directory where the archive will be expanded. Defaults to the ‘{workload_input_dir}’ + os.sep + ‘{input_name}’
sha256 (str) – Optional, the expected sha256 checksum for the input file
extension (str) – Optiona, the extension to use for the input, if it isn’t part of the file name.
expand (boolean) – Optional. Whether the input should be expanded or not. Defaults to True
- ramble.language.application_language.workload(name, executables=None, executable=None, input=None, inputs=None, tags=None, **kwargs)[source]
Adds a workload to this application
Defines a new workload that can be used within the context of its application.
- Parameters:
One of executable, or executables is required as an input argument.
- ramble.language.application_language.workload_group(name, workloads=None, mode=None, **kwargs)[source]
Adds a workload group to this application
Defines a new workload group that can be used within the context of its application.
- ramble.language.application_language.workload_variable(name, default, description, values=None, workload=None, workloads=None, workload_group=None, expandable: bool = True, track_used: bool = True, **kwargs)[source]
Define a new variable to be used in experiments
Defines a new variable that can be defined within the experiments.yaml config file, to control various aspects of an experiment.
These are specific to each workload.
- Parameters:
name (str) – Name of variable to define
default – Default value of variable definition
description (str) – Description of variable’s purpose
values (list) – Optional list of suggested values for this variable
workload (str) – Single workload this variable is used in
workloads (list) – List of modes this variable is used in
workload_group (str) – Name of workload group this variable is used in
expandable (bool) – True if the variable should be expanded, False if not.
track_used (bool) – True if the variable should be tracked as used, False if not. Can help with allowing lists without vecotizing experiments.
ramble.language.language_base module
This package contains the underlying implementation for the language directives, which are to allow functions to be invoked at class level
- exception ramble.language.language_base.DirectiveError(message, long_message=None)[source]
Bases:
RambleErrorThis is raised when something is wrong with a language directive.
- class ramble.language.language_base.DirectiveMeta(name, bases, attr_dict)[source]
Bases:
typeFlushes the directives that were temporarily stored in the staging area into the package.
- classmethod directive(dicts=None)[source]
Decorator for Ramble directives.
Ramble directives allow you to modify an object while it is being defined, e.g. to add version or dependency information. Directives are one of the key pieces of Ramble’s object “language”, which is embedded in python.
Here’s an example directive:
@directive(dicts='workloads') workload('workload_name', ...): ...
This directive allows you write:
class Foo(ApplicationBase): workload(...)
The
@directivedecorator handles a couple things for you:Adds the class scope (app) as an initial parameter when called, like a class method would. This allows you to modify a package from within a directive, while the package is still being defined.
It automatically adds a dictionary called “workloads” to the package so that you can refer to app.workloads.
The
(dicts='workloads')part ensures that ALL applications in Ramble will have aworkloadsattribute after they’re constructed, and that if no directive actually modified it, it will just be an empty dict.This is just a modular way to add storage attributes to the Application class, and it’s how Ramble gets information from the applications to the core.
ramble.language.language_helpers module
- ramble.language.language_helpers.check_definition(single_type, multiple_type, single_arg_name, multiple_arg_name, directive_name)[source]
Sanity check definitions before merging or require
- Parameters:
single_type – Single string for type name
multiple_type – List of strings for type names, may contain wildcards
multiple_pattern_match – List of strings to match against patterns in multiple_type
single_arg_name – String name of the single_type argument in the directive
multiple_arg_name – String name of the multiple_type argument in the directive
directive_name – Name of the directive requiring a type
- Returns:
List of all type names (Merged if both single_type and multiple_type definitions are valid)
- ramble.language.language_helpers.expand_patterns(multiple_type: list, multiple_pattern_match: list)[source]
Expand wildcard patterns within a list of names
This method takes an input list containing wildcard patterns and expands the wildcard with values matching a list of names. Returns a list containing matching names and any inputs with zero matches.
- Parameters:
multiple_types – List of strings for type names, may contain wildcards
multiple_pattern_match – List of strings to match against patterns in multiple_type
- Returns:
List of expanded patterns matching the names list plus patterns not found in the names list.
- ramble.language.language_helpers.merge_definitions(single_type, multiple_type, multiple_pattern_match, single_arg_name, multiple_arg_name, directive_name)[source]
Merge definitions of a type
This method will merge two optional definitions of single_type and multiple_type.
- Parameters:
single_type – Single string for type name
multiple_type – List of strings for type names, may contain wildcards
multiple_pattern_match – List of strings to match against patterns in multiple_type
single_arg_name – String name of the single_type argument in the directive
multiple_arg_name – String name of the multiple_type argument in the directive
directive_name – Name of the directive requiring a type
- Returns:
List of all type names (Merged if both single_type and multiple_type definitions are valid)
- ramble.language.language_helpers.require_definition(single_type, multiple_type, multiple_pattern_match, single_arg_name, multiple_arg_name, directive_name)[source]
Require at least one definition for a type in a directive
This method will validate that single_type / multiple_type are properly defined.
It will raise an error if at least one type is not defined, or if either are the incorrect type.
- Parameters:
single_type – Single string for type name
multiple_type – List of strings for type names, may contain wildcards
multiple_pattern_match – List of strings to match against patterns in multiple_type
single_arg_name – String name of the single_type argument in the directive
multiple_arg_name – String name of the multiple_type argument in the directive
directive_name – Name of the directive requiring a type
- Returns:
List of all type names (Merged if both single_type and multiple_type definitions are valid)
ramble.language.modifier_language module
- class ramble.language.modifier_language.ModifierMeta(name, bases, attr_dict)[source]
Bases:
SharedMeta
- ramble.language.modifier_language.default_mode(name, **kwargs)[source]
Define a default mode for this modifier.
The default mode will be used if modifier mode is not specified in an experiment.
- Parameters:
name (str) – Name of mode to be used as default
- ramble.language.modifier_language.env_var_modification(name, modification=None, method='set', mode=None, modes=None, **kwargs)[source]
Define an environment variable modifier
Environment variable modifications modify the values of environment variables within the application instance.
- Parameters:
name (str) – The name of the environment variable that will be modified
modification (str) – The value of the modification
method (str) – The method of the modification.
mode (str) – Name of mode this env_var_modification should apply in
modes (list(str)) – List of mode names this env_var_modification should apply in
- Supported values for method are:
set: Defines the variable to equal the modification value unset: Removes any definition of the variable from the environment prepend: Prepends the modification to the beginning of the variable.
Always uses the separator ‘:’
- append: Appends the modification value to the end of the value. Allows a
keyword argument of ‘separator’ to define the delimiter between values.
- ramble.language.modifier_language.executable_modifier(name)[source]
Register an executable modifier
Executable modifiers can modify various aspects of non-builtin application executable definitions.
These behave similarly to builtins, in that a python method defines the actual modifications
For example:
executable_modifier('write_exec_name') def write_exec_name(self, executable_name, executable, app_inst=None): prepend_execs = [] append_execs = [ExecutableCommand( template='echo "{executable_name}"', mpi=False, redirect='{log_file}', output_capture=OUTPUT_CAPTURE.DEFAULT )] return prepend_execs, append_execs
Would append the echo “{executable_name}” to every non-builtin executable in an experiment.
Executable modifiers are allowed to modify the input executable in place. Executable modifiers must return two lists of executables.
- Parameters:
name (str) – Name of executable modifier to use. Should be the name of a class method.
- Each executable modifier needs to return:
- prepend_execs (list(CommandExecutable)): List of executables to inject
before the base executable
- append_execs (list(CommandExecutable)): List of executables to inject
after the base executable
- ramble.language.modifier_language.mode(name, description, **kwargs)[source]
Define a new mode for this modifier.
Modes allow a modifier to bundle a set of modifications together.
NOTE: A mode ‘disabled’ is defined by default for all modifiers.
- ramble.language.modifier_language.modifier_variable(name: str, default, description: str, values: list | None = None, mode: str | None = None, modes: list | None = None, expandable: bool = True, track_used: bool = False, **kwargs)[source]
Define a variable for this modifier
- Parameters:
name (str) – Name of variable to define
default – Default value of variable definition
description (str) – Description of variable’s purpose
values (list) – Optional list of suggested values for this variable
mode (str) – Single mode this variable is used in
modes (list) – List of modes this variable is used in
expandable (bool) – True if the variable should be expanded, False if not.
track_used (bool) – True if the variable should be tracked as used, False if not. Can help with allowing lists without vecotizing experiments.
- ramble.language.modifier_language.package_manager_requirement(command: str, validation_type: str, modes: list, regex=None, package_manager: str = '*', **kwargs)[source]
Define a requirement when this modifier is used in an experiment with a package manager.
This allows modifiers to inject additional requirements on packages managers. These can be used to ensure package manager commands return specific values.
- Parameters:
command (str) – Package manager command to execute, when evaluating the requirement
validation_type (str) – Type of validation to perform on output of command. Valid types are: ‘empty’, ‘not_empty’, ‘contains_regex’, ‘does_not_contain_regex’
modes (list(str)) – List of usage modes this requirement should apply to
regex (str) – Regular expression to use when validation_type is either ‘contains_regex’ or ‘does_no_contain_regex’
package_manager (str) – Name of the package manager this requirement applies to
- ramble.language.modifier_language.required_variable(var: str, results_level='variable', modes=None, description=None)[source]
Mark a variable as being required by this modifier
- Parameters:
var (str) – Variable name to mark as required
results_level (str) – ‘variable’ or ‘key’. If ‘key’, variable is promoted to a key within JSON or YAML formatted results.
modes (list[str] | None) – modes that the required check should be applied. The default None means apply to all modes.
description (str | None) – Description of the required variable.
- ramble.language.modifier_language.variable_modification(name, modification, method='set', mode=None, modes=None, separator=' ', **kwargs)[source]
Define a new variable modification for a mode in this modifier.
A variable modification will apply a change to a defined variable within an experiment.
- Parameters:
name (str) – The variable to modify
modification (str) – The value to modify ‘name’ with
method (str) – How the modification should be applied
mode (str) – Single mode to group this modification into
modes (str) – List of modes to group this modification into
separator (str) – Optional separator to use when modifying with ‘append’ or ‘prepend’ methods.
- Supported values are ‘append’, ‘prepend’, and ‘set’:
‘append’ will add the modification to the end of ‘name’ ‘prepend’ will add the modification to the beginning of ‘name’ ‘set’ (Default) will overwrite ‘name’ with the modification
ramble.language.package_manager_language module
- class ramble.language.package_manager_language.PackageManagerMeta(name, bases, attr_dict)[source]
Bases:
SharedMeta
ramble.language.workflow_manager_language module
- class ramble.language.workflow_manager_language.WorkflowManagerMeta(name, bases, attr_dict)[source]
Bases:
SharedMeta
- ramble.language.workflow_manager_language.workflow_manager_variable(name: str, default, description: str, values: list | None = None)[source]
Define a variable for this wm :param name: Name of variable :param default: Default value if the variable is not defined :param description: Description of the variable :param values: Optional list of suggested values for this variable