Skip to content
LinkState
Go back

Deterministic Enough Means Defining a Repeatability Contract

Introduction to Repeatability Contracts

Repeatability in Continuous Integration (CI) labs refers to the ability to reproduce identical results across multiple runs of a pipeline, given the same inputs and conditions. This concept is crucial for ensuring the reliability, consistency, and trustworthiness of CI pipelines. A repeatability contract is an explicit agreement that defines what must be identical across runs, what variance is acceptable, and which deviations should fail the pipeline immediately.

Benefits and Components of Repeatability Contracts

Explicit repeatability contracts offer several benefits, including:

To ensure repeatability, the following components must be considered:

Environment Variables and Dependencies

Input Data and Configuration Files

Infrastructure and Hardware Requirements

Acceptable Variance Budget

Some deviations in input data may be tolerable, such as:

Permissible variations in environment and infrastructure may include:

Variance in output results must be quantified and managed, including:

Deviations Requiring Immediate Pipeline Failure

Critical environment and infrastructure discrepancies require immediate pipeline failure, including:

Unacceptable input data or configuration anomalies require immediate pipeline failure, including:

Output results outside of acceptable tolerance ranges require immediate pipeline failure, including:

Implementing Repeatability Contracts in CI Pipelines

Version control systems (e.g., Git) can be used to manage dependencies and ensure consistent versions, including:

Containerization (e.g., Docker) can be used to ensure consistent environments, including:

Example code for repeatability contract enforcement may include:

import os
import git

REPEATABILITY_CONTRACT_SETTINGS = {
    'environment_variables': ['VARIABLE1', 'VARIABLE2'],
    'dependencies': ['DEPENDENCY1', 'DEPENDENCY2'],
    'input_data': ['INPUT_DATA1', 'INPUT_DATA2'],
    'tolerance_ranges': {'OUTPUT_RESULT1': (0.9, 1.1), 'OUTPUT_RESULT2': (0.8, 1.2)}
}

for variable in REPEATABILITY_CONTRACT_SETTINGS['environment_variables']:
    if variable not in os.environ:
        raise Exception(f"Environment variable {variable} not set")

for dependency in REPEATABILITY_CONTRACT_SETTINGS['dependencies']:
    if not git.check_dependency(dependency):
        raise Exception(f"Dependency {dependency} not met")

for input_data in REPEATABILITY_CONTRACT_SETTINGS['input_data']:
    if not os.path.exists(input_data):
        raise Exception(f"Input data {input_data} not found")

for output_result, tolerance_range in REPEATABILITY_CONTRACT_SETTINGS['tolerance_ranges'].items():
    if not (tolerance_range[0] <= output_result <= tolerance_range[1]):
        raise Exception(f"Output result {output_result} outside of tolerance range")

Troubleshooting Repeatability Issues

Variance sources can be identified and debugged using:

Pipeline logs can be analyzed for repeatability-related errors, including:

CLI examples for troubleshooting repeatability contract failures may include:

# Check pipeline logs for errors
grep -i "error" pipeline.log

# Check environment variables
printenv VARIABLE1

# Check dependencies
pip list DEPENDENCY1

Scaling Repeatability Contracts

Repeatability contracts may have limitations in large-scale CI labs, including:

Strategies for scaling repeatability contract enforcement may include:

Performance impacts of repeatability contract checks can be mitigated using:

Code Examples and CLI Commands

Sample repeatability contract configuration files may include:

repeatability_contract:
  environment_variables:
    - VARIABLE1
    - VARIABLE2
  dependencies:
    - DEPENDENCY1
    - DEPENDENCY2
  input_data:
    - INPUT_DATA1
    - INPUT_DATA2
  tolerance_ranges:
    OUTPUT_RESULT1: (0.9, 1.1)
    OUTPUT_RESULT2: (0.8, 1.2)

CLI commands for repeatability contract enforcement and troubleshooting may include:

# Check repeatability contract settings
repeatability_contract check

# Run pipeline with repeatability contract enforcement
pipeline_run --repeatability-contract

# Troubleshoot repeatability contract failures
repeatability_contract troubleshoot

Example scripts for automating repeatability contract checks may include:

import os
import git

REPEATABILITY_CONTRACT_SETTINGS = {
    'environment_variables': ['VARIABLE1', 'VARIABLE2'],
    'dependencies': ['DEPENDENCY1', 'DEPENDENCY2'],
    'input_data': ['INPUT_DATA1', 'INPUT_DATA2'],
    'tolerance_ranges': {'OUTPUT_RESULT1': (0.9, 1.1), 'OUTPUT_RESULT2': (0.8, 1.2)}
}

for variable in REPEATABILITY_CONTRACT_SETTINGS['environment_variables']:
    if variable not in os.environ:
        print(f"Environment variable {variable} not set")

for dependency in REPEATABILITY_CONTRACT_SETTINGS['dependencies']:
    if not git.check_dependency(dependency):
        print(f"Dependency {dependency} not met")

for input_data in REPEATABILITY_CONTRACT_SETTINGS['input_data']:
    if not os.path.exists(input_data):
        print(f"Input data {input_data} not found")

for output_result, tolerance_range in REPEATABILITY_CONTRACT_SETTINGS['tolerance_ranges'].items():
    if not (tolerance_range[0] <= output_result <= tolerance_range[1]):
        print(f"Output result {output_result} outside of tolerance range")

Best Practices for Maintaining Repeatability Contracts

Repeatability contracts should be regularly reviewed and updated to ensure:

Consistency across multiple CI pipelines can be ensured by:

Repeatability contract rationale and decisions should be documented to ensure:


Share this post on:

Previous Post
ECMP failover across unequal policy domains
Next Post
Telemetry lag or real stability after a phase