Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

Table of Contents

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.

Info

Note that 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

Prerequisites

It is recommended that you already have working conda installation and have beginner's knowledge of conda environments.

...

This tutorial was built for unix machines, so if you have windows, you should consider setting up WSL through SLAC IT if you don't want to figure out the equivalent windows commands. if you don't want to do that, SLAC offers NoMachine as an option for running Linux, Stanford offers a virtual desktop that runs macOS, or you can install your own ubuntu in virtualbox.

Getting Started

...

Setting up GitHub

  1. Make a GitHub account and record your username (personal or work email is fine)
  2. Add your ssh key to your GitHub account
  3. Navigate to the #comp-general Slack channel 
  4. Create a SLAC GitHub access workflow (Workflow button at the top near the channel name). An admin will review and grant you access
    1. Image Added
    2. Image Added


Info
titleARM Macs

Note for anyone using ARM Macs: prefix any conda command in the following sections with CONDA_SUBDIR=osx-64 because the current builds do not support ARM. For example, instead of conda install use CONDA_SUBDIR=osx-64 conda install 

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 line alias pydmenv="conda activate pydm-environment"
  • 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  and export PYDM_DEFAULT_PROTOCOL=ca from the installation page
    • I personally also added an alias to launch designer to save keystrokes (alias designer='open $CONDA_PREFIX/bin/Designer.app')

...

  1. Run conda install --update-all --force-reinstall -y -c conda-forge bmad
  2. Run git clone git@github.com:slaclab/lcls-lattice.git
    1. This repo can live wherever, just remember where it lives
    2. You may need to request access
  3. Set the LCLS_LATTICE environment variable to wherever the repo in step 2 lives
  4. Run git clone git@github.com:slaclab/simulacrum.git and remember where it lives
  5. Navigate to the newly cloned simulacrum repo and run pip install . 
  6. Run python <service directory>/<service>.py for any service you want running
    1. This 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

    2. 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
      1. 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])
Info
titleModule 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

Info
titleRuntime 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

  1. Run git clone git@github.com:slaclab/lcls-tools.git
  2. Navigate to that repo and run pip install --upgrade .


Info

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

Porting to Production

Once you're happy with whatever program you're working on and think that it's ready (and safe) to run on production, you can connect your GitHub repo

Setup

  1. ssh into srv01 and activate your own profile
  2. make a directory with the desired name (this isn't a clone so it doesn't make the directory for you)
  3. navigate to that directory and run git init
  4. run ~/zacarias/utils/linkRepoToGithub/link_repo_to_github.sh -i and follow the prompts
  5. run git pull origin main and all of the files should now be there

Updating

  1. If you know where in AFS you connected your repo (setup step 4) skip to step 2 otherwise navigate to your production repository and run git remote -v to see where origin is
    1. It will look something like ssh:///[path to remote]
  2. ssh into an AFS machine that has internet connectivity
  3. navigate to the repo found in step 1
  4. run git --bare fetch origin main:main
  5. ssh to lcls-srv01 using your own profile
  6. navigate back to your production repo and run git pull origin main

Content by Label
showLabelsfalse
max5
spacesSRF
showSpacefalse
sortmodified
reversetrue
typepage
cqllabel = "pydm" and type = "page" and space = "SRF"
labelskb-how-to-article

Page properties
hiddentrue
Related issues