message_ix_models.model.transport.slurm.TEMPLATE
- message_ix_models.model.transport.slurm.TEMPLATE = ['sbatch', '--job-name={J}', '--mem=40G', '--output=/home/{username}/slurm/message-%J.out', '--time=2:00:00', '#!/bin/sh\nset -e\n\ndate\n\n# Paths\nHHOME=/hdrive/u045/{username}\nVENV=$SLURM_TMPDIR/venv/3.13\nSHARED_SCRATCH=/sharedscratch\nREPORT_DIR=/pdrive/projects/ene.model3/MESSAGEix-Transport\n\n# Work around an issue in pint\nexport IAM_UNITS_CACHE=$SLURM_TMPDIR/cache/iam-units\nexport IXMP_DATA=$SLURM_TMPDIR/ixmp\nexport MESSAGE_LOCAL_DATA=$SLURM_TMPDIR/message-local-data\nexport MESSAGE_MODELS_CACHE=$SHARED_SCRATCH/cache/message-ix-models\nSTATIC_DATA=$SHARED_SCRATCH/message-static-data\n\n\n# Activate lmod for the current shell\n. /opt/apps/lmod/8.7/init/sh\n\n# Load module(s)\nmodule load gams git git-lfs Java\n\n# git-lfs: install global configuration\ngit lfs install\n\n# ssh: add host keys for gitlab.iiasa.ac.at\nssh-keyscan -p 2222 gitlab.iiasa.ac.at | tee -a ~/.ssh/known_hosts\nssh-keygen -Hf ~/.ssh/known_hosts\n\n# uv: use UV from personal home directory\nUV=$HHOME/.local/bin/uv\n# Store cache in the shared-scratch disk mounted on runners\nexport UV_CACHE_DIR=$SHARED_SCRATCH/uv-cache\n# Shared-scratch and the job work directory are on different filesystems; silence an uv\n# warning about this\nexport UV_LINK_MODE=copy\n\n# Clone message-static-data to shared scratch\n# rm -rf $STATIC_DATA\n[ -d $STATIC_DATA ] || GIT_CLONE_PROTECTION_ACTIVE=false git clone ssh://git@gitlab.iiasa.ac.at:2222/ece/message-static-data.git $STATIC_DATA\ndate\n\n# Symlink message-static-data into local data\nmkdir -p $MESSAGE_LOCAL_DATA\ncp -frsv $STATIC_DATA/* $MESSAGE_LOCAL_DATA/\ndate\n\n# - Create and activate a virtual environment.\n# - Use the system Python. TODO Use Python 3.14\n$UV --verbose venv --python=3.13 $VENV\n. $VENV/bin/activate\ndate\n\n# Install\n# - message-ix-models from IIASA GitLab.\n# - message-ix-buildings from GitHub (not on PyPI).\n# - message-ix and other dependencies from PyPI.\n# - dask to work around https://github.com/khaeru/genno/issues/171\n$UV pip install \\\n "dask < 2025.4.0" \\\n "message-ix-buildings @ git+https://github.com/iiasa/message-ix-buildings.git" \\\n "message-ix-models[buildings,tests,transport] @ git+https://gitlab.iiasa.ac.at/ece/message-ix-models.git@transport/2025-w44"\ndate\n\n# Show what was installed\nmessage-ix show-versions\n\n# Copy config file for ixmp et al. to the worker node for possible modification\n# This file contains connection details for the ixmp-dev platform\nmkdir -p $IXMP_DATA\ncp $HHOME/.local/share/ixmp/config.json $IXMP_DATA/config.json\n\n# Create cache directory\nmkdir -p $MESSAGE_MODELS_CACHE\n\n# Run the workflow\ndate\nmix-models --platform=ixmp-dev transport run \\\n --base=auto --fast --nodes=R12 --model-extra=dev \\\n {mix_models_args} \\\n --go\ndate\n\n# Transfer files from worker to shared/permanent disk\ncp -rv $MESSAGE_LOCAL_DATA/report $MESSAGE_LOCAL_DATA/transport $REPORT_DIR/\ndate\n']
Template for use with mix-models sbatch. Example usage:
mix-models sbatch -m model.transport --remote --username=foo --go -- \ "--base=auto --fast --nodes=R12 --model-extra='debug' --from='' 'SSP2 reported'"
The script performs the following actions, tailored for the IIASA ‘UniCC’ cluster and SLURM:
Load necessary modules.
Use uv to install
message_ix_modelsand dependencies.Run mix-models transport run --go with additional arguments.
Copy output files (e.g. reporting) to a shared drive.