---
# System prepended metadata

title: '"Manually" updating PEcAn.ED / ED2 singularity container on HPC'

---

# "Manually" updating PEcAn.ED / ED2 singularity container on HPC

## NOTE:
I never got this to work.  The docker containers don't run for reasons I don't understand.
There are only 2 possibilities currently for ED versions because there is only one release tag---v.2.2.0.  So its either that or the development version "git".  If you want a specific commit, you'll have to edit the code in the Dockerfile to `git checkout` a specific SHA.

### Why would you want to do this?
When running ED2 models on the HPC, you might want to:
- use the development version of ED2 when the [container on docker hub](https://hub.docker.com/r/pecan/model-ed2-git) isn't updated
- use a version of PEcAn.ED2 other than the develop branch or the latest release (e.g. a PR you're working on)
- use some custom combination of PEcAn and ED2 versions

## New container naming convention:

`pecan-<PEcAn version>_ed2-<ED2 version>`

Where `<version>` is either a release number or a git hash

For example:
- `pecan-4ab3977_ed2-125f814` for development versions of both
- `pecan-4ab3977_ed2-2.2` for development pecan, latest release of ED2
- `pecan-1.7.2_ed2-125f814` for latest release of PEcAn and development version of ED2

Use this name consistently for the name of the docker container, .tar file, .sif file, and .sh files created in the steps below.

## Steps:

1. Clone pecan repo
2. Checkout whatever branch or PR you want to build PEcAn.ED from
3. Open Terminal, navigate to pecan/models/ed
4. Build docker image with most recent commit of ED2
    - `docker build -t pecan-<version>_ed2-<version> --build-arg MODEL_VERSION=git .`
    - Omit `--build-arg MODEL_VERSION=git` to use the latest release (default) or supply a version number instead of "git"
5. Save docker image as .tar file
    - `docker save -o pecan-<version>_ed2-<version>.tar pecan-<version>_ed2-<version>`
6. Transfer .tar image to HPC (this will take a while)
    ```
    rsync -avz pecan-<version>_ed2-<version>.tar ericrscott@filexfer.hpc.arizona.edu:/groups/dlebauer/ed2_results/global_inputs/ --log-file=hpc-user-rsync.log
    ```
6. SSH into HPC and request interactive session with `interactive`
7. Navigate to /groups/dlebauer/ed2_results/global_inputs/
8. Build singularity container from docker image .tar file
    ```
    singularity build pecan-<version>_ed2-<version>.sif docker-archive://pecan-<version>_ed2-<version>.tar
    ```
8. Copy `ed2_2.2.0_singularity.sh` to `pecan-<version>_ed2-<version>.sh` and edit the last line to use the new .sif file

    ```
    #!/bin/bash
    
    module load singularity
    pwd
    singularity run --pwd=$(pwd) --contain \
    -B /groups/dlebauer/ed2_results/pecan_remote:/groups/dlebauer/ed2_results/pecan_remote \
    -B /groups/dlebauer/ed2_results/inputs/julianp/sites:/data/sites \
    -B /groups/dlebauer/ed2_results/inputs/julianp/ed_inputs:/data/ed_inputs \
    -B /groups/dlebauer/ed2_results/inputs/julianp/faoOLD:/data/faoOLD \
    -B /groups/dlebauer/ed2_results/inputs/julianp/oge2OLD:/data/oge2OLD \
    -B /groups/dlebauer/ed2_results/inputs/julianp/tests/ed2:/data/tests/ed2 \
    /groups/dlebauer/ed2_results/global_inputs/pecan-<version>_ed2-<version>.sif /usr/local/bin/ed.2.2.0 -s
    ```
10. On Welsch, modify your pecan.xml to point to this .sh file as the binary
    ```
     <model>
       <type>ED2</type>
       <binary>/groups/dlebauer/ed2_results/global_inputs/ed2_git_singularity.sh</binary>
    ```

## Existing Containers:
pecan-[2bb62f959](https://github.com/PecanProject/pecan/tree/2bb62f959ccda4d9a7731f9d6c52a735eeff9abe)_ed2-[125f814](https://github.com/EDmodel/ED2/tree/125f814dbbd7c258cf623254ca9554a7e59807fd):
- bugfixes in `PEcAn.ED::model2netcdf.ED2()` in PR #3021
- bugfixes in `ED2` relating to snow

## To make:
pecan-[4ab3977](https://github.com/PecanProject/pecan/tree/4ab397792cb6d1a6ed73aedfe98649ac05d7ce49)_ed2-[125f814](https://github.com/EDmodel/ED2/tree/125f814dbbd7c258cf623254ca9554a7e59807fd): 
- fixes in ED2 but dev version of PEcAn