`verdi code test` failed for new `uenv` system in CSCS

I am running CP2K on Eiger, and CSCS provides the latest versions of CP2K via User Environments (UENV).

The process requires users to pull the image for a specific code (such as CP2K) and start the environment. However, the executable path only becomes available after the environment is activated. This causes an issue when testing the code in AiiDA:

$ verdi code test 13939
Critical: validation failed: The provided remote absolute path `/user-environment/env/cp2k/bin/cp2k.psmp` does not exist on the computer.

Despite the error during the test, the CP2K calculations run successfully.

To help others, here’s the YAML file I use to set up the CP2K code with uenv:

---
label: cp2k-psmp-2024.3
description: CP2K v2024.3 from uenv
default_calc_job_plugin: cp2k
computer: 'eiger'
filepath_executable: /user-environment/env/cp2k/bin/cp2k.psmp
prepend_text: |
    uenv view cp2k

    export OMP_NUM_THREADS=1
    export MPICH_MALLOC_FALLBACK=1

    ulimit -s unlimited
append_text: ' '

When running the calculation, it’s necessary to load the CP2K environment by specifying it in the job options as shown below:

metadata = {"options": {
                    'custom_scheduler_commands': '#SBATCH --uenv=cp2k/2024.3:v1',
            }

Hi Xing, this can be a problem. If you load the env manually in eiger and then copy to a dir cp2k.psmp, and afterwards defien the aiida code keeping the loading of the env in the code definition but putting filepath_executable: /mydir/cp2k.psmp would work?

1 Like

Hi @cpignedoli, thanks for the suggestion! I tried, and it works.

Since this issue only impacts the verdi code test command, we need to improve the error message for clarity:

Critical: validation failed: The provided remote absolute path `/user-environment/env/cp2k/bin/cp2k.psmp` does not exist on the computer.
This may be because the environment is not activated. The code may still work when executed.

Would it be safe enough to also run all the prepend text before trying the code? Or there are cases in which this is a bad idea? If we think it’s risky because people might put in there things with a side effect (creating folders etc.), maybe we can have it as an option --with-prepend, and the error message can say “This may be because the environment is not activated; you can try to run verdi code test with the --with-prepend option to also run the prepend commands” (or something like this). If it’s safe, then can you check if running the prepend would solve the issue?

Think it may be a good idea to improve the error message, but we have to be careful about the wording. The “loading of an environment” can be a bit specific here. There are a multitude of ways that the path can be updated to include more binaries. For example, another common case is the loading of modules that make executables available.