For developers and end users of controls software at SLAC, two python conda environments are provided for use that can save the trouble of installing and maintaining your own virtual environments (although this is supported as well if needed). The first is the stable or standard environment which contains a sizable number of packages suited for development here at SLAC and stable for use with production applications. The second is a nightly updating environment that contains all the same packages as the stable environment, but is updated every night using conda to grab the most recent (and compatible) version of each package. This is geared towards users who need access to the latest and greatest version of each package before these make their way to the stable environment.
In order to use the stable environment, a script has been created that will activate it along with a few additional helpful python packages called use_python3.sh. This script can be run using the following command on any development box with access to afs, as well as any production machine:
Code Block |
---|
source $TOOLS/script/use_python3.sh |
Note: while the $TOOLS environment variable will be available on production machines, it may not be set by default on development machines depending on the scripts you are sourcing upon login. If it is not set, use the following to point it to the correct location:
Code Block | ||
---|---|---|
| ||
export TOOLS=/afs/slac/g/lcls/tools |
After activating the environment, you may use pip list or conda list to show all available packages. Note that conda will not be on your path by default upon sourcing the environment. You may use the installed binary at $PACKAGE_TOP/anaconda/2020.11/bin or you are free to grab your own (RHEL 6 compatible) copy.
This environment is built using the environment.yml file located here: https://github.com/slaclab/lcls-python3.8-env/blob/main/environment.yml
If there is a package that would be useful to you which is not yet included in this environment, there are multiple avenues for requesting it to be added. A GitHub pull request may be created for the environment.yml file linked above adding the packages that are needed. The slack channel #lcls-python-environments can be used to make a request as well. Or an email can be sent to Jesse Bellister (jesseb@slac.stanford.edu) cc'ing Doug Murray with the requested packages listed.
In addition to this a CATER must be created for the request. If you are not yet a CATER user, you may request an account by going to this link and clicking the "Become a Cater User" button: http://slac.stanford.edu/cater
Creating a CATER is required since this python environment is used by many different teams including the operators in the control room. Therefore we want to ensure that the environment remains stable and only safely deployed during maintenance windows.
Similar to the stable environment, a script can be sourced to activate the environment that is updated every night.
Code Block |
---|
source $TOOLS/script/use_python3_devel.sh |
As mentioned above, the packages in this environment are the same as those in the stable environment, but they will be updated on a nightly basis. There is also no need to add packages to this environment directly. Any packages added to the environment file linked above will automatically get picked up by the nightly build and will be available in this environment prior to being deployed into the stable environment.
For a change log of the nightly environment as compared to the stable one, automatically generated release notes are provided with each new release. These can be located at $PACKAGE_TOP/anaconda/envs/nightly/<date of release>/RELEASE_NOTES. In the same directory there is also a solved_environment file which contains the exact versions of all packages in the environment.
If there is ever an issue with the current day's environment, a history of the last 5 days of environments is stored under $PACKAGE_TOP/anaconda/envs/nightly/. Therefore it is possible to return to a previous environment like this:
Code Block |
---|
source $PACKAGE_TOP/anaconda/envs/nightly/04-12-2022/bin/activate |
For users who require specific versions of packages or who would like full control over managing their environments a process is provided for creating custom environments. Full documentation for this process is available here:
https://slaclab.github.io/conda-pack-docs/
For users who want to create a small test environment on the development network, a version of conda must be used that is compatible with RHEL6. The latest versions of miniconda require glibc>=2.26 which is not possible on RHEL6. The recommended version of miniconda to download is here:
https://repo.anaconda.com/miniconda/Miniconda3-py38_4.9.2-Linux-x86_64.sh
That will provide the most recent release of miniconda which still works with RHEL6. For additional information see here:
https://docs.conda.io/en/master/miniconda.html
Everything described above is sufficient for using and updating the python environments. What follows are a few notes on the process behind keeping the nightly environment updated.
A GitHub action runs every night at 10 pm to update the published tarball of the nightly release here: https://github.com/slaclab/lcls-python3.8-env/releases/tag/nightly
A cron job will run at midnight on our development network which pulls that tar file onto lcls-dev3, unpacks it, and updates a symlink to point to the new version which is referenced in the use_python3_devel script.
A similar cron job will pull the tar file from dev into production and repeat the same steps there.
These jobs clean up environments older than a week so that we don't take up excessive disk space holding onto old environments.