Using containers in COMPS

You can use the Singularity container files (.sif) for running simulations on COMPS.

Run a job in COMPS with Singularity

idmtools includes examples to help you get up and running with Singularity on COMPS. First, you can run the script, located in examples/singularity/ubuntu-20-04/ This script creates an Ubuntu Singularity container based on the included definition file, ubuntu_20_04_base.def, and writes it to an asset collection on COMPS.

if __name__ == '__main__':
platform = Platform("CALCULON")
sbi = SingularityBuildWorkItem(name="Create ubuntu sif with def file", definition_file="ubuntu_20_04_base.def", image_name="ubuntu.sif")
sbi.tags = dict(ubuntu="20.04"), platform=platform)
if sbi.succeeded:
    # Write ID file

Once you have the required Linux .sif container file, you can then add your modeling files. For example,, located in examples/singularity/covasim/, uses the pre-created ubuntu container and associated asset collection id to create a new .sif container file for running simulations using Covasim.

if __name__ == '__main__':
platform = Platform("CALCULON")
sbi = SingularityBuildWorkItem(name="Create covasim sif with def file", definition_file="covasim_req.def", image_name="covasim_ubuntu.sif")
# Try to load the ubuntu image from an id file
pwd = PurePath(__file__).parent
ub_base = pwd.joinpath("..", "ubuntu-20-04")
fp = pwd.joinpath("")
sbi.tags = dict(covasim=None), platform=platform)
if sbi.succeeded:

As the following example script,, shows you can run simulations in a Singularity container on COMPS using the previously created .sif container file.

import os
import sys
from functools import partial
from idmtools.assets import AssetCollection
from import SimulationBuilder
from idmtools.core.platform_factory import Platform
from idmtools.entities import CommandLine
from idmtools.entities.command_task import CommandTask
from idmtools.entities.experiment import Experiment
from idmtools.entities.templated_simulation import TemplatedSimulations

def set_value(simulation, name, value):
    fix_value = round(value, 2) if isinstance(value, float) else value
    # add argument
    # add tag with our value
    simulation.tags[name] = fix_value

if __name__ == "__main__":
    here = os.path.dirname(__file__)
    # Create a platform to run the workitem
    platform = Platform("CALCULON")
    # create commandline input for the task
    command = CommandLine(f"singularity exec ./Assets/covasim_ubuntu.sif python3 Assets/")
    task = CommandTask(command=command)
    ts = TemplatedSimulations(base_task=task)
    # Add our image
    sb = SimulationBuilder()
    # Add sweeps on 3 parameters. Total of 1680 simulations(6x14x21)
    sb.add_sweep_definition(partial(set_value, name="pop_size"), [10000, 20000])
    sb.add_sweep_definition(partial(set_value, name="pop_infected"), [10, 100, 1000])
    sb.add_sweep_definition(partial(set_value, name="n_days"), [100, 110, 120])
    sb.add_sweep_definition(partial(set_value, name="rand_seed"), [1234, 4567])

    experiment = Experiment.from_template(ts, name=os.path.split(sys.argv[0])[1])
    experiment.add_asset(os.path.join("inputs", ""))
    experiment.add_asset(os.path.join("inputs", ""))
    if experiment.succeeded: