payu-org / payu

A workflow management tool for numerical models on the NCI computing systems
Apache License 2.0
18 stars 25 forks source link

Restructure order of user module load/use and setting executable paths #382

Closed jo-basevi closed 2 weeks ago

jo-basevi commented 7 months ago

As brought up in this issue #379 regarding payu being able to find the path to spack built executables. A potential solution, as suggested by @micaeljtoliveira here, was to add the following in config.yaml:

exe: $SPACK_ACCESS_OM3_ROOT/bin/access-om3-MOM6-CICE6

modules:
  use:
      - /g/data/ik11/spack/0.20.1/modules/access-om3/0.3.0/linux-rocky8-cascadelake
  load:
      - access-om3

Where SPACK_ACCESS_OM3_ROOT is set by the access-om3 module.

However currently payu runs module load/use during payu run (Experiment.run()). The paths to the executable are set earlier in the experiment initialisation and if exe is not an absolute path, it prepends the path to the laboratory bin path. The executable paths are checked and added to the manifest during setup in the model driver.

The minimum to get the above solution working, would require moving use/load user modules to Experiment.setup before any Model.setup() is run. It will also require any environment variables to be expanded in the exec_path before the path is checked and added to the manifest. To bypass the absolute path check in initialisation, the exe path will need to start with a forward slash.

I think it could be worth restructuring the Model.exec_path initialisation and setup, so executable paths are set later in Model.setup (vs at payu Experiment initialisation). This means there is no need to ensure there's a starting forward slash in exe as the path will be fully expanded to an absolute path.

As spoke about in the #379, it may be worth adding a check that user module versions are specified. At minimum, it could just be emit a warning if it is using default version.

jo-basevi commented 2 weeks ago

Closed by https://github.com/payu-org/payu/pull/439