1 of 24

Intro to Computing at FACET-II

Ivan Rajkovic

Facility for Advanced Accelerator Experimental Tests

2 of 24

Overview

  • SLAC Network
  • Remote connections
  • FACET-II controls network access
  • GIT/CVS at FACET-II

​

​

FACET-II Summer Intern Program - Intro to computing at FACET-II

3 of 24

SLAC Network

firewall

Bastion hosts:

jump.slac.stanford.edu

rocky9.slac.stanford.edu

nx4.slac.stanford.edu

fastx.slac.stanford.edu

s3dflogin.slac.stanford.edu

s3dfnx.slac.stanford.edu

SLAC Network

Controls network

- Local, no internet access

mcclogin

facet-srv01

facet-srv20

iana, s3dfdtn….

FACET-II Summer Intern Program - Intro to computing at FACET-II

4 of 24

Remote connection

​

FACET-II Summer Intern Program - Intro to computing at FACET-II

5 of 24

FACET-II controls network access

  • https://confluence.slac.stanford.edu/display/FACET/Remote+access+to+facethome+and+facet-srv01
    • Follow steps to have your account granted access to facet-srv01
  • facethome is a hub for FACET controls
    • Get to controls network (e.g. FastX, ssh mcclogin, ssh fphysics@facet-srv01, select profile)
    • Launch facethome
  • Experiment data (https://confluence.slac.stanford.edu/display/FACET/Data+Retrieval)
    • Initially saved to FACET NAS (controls network only)
    • Uploaded daily to SLAC central /nfs/slac/g/facetdata/nas/, mounted on s3df to /fs/gpfs/slac/staas/fs1/g/facetdata/nas/
    • Data will soon be moved to /sdf/data/facet/

Your home directory is synced between s3df and mcclogin, but not facet-srv01�

More info: https://confluence.slac.stanford.edu/display/FACET/FACET-II+Home

FACET-II Summer Intern Program - Intro to computing at FACET-II

6 of 24

Git (and CVS) at FACET-II

FACET-II Summer Intern Program - Intro to computing at FACET-II

7 of 24

Why do we need a version control system?

  • track the changes you make to files, so you have a record of what has been done, and you can revert to specific versions should you ever need to.
  • makes collaboration easier, allowing changes by multiple people to all be merged into one source.

​

FACET-II Summer Intern Program - Intro to computing at FACET-II

8 of 24

GIT vs CVS

  • Git is a distributed version control system
  • Developed by Linus Torvalds in 2005.

​

  • CVS is a centralized version control system
  • Developed by Dick Grune in 1986.
  • ‘Concurrent Versions System’

Repository

Local

copy 1

Local

copy 2

Local

copy N

Centralized version system (CVS, SVN,...)

Repository

Local repo

Local repo

Local repo

Local

copy 1

Local

copy 2

Local

copy N

Distributed version system (Git, Mercurial,...)

Developer 1

Developer 1

Developer 2

Developer 2

Developer N

Developer N

Central Server

Remote Server

FACET-II Summer Intern Program - Intro to computing at FACET-II

9 of 24

Version control systems for software

  • We use both Git and CVS to manage the changes that individuals make to code that runs in the FACET-II control system
  • Key language:
    • Repository and branches
    • Commit, pull, push, checkout
    • Master and “Production”

​

9

FACET-II Summer Intern Program - Intro to computing at FACET-II

10 of 24

Git or CVS???

  • EDM -> CVS
  • PyDM -> Git
  • Matlab GUI -> Git

​

10

PyDM panel

EDM panel

facethome

Matlab GUI panel

FACET-II Summer Intern Program - Intro to computing at FACET-II

11 of 24

What does this look like for FACET?

11

‘master’ matlabTNG repository

‘production’ copy

Your local copy

Edit files -

Commit(s) -

Merge/check for conflicts -

Edit files (if needed) -

Push changes to master -

FACET-II Summer Intern Program - Intro to computing at FACET-II

12 of 24

What does this look like for FACET – with many users

12

‘master’ matlabTNG repository

‘production’ copy

My code changes

Someone else’s work

Your local copy

FACET-II Summer Intern Program - Intro to computing at FACET-II

13 of 24

Where to find more information

  1. Confluence:

​

  • Ask each other!

​

  • Both Git and CVS are widely used, so lots of information is available online
    • https://github.com/git-guides
    • Google: ‘git cheatsheet’
  • Your mentor (or anyone at FACET-II)

13

FACET-II Summer Intern Program - Intro to computing at FACET-II

14 of 24

Get access to both Git and CVS

  1. Request access from Ken Brobeck: brobeck@slac.stanford.edu 
    • Tell him you are a FACET summer intern, your unix username, and that you need access to: /afs/slac/g/cd/swe/git/repos/slac/FACET

(and facet CVS repositories for edm, if needed)

  • Set up your home git_work and cvs_work directories on facet-srvXX (i.e.: mkdir git_work)
    • Make sure you select your profile at login, or use the set_profile command
  • Locations of repositories:
    • Matlab files: /afs/slac/g/cd/swe/git/repos/slac/FACET/matlabTNG.git
      • Mirrored here: https://github.com/slaclab/facet-matlabTNG
      • Production version: /usr/local/facet/tools/matlabTNG/
    • Python files: /afs/slac/g/cd/swe/git/repos/slac/pydm_displays/user-facet.git
      • Production: /usr/local/facet/tools/pydm/display/user-facet/
    • Matlab tools: /afs/slac/g/cd/swe/git/repos/slac/matlab/hla/facet/toolbox.git
      • Production: /usr/local/facet/tools/matlab/toolbox/
    • CVS: EDM files: tools/edm/...
      • Production: /usr/local/facet/tools/...

​

14

FACET-II Summer Intern Program - Intro to computing at FACET-II

15 of 24

Git Step 1: Clone a repository to your git_work directory

15

•This puts a local repo and local copy onto your facet-srv01 account

•This is now your own “private” version that you will work on

•But – it is a clone at this specific time, new changes are not automatically updated

• Later on use: git pull to update your local copy to include the latest code updates.

FACET-II Summer Intern Program - Intro to computing at FACET-II

16 of 24

Git Step 2: Typical workflow for editing a file

  • Note – if the file didn’t already exist in the repo, then you can use: git add README.md before the commit to add it.

16

1) Edit the file

2) Commit the changes with a USEFUL comment

3) Uploads your local copy commits to the remote server. i.e. publishes your changes

nano

FACET-II Summer Intern Program - Intro to computing at FACET-II

17 of 24

Git Step 3: Update the production repo

  • You have now pushed your changes to the master repo
  • But… the “production” repository that runs on the control system is not automatically updated
  • So you need to: git pull the changes on the production system:

17

1) Get to the right directory

2) Pull the latest version of the master repository

FACET-II Summer Intern Program - Intro to computing at FACET-II

18 of 24

Git workflow summary

  • From your git work directory
    • fphysics@facet-srv01 ~/<user>/gitwork/matlabTNG ]$

​

  • Commands:
    • git pull origin master
    • edit your file
    • git add file.m (only if it’s a new file that doesn’t exist on the repository)
    • git commit –m “This a descriptive comment” file.m
    • git pull origin master
    • git push origin master

​

    • cd /usr/local/facet/tools/matlabTNG/
    • git pull

FACET-II Summer Intern Program - Intro to computing at FACET-II

19 of 24

CVS Step 1 - Workflow is similar with CVS

  • First – need to checkout the latest version into your cvs_work directory:

​

​

​

​

​

​

​

  • Always check to make sure the file is up-to-date before making changes and committing.

​

19

1) Checks out the current version of the file to you.

Do not forget this step!

2) The –A argument checks if your repo is current

  • No output means current
  • The ‘P’ means you need to pull changes!

FACET-II Summer Intern Program - Intro to computing at FACET-II

20 of 24

CVS Step 2 – Edit your file and commit

  • Edit the file, then commit:

​

​

​

​

​

  • If this is a new file, then you need to add it to the repository first:

20

1) Commit the changes with a USEFUL comment

1) Adds the file to the repo

2) Commits the new file

FACET-II Summer Intern Program - Intro to computing at FACET-II

21 of 24

CVS Step 3 – Update the production version

​

For EDM files, change to the production directory and update:

21

Moves the new version to the production machine

FACET-II Summer Intern Program - Intro to computing at FACET-II

22 of 24

CVS workflow summary

  • From your cvs work directory, and into the directory where the file resides:
    • fphysics@facet-srv01 ~/<user>/cvswork/tools/../../.. ]$

​

  • Commands:
    • cvs update -A file.edl
    • edit your file
    • cvs add file.edm (only if it’s a new file that doesn’t exist on the repository)
    • cvs commit –m “This a descriptive comment” file.edl

​

    • cvs2prod file.edl

-- or --

    • cd $TOOLS/edm/display/facet
    • cvs update file.edl

Repository

Local copy

update

commit

FACET-II Summer Intern Program - Intro to computing at FACET-II

23 of 24

Extra steps

​

  • Make an account on one of the version control system sites:
  • www.bitbucket.org
  • www.github.com
  • www.gitlab.com

​

  • Install git client on your computer (command line or GUI)
  • https://git-scm.com/downloads

​

  • Test various git commands and workflows:
  • Make extra branch, edit/create files in both branches, merge back
  • Resolve merge conflict - same file edited in different local copies�……

​

FACET-II Summer Intern Program - Intro to computing at FACET-II

24 of 24

Final thoughts

  • Questions?

​

  • Remember:
    1. Make sure that you have access to git
      • if not, then please contact Ken Brobeck from your SLAC email account
    2. Select your own profile when you log in

​

    • Always make sure that you have the latest version before you start making your own edits
    • Add useful comments when committing
    • Don’t forget to push changes to production

​

    • Don’t store huge amounts of data on the facet-srvXX machines (<10GB)
      • It’s ok if required for development (code is fine, large FACET image datasets can be 10’s-100’s of GB)
    • Don’t store anything on FastX – it gets reset every month

24

FACET-II Summer Intern Program - Intro to computing at FACET-II