You are viewing an old version of this page. View the current version.

Compare with Current View Page History

« Previous Version 36 Next »

Git

Production repositories locally live in ~/opsTools, and remotely live on GitHub.

Here's a link to the git resource I used in college; I found it really helpful!


GitHub

SLAC has a GitHub organization called SLAC Lab. Access to it isn't granted automatically, but it's pretty easy to get! Make a GitHub account (or use one that you already have) and send your username to Brian Van Klaveren (email bvan@slac.stanford.edu or ping brianv on Slack) asking for access. Note: This step has very high potential to end up out of date if someone else ends up managing SLAC Lab, so keep that in mind.

Once you've done that, add your rhel6-64 ssh key to GitHub.


Adding SSH Keys to GitHub

Run "set_profile [YOUR USERNAME]" then ssh into mcclogin

 

 

From there, ssh into rhel6-64

 

 

From there, cat your ssh key

 

 

Copy the entire output (starts with ssh-rsa and ends with your email address).

 

Back on GitHub, go to your settings

 

 

And add a new SSH key

 

 

Title it something descriptive, paste in the output you got from cat, and save it! 

 


PyDM

PyDM is next generation EDM! It's basically a combination of EDM and PyQt (if you don't know what PyQt is, it's what we use to make Python GUIs). The goal is to eventually migrate all existing Python GUIs to PyDM, and to make any new ones going forward in PyDM, all while version controlling them using git and GitHub. This tutorial will walk you through making a change to an existing PyDM panel and going through the review process to release it into production.


Tutorial

Go to https://github.com/slaclab/devPanel

 

Click "Fork" in the upper right corner

 

 

Click the link that says [Your User Name]/devPanel (Mine says that I've already forked it, but yours should ask you where you want to fork it)

 

Click the green "Clone or Download" button and copy the ssh path. If you see what looks like a URL, click the blue "Use SSH" link right above it

 

Back on an OPI (or ssh'ed in), type "set_profile [Your Username]". This should take you to your personal physics directory. Make a new devPanel subdirectory

 

In that subdirectory, run "git init"

 

Still in that subdirectory, type "~/mgibbs/link_repo_to_github/link_repo_to_github.sh -i" and follow the prompts (if you don't feel like thinking about the AFS repo, you can use this default, but you should paste in the GitHub ssh link you got in Step 4 for your fork or you'll connect to mine! You'll get slightly different messages since I've already run this before)

 

Type "git pull origin master" and type in your password when prompted (again, messages will be slightly different since I've done this before)

 

Type "source use_pydm.sh"

 

 

Type "mkdir [Your Name]" and head into that directory

 

 

Type "designer &"

 

 

Sometimes you get an error saying something about backup files. Ignore it(: In the program that opens, click "Widget" and then "Create"

 

 

In the Widget box on the left, scroll all the way down and drag a drop a PyDMShellCommand somewhere in the widget that popped up in the last step

 

Right click anywhere in the widget that isn't the tiny shell command button, hover over "layout" at the bottom, and click "lay out in a grid"

 

 

In the Object Inspector in the top right, rename that button something more descriptive by double clicking it, typing the new name, and pressing enter

 

 

Right click the button itself and click "Change text..."

 

 

Rename it something more descriptive and press enter

 

 

In the property/value table in the middle right, scroll all the way down to "commands," double click the value box (it'll be blank at first, and then it'll be a button that says "Change String List"), Click "New", type "pydm ~/opsTools/devPanel/example/example.py", then click "OK". This will launch the production example panel!

 

 

Save this file as devPanel[Your Name].ui

 

From here, open opsDevPanel.ui from the parent directory (~/[your username]/devPanel)

 

Drag and drop a PyDMRelatedDisplayButton onto the newly opened devPanel.ui

 

 

Right click rename the button itself and its object name like before

 

Add the path to your personal dev panel in your subdirectory and save

 

 

Back in your terminal in the devPanel directory, run "pydm opsDevPanel.ui" and you should see your creation! Feel free to play with it until it looks good to you!

 

Run "git status" to see what's changed. It should be opsDevPanel.ui and a new folder with your name

 

Run "git add [YOUR NEW FOLDER]" and "git add opsDevPanel.ui", then run another git status. They should both be staged for commit 

 

Run git commit -m "adding [YOUR NAME]'s dev panel"

 

Run "git push origin master" and log in when prompted

 

 

Back on your fork on GitHub, click "New Pull Request"

 

 

Click "Create Pull Request"

 

Add slaclab/ops as a reviewer (by clicking on the gear and then searching), and then click "Create pull request"

 

An admin will look at it to make sure that nothing important got deleted, and if they approve it, they'll merge it into production!


Afterword: Updating Your Personal Repo

Note that the tutorial didn't say anything about updating your personal copy if the production copy gets updated by someone else. There are two ways to do this, and it's really your choice which one to do.


GitHub Method

In the SLAC Lab production repo, click "Pull Request" and then "New Pull Request"

 

Click on "Compare across forks" and then pick your fork in the left hand drop down menu

 

Click "create pull request", which will take you to the same page we had in the tutorial! The only difference here is that you don't need any reviewers because you're merging it into your personal fork.

 

Sometimes it'll say that it can't be merged automatically. This usually happens when you've edited the same file as one that got updated in production. One way to avoid this problem on GitHub is to always keep your fork's master up to date with production and do all your work in a different branch and just deal with the merge conflicts locally

 

You can just immediately merge it in on the next page by clicking "merge pull request"

 

Using the steps in the tutorial, ssh into rhel6-64 and navigate to the repository you created with Matt's script and run "git --bare fetch origin master:master". Mine doesn't have output because it's already up to date, but yours should

 

Back in your physics devPanel directory, run "git pull origin master", and that should be it! Again, your output will be different from mine because mine is already up to date.


Command Line Method

This will rely heavily on git remotes. If you'd like to learn more about them, check this out!

Pulling From the Local Production Copy

Assuming that you trust the custodian of the local production copy to keep it up to date, this method is probably the easiest.

 

In your physics devPanel directory, run "git remote add upstream ~/opsTools/devPanel"

Now you can just run "git pull upstream master" whenever you'd like to bring your local copy up to date with production!

 


Pulling from the SLAC Lab Production Copy

If you don't trust the custodian of the local production copy to keep it up to date, then you can connect your bare AFS repo directly to SLAC Lab's production repo.

 

Using the steps in the tutorial, ssh into rhel6-64, navigate to the bare repo you created with Matt's script, and run "git remote add upstream git@github.com:slaclab/devPanel.git" (gotten from the SLAC Lab devPanel page, much like we got it for our personal forks in the tutorial)

 

Now, similar to in the GitHub method, you should run "git --bare fetch upstream master:master"  (yes, I have an error message, but it's for stupid reasons. Yours should be fine)

And now it's the same step as in the GitHub method, running "git pull origin master" from your devPanel physics directory.

Those last two steps will need to be run every time you want to update.

  • No labels