---
# System prepended metadata

title: Updating ED2 and PEcAn.ED2 container on HPC
tags: [PEcAn]

---

---
tags: PEcAn
---
# Updating ED2 and PEcAn.ED2 container on HPC

###### tags: `PEcAn`, `Welsch`, `HPC`


When a PR is merged into the develop branch in the [PEcAn repository](https://github.com/PecanProject/pecan), a [GitHub action](https://github.com/PecanProject/pecan/actions/workflows/docker.yml) is triggered to build two docker containers and push them to docker hub:
    1. [pecan/model-ed2-2.2.0](https://hub.docker.com/r/pecan/model-ed2-2.2.0), which has the latest release of ED2 (v2.2.0)
    2. [pecan/model-ed2-git](https://hub.docker.com/r/pecan/model-ed2-git), which has the development version of ED2[^1]
    
Each of these two containers also have 'tags' for version of PEcAn.  For example `pecan/model-ed2-2.2.0:latest` is a container with the latest release of `PEcAn.ED2` and the last release of `ED2` (v2.2.0).  `pecan/model-ed2-2.2.0:develop` has the last release of `ED2` and the development version of `PEcAn.ED2`.  `pecan/model-ed2-git:develop` has the development versions of both `ED2` and `PEcAn.ED2`, and so on.

Here I'll outline the process of updating to use the development version of both `ED2` and `PEcAn.ED2`

1. Log into the HPC and request an interactive session by typing `interactive` (using El Gato and specifying an account with `-a kristinariemer` will get you a session faster)
2. Navigate to `/groups/kristinariemer/ed2_results/global_inputs/`
3. Pull down a docker container to create a new singularity .sif file.  For the name, use `pecan-<version>_ed2-<version>.sif` to keep track of what combination of ED2 and PEcAn.ED2 is in the file.
    ```
    singularity pull pecan-dev_ed2-dev.sif docker://pecan/model-ed2-git:develop
    ```
4. Copy an existing .sh file to a new one with the same naming scheme
    ```
    cp pecan-dev_ed2-2.2.0.sh pecan-dev_ed2-dev.sh
    ```
5. Open the .sh file in an editor and edit the last line
    ```
    
    #!/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/data/sites:/data/sites \
    -B /groups/dlebauer/data/ed_inputs:/data/ed_inputs \
    -B /groups/dlebauer/data/faoOLD:/data/faoOLD \
    -B /groups/dlebauer/data/oge2OLD:/data/oge2OLD \
    -B /groups/dlebauer/ed2_results/inputs/julianp/tests/ed2:/data/tests/ed2 \
    /groups/dlebauer/ed2_results/global_inputs/pecan-dev_ed2-dev.sif /usr/local/bin/ed.git -s
    ```
    Be sure to edit this in **two** places on the last line: edit the .sif file name **and** the path to the ED2 binary (this path is *inside* the docker container) if necessary.  For the `pecan/model-ed2-git` container, the ED2 binary file should be named `ed.git` and for `pecan/model-ed2-2.2.0` it should be named `ed.2.2.0`
    
6. Edit your `pecan.xml` file in **two** places to use this new container

    ```
    <model>
      <type>ED2</type>
      <binary>/groups/dlebauer/ed2_results/global_inputs/pecan-dev_ed2-dev.sh</binary>
      <edin>ED2IN.r2.2.0.github</edin>
    ```
   - `<binary>` should point to the new .sh file
   - `<edin>` should be the name of an ED2IN file[^1] found in [pecan/models/ed/inst](https://github.com/PecanProject/pecan/tree/develop/models/ed/inst)  Alternatively, supply `<revision>2.2.0.github</revision>`

7. Make sure the version of `PEcAn.ED2` is up to date on Welsch also!

Now your PEcAn run should use the updated docker container with your specified versions of PEcAn.ED2 and ED2!

[^1]:A new version of ED2 may require a new ED2IN file in [PEcAn/models/ed/inst/](https://github.com/PecanProject/pecan/tree/develop/models/ed/inst). Look for any recent changes to [ED/run/ED2IN](https://github.com/EDmodel/ED2/blob/master/ED/run/ED2IN).  If there are recent changes (e.g. new variables), create a PR for PEcAn where you create a new ED2IN file based on an old one, but with any new variables or changes (and potentially set defaults for them).  This PR will need to be merged before the updated docker container is built and you can go through these steps.  In the meantime, you can add any new variables to `pecan.xml` with the `<ed2in_tags>` tag without having to edit the ED2IN file.