Skip to content

Commit

Permalink
Add Spack setup runner
Browse files Browse the repository at this point in the history
  • Loading branch information
nick-stroud committed Sep 30, 2022
1 parent 000ac6a commit 5f2dde7
Show file tree
Hide file tree
Showing 3 changed files with 51 additions and 10 deletions.
8 changes: 1 addition & 7 deletions community/examples/AMD/hpc-cluster-amd-slurmv5.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -77,13 +77,7 @@ deployment_groups:
source: modules/scripts/startup-script
settings:
runners:
- type: data
destination: /etc/profile.d/spack.sh
content: |
#!/bin/sh
if [ -f /sw/spack/share/spack/setup-env.sh ]; then
. /sw/spack/share/spack/setup-env.sh
fi
- $(spack.setup_spack_runner)
# the following installation of AOCC may be automated in the future
# with a clear direction to the user to read the EULA at
# https://developer.amd.com/aocc-compiler-eula/
Expand Down
39 changes: 36 additions & 3 deletions community/modules/scripts/spack-install/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -112,13 +112,45 @@ Alternatively, it can be added as a startup script via:
settings:
runners:
- $(spack.install_spack_deps_runner)
- type: shell
content: $(spack.startup_script)
destination: "/sw/spack-install.sh"
- $(spack.install_spack_runner)
```

[spack-gromacs.yaml]: ../../../examples/spack-gromacs.yaml

## Environment Setup

[Spack installation] produces a setup script that adds `spack` to your `PATH` as
well as some other command-line integration tools. This script can be found at
`<install path>/share/spack/setup-env.sh`. This script will be automatically
added to bash startup by the `install_spack_runner`. In the case that you are
using Spack on a different machine than the one where Spack was installed, you
can use the `setup_spack_runner` to make sure Spack is also available on that
machine.

[Spack installation]: https://spack-tutorial.readthedocs.io/en/latest/tutorial_basics.html#installing-spack

### Example using `setup_spack_runner`

The following examples assumes that a different machine is running
`$(spack.install_spack_runner)` and the Slurm login node has access to the Spack
instal through a shared file system.

```yaml
- id: spack
source: community/modules/scripts/spack-install
...

- id: spack-setup
source: modules/scripts/startup-script
settings:
runners:
- $(spack.setup_spack_runner)

- id: slurm_login
source: community/modules/scheduler/SchedMD-slurm-on-gcp-login-node
use: [spack-setup, ...]
```

## License

<!-- BEGINNING OF PRE-COMMIT-TERRAFORM DOCS HOOK -->
Expand Down Expand Up @@ -182,5 +214,6 @@ No resources.
| <a name="output_controller_startup_script"></a> [controller\_startup\_script](#output\_controller\_startup\_script) | Path to the Spack installation script, duplicate for SLURM controller. |
| <a name="output_install_spack_deps_runner"></a> [install\_spack\_deps\_runner](#output\_install\_spack\_deps\_runner) | Runner to install dependencies for spack using the startup-script module<br>This runner requires ansible to be installed. This can be achieved using the<br>install\_ansible.sh script as a prior runner in the startup-script module:<br>runners:<br>- type: shell<br> source: modules/startup-script/examples/install\_ansible.sh<br> destination: install\_ansible.sh<br>- $(spack.install\_spack\_deps\_runner)<br>... |
| <a name="output_install_spack_runner"></a> [install\_spack\_runner](#output\_install\_spack\_runner) | Runner to install Spack using the startup-script module |
| <a name="output_setup_spack_runner"></a> [setup\_spack\_runner](#output\_setup\_spack\_runner) | Adds Spack setup-env.sh script to /etc/profile.d so that it is called at shell startup. Among other things this adds Spack binary to user PATH. |
| <a name="output_startup_script"></a> [startup\_script](#output\_startup\_script) | Path to the Spack installation script. |
<!-- END OF PRE-COMMIT-TERRAFORM DOCS HOOK -->
14 changes: 14 additions & 0 deletions community/modules/scripts/spack-install/outputs.tf
Original file line number Diff line number Diff line change
Expand Up @@ -43,3 +43,17 @@ output "install_spack_runner" {
description = "Runner to install Spack using the startup-script module"
value = local.install_spack_runner
}

output "setup_spack_runner" {
description = "Adds Spack setup-env.sh script to /etc/profile.d so that it is called at shell startup. Among other things this adds Spack binary to user PATH."
value = {
"type" = "data"
"destination" = "/etc/profile.d/spack.sh"
"content" = <<-EOT
#!/bin/sh
if [ -f ${var.install_dir}/share/spack/setup-env.sh ]; then
. ${var.install_dir}/share/spack/setup-env.sh
fi
EOT
}
}

0 comments on commit 5f2dde7

Please sign in to comment.