DUNE-DAQ / daq-buildtools

Make life for developers easier through a collection of CMake functions and scripts
0 stars 1 forks source link

Support of using venv from cvmfs and install a writable local spack instance when calling `dbt-create` #239

Closed dingp closed 1 year ago

dingp commented 1 year ago

This PR contains two features:

support the use of python venv from cvmfs, and avoid the time-consuming cloning/installing a venv into a work area;

The first feature allows developers to skip the creation of python venv (either via clone or fresh install) inside a workarea when using dbt-create.

Unless -i/--install-pyvenv or -c/--clone-pyvenv is used with dbt-create, the workarea will not contain a pre-installed python venv.

dbt-workarea-env will check the existence of $DBT_WORKAREA_ROOT/$DBT_VENV, if not found, it will activate the python venv in the release directory on cvmfs.

support the installation of a writable spack instance into a work area, so developers can install their own spack packages.

Use option -s/--spack when calling dbt-create.

This optionw will create .spack under the workarea, and add LOCAL_SPACK_DIR env to the dbt-workarea-constants.sh.

The local .spack is a clone of the spack instance from the release directory on cvmfs with the following modifications:

  1. the packages installed in the release are skipped;
  2. a spack-repo subdir is created, and added to the repos.yaml in the local .spack. In case one need to modify a package's recipe file, they should copy over the existing recipe file into .spack/spack-repo/packages/<pkg_name>, and modify it there;
  3. the spack instance from the release is added as an upstream spack instance, together with all existing upstream instances used by the release.

When calling dbt-workarea-env, it will check if LOCAL_SPACK_DIR is set, if so, load the spack setup script from there.

dingp commented 1 year ago

Here are some suggested tests of the two features:

  1. dbt-create -n last_fddaq <new_workarea_dir> to verify <new_workarea_dir>/.venv subdirectory is not created in the work area, and then verify if the the .venv from cvmfs is loaded when doing cd <new_workarea_dir>; source env.sh;
  2. Similar as test 1, but add option --clone-pyvenv;
  3. Similar as test 1, but add option --install-pyvenv;
  4. use dbt-create -s -n last_fddaq <new_workarea_dir> and verify <new_workarea_dir>/.spack is created, and then load the workarea with cd <new_workarea_dir>; source env.sh, followed by spack install --reuse dpdk@21.11 to install an older version of dpdk locally. Use spack find -p dpdk to verify the locally installed dpdk is listed. Use spack load dpdk@21.11 to make sure it can be loaded;

Repeat the test above by replacing last_fddaq with last_successful when calling dbt-create.

jcfreeman2 commented 1 year ago

I tried all the suggested tests, and things looked fine. I also added two changes: 1) Updated the documentation on this feature branch to reflect the updated dbt-create interface 2) Working off the principle of "write a function if you do something more than once in your code", I wrapped the subprocess.Popen polling and return value checking in a run_command function I added to dbt_setup_tools.py

dingp commented 1 year ago

Thanks John! Merging the PR.