Skip to content

cmor‐fixer container

Thomas Reerink edited this page Nov 14, 2024 · 7 revisions

The cmor-fixer can be used from a containerized environment. This cmor-fixer container has been set up by NSC.

For a real case use scenario, see the final guidance at the botttom.

Installation of Apptainer (= singularity) on Ubuntu (see here) for a non-setuid installation:

sudo apt update
sudo apt install -y software-properties-common
sudo add-apt-repository -y ppa:apptainer/ppa
sudo apt update
sudo apt install -y apptainer

Test the availability of singularity for your system:

singularity --version    # Giving: apptainer version 1.3.4

Download the gitlab cmor-fixer_env container environment:

cd ${HOME}/cmorize/
git clone https://gitlab.liu.se/NSC/esgf/cmor-fixer_env.git
#git clone git@gitlab.liu.se:NSC/esgf/cmor-fixer_env.git        # requires an NSC gitlab account and setting your SSH key

Create the cmor-fixer environment inside the container:

cd cmor-fixer_env/
sudo singularity build cmorfixerenv.simg Singularity

This ends with:

 #                                                                                                                                                                                                                 
 # To activate this environment, use                                                                                                                                                                               
 #                                                                                                                                                                                                                 
 #     $ conda activate cmorfixer                                                                                                                                                                                  
 #                                                                                                                                                                                                                 
 # To deactivate an active environment, use                                                                                                                                                                        
 #                                                                                                                                                                                                                 
 #     $ conda deactivate                                                                                                                                                                                          

 INFO:    Creating SIF file...                                                                                                                                                                                     
 INFO:    Build complete: cmorfixerenv.simg

To initialize container (and mount):

 singularity shell --bind ${HOME}/cmorize:/mnt ${HOME}/cmorize/cmor-fixer_env/cmorfixerenv.simg

Here ${HOME}/cmorize is mounted at mountpoint /mnt/

In case, for leaving the apptainer container environment use:

exit

Using the cmor-fixer from the container (v4.0):

source /etc/bashrc
activatecmorfixer
script -c '/opt/cmor_fixer/cmor-fixer/cmor-fixer.py --verbose --forceid --olist $HOME/outputdir --npp 1 --dry testfiles/CMIP6/' scriptout_cmorfix_dryrunscript -c '/opt/cmor_fixer/cmor-fixer/cmor-fixer.py --verbose --forceid --olist $HOME/outputdir --npp 1 --dry testfiles/CMIP6/' scriptout_cmorfix_dryrun

Using the cmor-fixer from the container with a mounted path:

script -c '/opt/cmor_fixer/cmor-fixer/cmor-fixer.py --verbose --forceid --olist $HOME/outputdir --npp 1 --dry /mnt/cmor-fixer/cmorfixer-test-data/test-set-01/CMIP6/' scriptout_cmorfix_dryrun

The real use case, using the wrapper:

After the installation, from a fresh terminal from any location, without the need of first being inside the container (actually take care that you have left the container environment before calling singularity itself because it won't be recognized inside the container itself):

singularity exec --bind ${HOME}/cmorize/cmor-fixer_env/testfiles/:/mnt ${HOME}/cmorize/cmor-fixer_env/cmorfixerenv.simg bash /opt/scripts/cmorfixerwrapper.sh --verbose --olist $HOME/log-dir --npp 2 --meta /mnt/recipe.json --dry ${HOME}/cmorize/cmor-fixer_env/testfiles/CMIP6/