Skip to content

How to archive a model run

Suzanne Childress edited this page May 29, 2025 · 8 revisions

πŸ—‚οΈ Archive Utility for TM2 Model Runs

This script (archive.py) compresses selected output folders from a model run directory and archives them into a .7z file.

πŸ“‹ Prerequisites

  • Anaconda installed
  • A Conda environment with the required packages:
    conda create -n tm2py-utils python=3.10 py7zr tqdm
    conda activate tm2py-utils
  • 7-Zip CLI (7z.exe or 7z) placed in the repository’s bin/ folder.

πŸ“ Repository Structure (relative paths)

Assuming you cloned your repo into C:\GitHub\tm2py-utils (or ~/GitHub/tm2py-utils):

tm2py-utils/
β”œβ”€β”€ bin/
β”‚   └── 7z.exe
β”œβ”€β”€ tm2py_utils/
β”‚   └── scripts/
β”‚       └── archive.py
└── README.md
  • 7z executable: bin/7z.exe
  • Archive script: tm2py_utils/scripts/archive.py

πŸ”§ Run the script

From a terminal in the repo root (C:\GitHub\tm2py-utils):

1. start python

python

2. read in the necessary function

from tm2py_utils.scripts.archive import archive

3. run the archive function
 
archive(r'C:\path\to\model\run\directory', r'C:\path\to\archive\run\directory', 'runlabel')

🧠 Notes

  • Default excludes: emme_project/*/emmemat
  • Chunks files in groups of 100 (change CHUNK_SIZE in code)
  • Uses the 7z CLI for speed over the Python py7zr library