Introduction
Developing applications on your local machine is strongly recommended as it saves on headaches with using shared OPIs and allows for robust testing on a simulated machine before launching in production.
Getting Started
- Install conda if you don't have an existing installation
- Review conda environments, the Getting Started with Conda page, and this useful conda cheatsheet
- Review this git version control intro
- Brush up on environment variables
- Run through this GitHub tutorial
Setting up GitHub
- Make a GitHub account and record your username (personal or work email is fine)
- Navigate to the #comp-general Slack channel
- Create a SLAC GitHub access workflow (the + with the lightning bolt at the bottom). An admin will review and grant you access
Installing PyDM
The basic steps can be found in the official documentation, but some quality of life improvements include:
- Setting an alias in your native system to launch the pydm conda environment
- For example, my
~/.zshrc
(my Mac's default shell is zsh for some reason) has the linealias pydmenv="conda activate pydm-environment"
- For example, my
- Learning how to save environment variables in your conda environment (note that you need to scroll down for Mac/linux)
- That internal file will need the
export QT_MAC_WANTS_LAYER=1
from the installation page - I personally also added an alias to launch designer to save keystrokes (
alias designer='open $CONDA_PREFIX/bin/Designer.app
'
)
- That internal file will need the
Installing Simulacrum
These steps should all be done in your pydm conda environment unless you don't need/intend to use PyDM
- Run
conda install --update-all --force-reinstall -y -c conda-forge bmad
- Run
git clone git@github.com:slaclab/lcls-lattice.git
- This repo can live wherever, just remember where it lives
- Set the
LCLS_LATTICE
environment variable to wherever the repo in step 2 lives - Run
git clone git@github.com:slaclab/simulacrum.git
and remember where it lives - Append the path from step 4 to your python path in your environment variable file using
export PYTHONPATH="${PYTHONPATH}:path/to/simulacrum/repo"
- Run
python <service directory>/<service>.py
for any service you want runningThis will eat a terminal tab. I strongly advise against backgrounding because you'll need to kill the process eventually, and if you background it you'll either need to remember the process ID or find it later
- For SRF work specifically, we typically only need the sc_rf_service so the command would be
python sc_rf_service/sc_rf_service.py
- All other services typically need the model service running with the appropriate beam line flag (
python model_service/model_service.py [lcls classic | cu_hxr | cu_spec | cu_sxr | sc_hxr | sc_sxr]
)
- All other services typically need the model service running with the appropriate beam line flag (
Module Not Found
Sometimes running a service for the first time will generate "module not found" errors. If that is the case, simply pip install the missing module and try again
Runtime Error: Empty SharedPV
If you get a SharedPV runtime error when running the model service, it's likely that the newer p4p version isn't backward compatible. Try running pip install p4p==4.0.0
Installing LCLS Tools
A shared library used by most (if not all) SRF software
- Run
git clone git@github.com:slaclab/lcls-tools.git
- Navigate to that repo and run
pip install --upgrade .
If there are sudden unexplained errors in your program, it is possible that one of these libraries was updated. In most cases, all you'll need is a git pull from the relevant repo. LCLS Tools specifically also needs the pip upgrade