Spack installation#

Spack is a package manager for easy sofwtare installation from Linux laptops to supercomputers.

Following the instructions below, installing gym-DSSAT is as easy as typing:

spack install gym-dssat

Creating gym-dssat-pdi Spack environment#

Step #1: Setup#

To use it, you should first setup spack:

# 1. Get and enable Spack (version 0.19.0, last stable when writing this text)
git clone --branch v0.19.0 -c feature.manyFiles=true
. spack/share/spack/

# 2. Get and enable PDI spack repo
git clone spack/var/spack/repos/pdi
spack repo add spack/var/spack/repos/pdi

# 3. Get and enable this spack repo
git clone spack/var/spack/repos/gym-dssat-pdi
spack repo add spack/var/spack/repos/gym-dssat-pdi

Step #2: Installation#

spack install gym-dssat

Step #3: Create gym-dssat-pdi Spack environment#

Spack environments make it easier to use the software installed via Spack. The recipe for the gym-dssat-pdi environment we have prepared is the file spack.yaml provided in spack/var/spack/repos/gym-dssat-pdi/env. Once activated, this environment provides a specific view of the gym-dssat-pdi installation in spack/gymdssat_env.

To create and activate the environment:

# Create the Spack environment from the recipe
spack env create gym-dssat-pdi spack/var/spack/repos/gym-dssat-pdi/env/spack.yaml

A view has been created for this environment in $HOME/gymdssat_spackenv

Using gym-dssat-pdi Spack environment#

Step #1: Get easy access to Spack commands#

In this example, Spack has been installed in the user home: /home/emilioj/.

. /home/emilioj/spack/share/spack/

Step #2A: Activate it#

spack env activate gym-dssat-pdi

You can check it is activated with
spack env status

(Step #2B: Concretize the environment to get a unified/integrated ‘view’ of gym-dssat-pdi)#

This is only needed the first time or whenever we introduce changes in the environment!

spack concretize

Step #3: Use gym-dssat-pdi Spack environment#

Once we have an activated concretized environment we can use gym-dssat-pdi, in a similar way to using python venvs.

For example:

$ which python

$ python
>>> import gym
>>> env = gym.make('gym_dssat_pdi:GymDssatPdi-v0')

On the environment is activated, you can install additional Python packages you need with pip.

We can also run the example bundled with gym-dssat:

$ python gymdssat_spackenv/lib/python3.10/site-packages/gym_dssat_pdi_samples/

Step #4: Dectivate it#

To go back to your normal Python environment, type:

spack env deactivate