Skip to content

roussel-ryan/sirepo

 
 

Repository files navigation

Sirepo

Sirepo brings computational science to the cloud. Develop, run and share your HPC simulations.

Sirepo brings Clickable Physics(TM) to your desktop and mobile devices. No signup is required, just click beta.sirepo.com.

We currently support the following Clickable Physics(TM) codes:

Synchrotron Radiation Workshop (SRW)

SRW computes synchrotron radiation from relativistic electrons in arbitrary magnetic fields and propagates the radiation wavefronts through optical beamlines. SRW is open source.

Elegant

Elegant simulates charged particle accelerators with a wide range of features, including support for nonlinear optimization and design. Elegant is freely available and open source.

Warp

Warp is a particle-in-cell (PIC) code designed to simulate high-intensity charged particle beams and plasmas in both the electrostatic and electromagnetic regimes, with a wide variety of integrated physics models and diagnostics. At present, Sirepo supports a small subset of Warp’s capabilities. Warp is open source and is part of the Berkeley Lab Accelerator Simulation Toolkit.

Sirepo is currently in beta.

You can use our curl installer on your Mac, PC (Cygwin only), or Linux box as follows:

$ mkdir sirepo
$ cd sirepo
$ curl radia.run | bash

For this to work, you will need to install the prerequisites.

API Documentation is available on Read the Docs.

Manual Install with Docker

You can start Sirepo with Docker.

If you are running Docker as an ordinary user (recommended), use the following:

$ docker run -it --rm -p 8000:8000 -v "$PWD:/vagrant" radiasoft/sirepo /radia-run "$(id -u)" "$(id -g)" /home/vagrant/bin/radia-run-sirepo /vagrant 8000

The /radia-run command ensures the guest's user can read/write files from the current directory, which is where the database and other files will be stored.

Then visit the following link:

http://localhost:8000/light

You can run sirepo in an emphemeral container as root, but without storing files on the host:

# docker run -it --rm -p 8000:8000 -u vagrant radiasoft/sirepo bash -l -c 'radia-run-sirepo "$HOME" 8000'

Manual Install with Vagrant

You can start Sirepo with Vagrant.

First create a Vagrantfile by copy-and-pasting this into a shell:

cat > Vagrantfile <<'EOF'
Vagrant.configure(2) do |config|
  config.vm.box = "radiasoft/sirepo"
  config.vm.network "forwarded_port", guest: 8000, host: 8000
  config.vm.synced_folder ".", "/vagrant", disabled: true
end
EOF

Boot the machine:

vagrant up

The image is 2.5GB so this will take some time to start.

If it's your first time running Vagrant, it will ask to install VirtualBox.

Follow the prompts

You can run Sirepo with a single command:

vagrant ssh -c '. ~/.bashrc; sirepo service http'

Or, if you would like to do development:

vagrant ssh
cd src/radiasoft
pip uninstall sirepo pykern
git clone https://github.com/radiasoft/pykern
cd pykern
pip install -e .
cd ..
git clone https://github.com/radiasoft/sirepo
cd sirepo
pip install -e .
sirepo service http

Then visit the following link:

http://localhost:8000/light

Sharing Folder with Vagrant VM

Note that if you want to transfer files to the virtual machine, you'll need to install the vagrant-vbguest plugin and remove the following line from the Vagrantfile:

config.vm.synced_folder ".", "/vagrant", disabled: true

Angular Testing

In order to test, you need to install Xvfb, nodejs (v4+), and google-chrome.

Extensive tutorial on Angular Testing from 2013, which gives advice on jasmine testing, but uses obsolete scenario runner.

Advice on how to test better

Install node globally as root:

curl -s -S -L https://rpm.nodesource.com/setup_4.x | bash
yum install -y nodejs

Install Xvfb globally as root. It runs as vagrant:

yum install -y xorg-x11-server-Xvfb xorg-x11-server-utils
cat > /etc/systemd/system/Xvfb.service <<'EOF'
[Unit]
Description=Xvfb
After=network.target

[Service]
User=vagrant
SyslogIdentifier=%p
# -noreset fixes memory leak issue with other flags described here:
# http://blog.jeffterrace.com/2012/07/xvfb-memory-leak-workaround.html
# Start with screen 10, because we use visible X11 apps on VMs.
# Small screen size to save memory
# RANDR needed for chrome
ExecStart=/usr/bin/Xvfb -ac -extension RANDR -noreset -screen 0 1024x768x8

[Install]
WantedBy=multi-user.target
EOF
systemctl enable Xvfb
systemctl start Xvfb

Install Chrome globally as root:

cat << 'EOF' > /etc/yum.repos.d/google-chrome.repo
[google-chrome]
name=google-chrome - $basearch
baseurl=http://dl.google.com/linux/chrome/rpm/stable/$basearch
enabled=1
gpgcheck=1
gpgkey=https://dl-ssl.google.com/linux/linux_signing_key.pub
EOF
yum install -y google-chrome-stable

Karma (Angular unit testing)

The tests are located in tests/karma. Tutorial on karma and jasmine.

As user install node modules:

cd ~/src/radiasoft/sirepo
npm install --save-dev karma
npm install --save-dev karma-jasmine
npm install --save-dev karma-phantomjs-launcher

To run tests:

cd ~/src/radiasoft/sirepo
./node_modules/karma/bin/karma start karma-conf.js

Protractor (Angular end-to-end testing)

The tests are located in tests/protractor. Tutorial on protractor and jasmine.

As user install node modules:

cd ~/src/radiasoft/sirepo
npm install --save-dev protractor
npm install --save-dev protractor-snapshot
./node_modules/protractor/bin/webdriver-manager update

Verify the X11 server is running:

DISPLAY=:0 xset q > /dev/null && echo OK

To run tests:

cd ~/src/radiasoft/sirepo
# Starts server on http://localhost:4444/wd/hub
DISPLAY=:0 ./node_modules/protractor/bin/webdriver-manager start >& webdriver.log &
# Default is 8000
SIREPO_PKCLI_SERVICE_PORT=8000 sirepo service http >& http.log &
# You don't need to pass uri as it is set to 8000 by default, but clearer
./node_modules/protractor/bin/protractor --params.uri=http://localhost:8000 protractor-conf.js

Output will look like:

./node_modules/protractor/bin/protractor protractor-conf.js
[16:20:30] I/hosted - Using the selenium server at http://localhost:4444/wd/hub
[16:20:30] I/launcher - Running 1 instances of WebDriver
Started
.


1 spec, 0 failures
Finished in 6.88 seconds
[16:20:40] I/launcher - 0 instance(s) of WebDriver still running
[16:20:40] I/launcher - chrome #01 passed

If you would like to see what the browser (webdriver) is doing, you must have X11 running, and start the webdriver this way:

./node_modules/protractor/bin/webdriver-manager start >& webdriver.log &

This will use the $DISPLAY forwarded through your ssh session via Vagrant.

Full Stack Development

The sirepo service http setup is used for basic application development. However, if you want to test the full stack workflow, you'll need to start all the support processes and configure your servers.

Set up a few environment variables:

export SIREPO_SERVER_JOB_QUEUE=Celery
export SIREPO_MPI_CORES=4
export PYKERN_PKDEBUG_REDIRECT_LOGGING=1
export PYKERN_PKDEBUG_WANT_PID_TIME=1
export SIREPO_CELERY_TASKS_CELERYD_CONCURRENCY=2

Then run each of the following commands in separate windows:

sirepo service rabbitmq
sirepo service celery
sirepo service uwsgi
sirepo service nginx_proxy
sirepo service flower

nginx will listen on port 8080 so you can browse Sirepo at http://localhost:8080. The middle tier uwsgi server will start on port 8000.

The last process starts Flower, which allows you to monitor Celery. You can visit http://localhost:5555 to see the workers, tasks, processes, queues, etc.

You can also visit RabbitMQ's Management Plugin on this URL: http://localhost:15672.

License

License: http://www.apache.org/licenses/LICENSE-2.0.html

Copyright (c) 2015-2016 RadiaSoft LLC. All Rights Reserved.

RadiaSoft

About

A framework for scientific cloud computing

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • JavaScript 73.6%
  • Python 18.6%
  • CSS 5.1%
  • HTML 2.7%