Advanced Topics for Definition Developers
Some application or modifier definition files have more complex requirements than those met with the directives that are covered in the object specific developer guides. This developers guide will teach you several more advanced concepts to help write more specialized definition files.
The functionality described in this guide is briefly described within the package manager developer guide, but will be covered in more detail here. This functionality is shared by all of the object types supported in Ramble.
Experiment Pipelines and Phases
Architecture Overview
Ramble organizes workspaces into a modular Pipeline and Phase Graph architecture.
Pipelines
Ramble has a concept of a pipeline which represents full actions that can
be taken on a workspace. Each pipeline has a corresponding workspace
command and targets a specific stage of the experiment lifecycle. The most
common pipelines are:
There are more pipelines that Ramble can use to perform complex actions on a workspace, which can be seen in the Additional Pipelines section below.
Phase Graphs
Pipelines are built out of phases. In Ramble, a phase represents a specific
step along the path of completing the action defined by the pipeline.
Examples of phases include get_inputs (for downloading input files needed
by a workload) and software_install (for performing software installation
using a package manager).
For each pipeline, Ramble builds a directed acyclic graph
(ramble.graphs.PhaseGraph) containing all phases registered for that pipeline.
Constraint Declaration: Phase dependency constraints are declared within object class definitions using
run_before=['phase_name']orrun_after=['phase_name'].Order Resolution: When a pipeline initializes,
ramble.graphs.PhaseGraphresolves phase dependencies using a topological sort. If cyclical dependencies exist, Ramble raises aRambleError.
Phase Registration
Phases can be defined in a variety of locations. Some base classes define phases for specific pipelines. For example:
ApplicationBase registers phases such as
get_inputs,license_includes, andmake_experimentsin thesetuppipeline,prepare_analysisandanalyze_experimentsin theanalyzepipeline, andarchive_experimentsin thearchivepipeline.PackageManagerBase registers
check_auxiliary_software_filesin thesetuppipeline andadd_software_to_resultsin theanalyzepipeline.
Additionally, instances of the base classes (e.g., application, modifier, or package manager) can define and register their own phases to build more complex pipelines for specific use cases. Some examples include:
The HpcgBase base application registers
calculate_valuesin thesetuppipeline to compute grid dimensions from memory variables before experiment scripts are rendered.The Spack package manager registers
software_installanddefine_package_pathsin thesetuppipeline (extending thesoftware_create_envandsoftware_configurephases inherited from SpackLightweight).Container modifiers such as Docker and Apptainer register phases like
build_container,pull_container, andformat_docker_mountsin thesetuppipeline (alongsidedefine_container_variablesfrom ContainerBase).
Each phase is defined in two parts. The first part is to define a class method on an object definition. Phase names need to begin with an underscore, and they have the following signature:
def _new_phase_name(self, workspace, app_inst=None)
In this signature, workspace is a reference to the workspace that has a
pipeline acting on it, and app_inst is a reference to the application
instance representing the experiment. The app_inst should be identical to
self when self is an instance of an application definition.
Once the phase’s method is complete, it can be registered into a pipeline as follows:
register_phase("new_phase_name", pipeline="setup", run_before=["make_experiments"])
This example would register the phase defined by _new_phase_name into the
setup pipeline, and make sure it is executed before the make_experiments
phase. Phase registration can also define a run_after list of phases to execute
before the newly registered phase. A phase can also be registered into multiple
pipelines, by calling the register_phase directive multiple times.
Example Experiment Pipelines
The following sections illustrate the pipeline phase graphs constructed
for a common experiment workflow of ramble workspace setup → ramble on →
ramble workspace analyze using the
Hpcg
application and the
Spack
package manager. In this scenario, no phases are added
to the ramble.pipeline.ExecutePipeline by any of the objects, so we’ll only
be examining the ramble.pipeline.SetupPipeline and
ramble.pipeline.AnalyzePipeline.
Example: Setup Pipeline
CLI Command: ramble workspace setup
When SetupPipeline initializes, Ramble constructs a
PhaseGraph by combining the setup phases registered across both
Hpcg and Spack object inheritance hierarchies. Hpcg
inherits from HpcgBase
which, in turn, inherits from ApplicationBase.
Likewise, Spack
inherits from SpackLightweight
which inherits from PackageManagerBase.
This results in the following phases being registered by the associated objects:
Application Hierarchy:
Constraints |
||
|---|---|---|
Phase |
Before |
After |
base_class definition: ApplicationBase |
||
|
|
|
|
Unconstrained |
|
|
Unconstrained |
|
|
|
|
|
|
|
base_application definition: Hpcg |
||
|
|
|
application definition: Hpcg |
||
None |
||
Package Manager Hierarchy:
Constraints |
||
|---|---|---|
Phase |
Before |
After |
base_class definition: PackageManagerBase |
||
|
|
|
package_manager definition: SpackLightweight |
||
|
Unconstrained |
|
|
|
|
|
|
|
|
|
|
package_manager definition: Spack |
||
|
|
|
|
|
|
The diagram below shows the resulting PhaseGraph directed acyclic graph
(DAG), where directed connecting lines express the run_before / run_after dependencies and
nodes are colored to indicate the object hierarchy that registered them (green for the application
hierarchy, blue for the package manager hierarchy):
You’ll notice that some phases don’t have explicit constraints defined by
them at registration, but do have constraints applied indirectly on them
when other phases are registered - e.g., get_inputs has no explicit constraints
but bootstrap_utilities has a run_before=["get_inputs"] constraint and
make_experiments has a run_after=["get_inputs"] constraint. Some phases, like
license_includes, have no constraints at all, and their execution order gets
resolved by the PhaseGraph topological sort. When
PhaseGraph topologically sorts this graph, the phases are
flattened into the following execution order:
bootstrap_utilities(ApplicationBase)license_includes(ApplicationBase)calculate_values(HpcgBase)software_create_env(SpackLightweight)get_inputs(ApplicationBase)software_install_requested_compilers(SpackLightweight)software_configure(SpackLightweight)software_install(Spack)evaluate_requirements(SpackLightweight)define_package_paths(Spack)make_experiments(ApplicationBase)write_status(ApplicationBase)check_auxiliary_software_files(PackageManagerBase)
Example: Analyze Pipeline
CLI Command: ramble workspace analyze
The analyze pipeline evaluates completed experiments, extracts metrics, records software
provenance, and writes results using phases registered across the application and package
manager hierarchies. Fewer phases are registered in the
ramble.pipeline.AnalyzePipeline by the Hpcg and Spack object hierarchies:
Application Hierarchy:
ApplicationBase registers:
prepare_analysis(unconstrained)analyze_experiments(run_after=["prepare_analysis"])write_status(run_after=["analyze_experiments"])append_results_to_workspace(run_after=["analyze_experiments"])write_results_cache(run_after=["write_status", "append_results_to_workspace"])
Package Manager Hierarchy:
PackageManagerBase registers:
add_software_to_results(run_after=["analyze_experiments"],run_before=["append_results_to_workspace"])
The diagram below shows the resulting PhaseGraph DAG.
When the PhaseGraph topologically sorts this graph, the phases are
flattened into the following execution order:
prepare_analysis(ApplicationBase)analyze_experiments(ApplicationBase)write_status(ApplicationBase)add_software_to_results(PackageManagerBase)append_results_to_workspace(ApplicationBase)write_results_cache(ApplicationBase)
Exploring Experiment Pipelines
Several Ramble commands are useful for understanding what objects register phases in what pipelines, how these phased registrations are applied to a given workspace, and what the resulting ordered phase execution is for a given pipeline.
To explore and understand what phases a Ramble object registers, you can use the ramble info command:
ramble info --attributes registered_phases hpcg
ramble info --type base_classes application-base --attributes registered_phases
ramble info --type package_managers --attributes registered_phases spack
To understand what phases are registered for a given workspace, you can use the ramble workspace info command:
ramble workspace info --phases
Additional Pipelines
In addition to the previously mentioned pipelines, Ramble provides several additional pipelines:
Mirror Pipeline (
MirrorPipeline):CLI Command: ramble workspace mirror
Downloads software tarballs and workload input files into a local workspace mirror for offline execution (see Ramble Mirrors).
PushDeployment Pipeline (
PushDeploymentPipeline):CLI Command: ramble deployment push
Packages workspace configurations, software definitions, and templates into a deployment bundle suitable for distribution (see Ramble Workspace).
PushToCache Pipeline (
PushToCachePipeline):CLI Command: ramble workspace push-to-cache
Pushes compiled software environments to a Spack build cache (see Package Managers).
Bootstrap Pipeline (
BootstrapPipeline):CLI Command: ramble workspace bootstrap
Bootstraps external utilities required by the workspace (see Utilities).
Logs Pipeline (
LogsPipeline):CLI Command: ramble workspace experiment-logs
Inspects log files and archive patterns across workspace experiments (see Ramble Workspace).
Pipeline Reference Links
Pipeline Engine:
Base Class:
ramble.pipeline.PipelineExecute:
ramble.pipeline.ExecutePipelineAnalyze:
ramble.pipeline.AnalyzePipelineArchive:
ramble.pipeline.ArchivePipelineMirror:
ramble.pipeline.MirrorPipelinePushDeployment:
ramble.pipeline.PushDeploymentPipelinePushToCache:
ramble.pipeline.PushToCachePipeline
Phase Graph Engine:
Graph:
ramble.graphs.PhaseGraph
Phase Directives:
Builtins
Another component of object definitions is a builtin. These are intended to
be semi-static command blocks that should / could be injected into experiments
using this definition. Similar to phases, builtins are defined in two steps.
The first step in defining a builtin is to define a class method with the
following signature:
def new_builtin(self):
cmds = []
... add strings to cmds ...
return cmds
Once the class method is defined, the second step is to register the builtin
into the object definition. Builtin registration is accomplished using the
register_builtin directive, as follows:
register_builtin("new_builtin", required=True/False, injection_method="prepend"/"append", depends_on=[...])
When registering a builtin, the required attribute controls whether the builtin
is required to be present in experiments generated using the object or not. The
injection_method attribute controls if the commands defined by the builtin
should be at the beginning (prepend) or end (append) of the experiment.
The depends_on attribute can be used to define the ordering of multiple
builtins relative to each other. Fully qualified builtin names are passed in
here, and their named depend on which object they are defined in.