Prism Template Format - Advanced Guide¶
This document describes the technical details of the YAML template format used by Prism to define research environment templates.
Overview¶
Templates define the steps needed to build an Amazon Machine Image (AMI) for a specific research environment. Templates are written in YAML format and include metadata, build steps, and validation tests.
Template Structure¶
A template consists of the following sections:
name: template-name
description: A description of the template
base: base-image-name
architecture: x86_64 # or arm64
build_steps:
- name: Step name
script: |
# Commands to run
timeout_seconds: 600 # Optional
validation:
- name: Test name
script: |
# Commands to run for validation
Required Fields¶
| Field | Description |
|---|---|
name | A unique identifier for the template |
description | A human-readable description of the environment |
base | The base AMI to start from (e.g., ubuntu-22.04-server-lts) |
architecture | The CPU architecture (x86_64 or arm64) |
build_steps | A list of build steps to create the environment |
Build Steps¶
Each build step consists of:
| Field | Description |
|---|---|
name | A descriptive name for the step |
script | The shell script to execute |
timeout_seconds | (Optional) Maximum execution time in seconds (default: 600) |
Validation Tests¶
Validation tests verify that the environment was built correctly:
| Field | Description |
|---|---|
name | A descriptive name for the test |
script | The shell script to execute for validation |
Example Template¶
name: python-ml
description: Python environment with machine learning libraries
base: ubuntu-22.04-server-lts
architecture: x86_64
build_steps:
- name: Update system packages
script: |
apt-get update
apt-get upgrade -y
timeout_seconds: 300
- name: Install system dependencies
script: |
apt-get install -y build-essential python3-pip git curl
timeout_seconds: 600
- name: Install Python packages
script: |
pip3 install numpy pandas scikit-learn tensorflow torch
timeout_seconds: 1200
validation:
- name: Verify Python installation
script: python3 --version
- name: Verify ML libraries
script: |
python3 -c "import numpy; import pandas; import sklearn; import tensorflow; import torch; print('All libraries loaded')"
Best Practices¶
General Tips¶
- Idempotent Scripts: Ensure your scripts are idempotent (can be run multiple times safely)
- Error Handling: Include error checking in critical scripts
- Timeouts: Set appropriate timeouts for long-running operations
- Clear Names: Use descriptive names for steps and tests
- Comments: Add comments to explain complex operations
- Dependencies: Install all required dependencies explicitly
- Validation: Include comprehensive validation tests
Build Step Recommendations¶
- Start with system updates
- Install system packages before language-specific packages
- Use non-interactive installation flags where possible (
-y,DEBIAN_FRONTEND=noninteractive, etc.) - For large installations, split into multiple build steps
- Specify versions for critical software components
- Clean up temporary files to reduce AMI size
Validation Recommendations¶
- Test every major component installed
- Verify configurations are correct
- Check that services are running if applicable
- Test actual functionality, not just presence of binaries
- Keep validation scripts simple and focused
Template Organization¶
Prism templates are organized by research domain:
/templates/python-research.yaml: Python data science environment/templates/neuroimaging.yaml: Neuroimaging tools (FSL, AFNI, etc.)/templates/bioinformatics.yaml: Bioinformatics tools (BWA, GATK, etc.)/templates/gis-research.yaml: GIS and spatial analysis tools
Common Base Images¶
Prism supports multiple base images:
ubuntu-22.04-server-lts: Standard Ubuntu 22.04 LTS serverubuntu-22.04-server-lts-arm64: ARM64 version of Ubuntu 22.04 LTS
Adding New Templates¶
To add a new template:
- Create a YAML file in the
/templatesdirectory - Follow the format described above
- Test your template with
prism ami validate my-template.yaml - Build the AMI with
prism ami build my-template.yaml
Testing Templates¶
Test your template before building: