Skip to content

Development

robnagler edited this page Mar 27, 2019 · 15 revisions

Developing Sirepo

Sirepo is fully open source as are all its codes. We are happy to support you, just submit an issue if you have questions.

Sirepo runs on Linux. We use Vagrant and VirtualBox. You will need to install Vagrant/Virtualbox manually before doing anything below.

We deploy using Docker.

We rely heavily on a simple curl installer structure in our download repo. If you are not comfortable with curl installers, please feel free to follow the installer scripts mentioned below.

If you use a Mac, read on. Otherwise, skip to PC Install. We use Macs so they are the best supported.

Once installed, run the server.

Server-side Technologies

  • python programming language
  • Flask lightweight web server framework
  • OpenMPI parallel computing

Client-side Technologies

Mac Install

Once Vagrant is installed, run the vagrant-sirepo-dev installer on your Mac:

mkdir v
cd v
curl radia.run | vagrant_dev_no_nfs_src=1 bash -s vagrant-sirepo-dev
vagrant ssh

The directory must be named "v", which will be used as a basis for the hostname v.radia.run. The rest of this page assumes v.radia.run is the hostname.

The vagrant_dev_no_nfs_src=1 turns off sharing ~/src between the host (Mac) and guest (VM). This depends on how you develop. If you would like to use an IDE like PyCharm, you might want to share ~/src with the VM. This way you can edit files locally on your Mac. In this case, you would use the command:

curl radia.run | bash -s vagrant-sirepo-dev

If you do this, you may want to have a symlink on your mac from /home/vagrant to /Users/<your-user> so that you can directly reference file names in error messages output by sirepo. Make sure /home on your Mac is chmod 755.

The host defaults to v.radia.run (ip 10.10.10.10). You can also specify a different host as an argument to vagrant-sirepo-dev, e.g.

curl radia.run | bash -s vagrant-sirepo-dev my-host.example.com

Next step: Single Server Execution.

PC Install

You can develop on Windows or Linux with Vagrant. You just have to run the install manually.

Linux Note: Always use the repos configured by vagrantup.com and virtualbox.org, and not the default that comes with your distro. We know for sure that Ubuntu's VirtualBox doesn't work properly.

Once you have installed VirtualBox and Vagrant, create a directory, and use this Vagrantfile:

# -*-ruby-*-
Vagrant.configure("2") do |config|
    config.vm.box = "fedora/27-cloud-base"
    config.vm.hostname = "v.radia.run"
    config.vm.network "private_network", ip: "10.10.10.10"
    config.vm.provider "virtualbox" do |v|
        v.customize ["guestproperty", "set", :id, "/VirtualBox/GuestAdd/VBoxService/--timesync-set-threshold", 5000]
        # https://stackoverflow.com/a/36959857/3075806
        v.customize ["setextradata", :id, "VBoxInternal/Devices/VMMDev/0/Config/GetHostTimeDisabled", "0"]
        # If you see network restart or performance issues, try this:
        # https://github.com/mitchellh/vagrant/issues/8373
        # v.customize ["modifyvm", :id, "--nictype1", "virtio"]
        #
        # Needed for compiling some the larger codes
        v.memory = 8192
        v.cpus = 4
    end

    config.ssh.forward_x11 = false
    # https://stackoverflow.com/a/33137719/3075806
    # Undo mapping of hostname to 127.0.0.1
    config.vm.provision "shell",
        inline: "sed -i '/127.0.0.1.*v.radia.run/d' /etc/hosts"
end

Then install the vbguest plugin:

> vagrant plugin install vagrant-vbguest

This will make sure your time on the machine stays up to date, and also allow you to mount directories from the host. Once the plugin is installed, run:

> vagrant up

Once booted:

> vagrant ssh

And inside the guest VM run the redhat-base installer:

$ curl radia.run | bash -s redhat-dev
$ exit

This sets up a lot of environment so logging out is a good idea, then login again and run the sirepo-dev installer:

$ vagrant ssh
$ curl radia.run | bash -s sirepo-dev
$ exit

This installs all the codes used by sirepo, and it's fully automatic so go have lunch, and it will be done. Make sure you exit, because you will need to refresh your login environment.

Next step: Single Server Execution.

Single Server Execution

Once installed by one of the methods above, you will have a sirepo development environment. To run sirepo locally, run:

$ cd ~/src/radiasoft/sirepo
$ sirepo service http

Vagrant sets up a private network. You can access the server at http://v.radia.run:8000. However, some networks block resolutions to private internet addresses so you may have to visit http://10.10.10.10:8000.

Two Server Execution (runner_daemon)

The sirepo service http setup is used for basic application development, but we are migrating to requiring a runner_daemon for all workflows.

You need a py3 virtual environment:

$ bivio_pyenv_3
$ cd ~/src/radiasoft/sirepo
$ pip install -e .

Start the runner_daemon in py3 environment:

$ PYENV_VERSION=py3 SIREPO_FEATURE_CONFIG_RUNNER_DAEMON=1 pyenv exec sirepo runner start

Start sirepo with runner_daemon enabled (assumes py2 is active):

$ SIREPO_FEATURE_CONFIG_RUNNER_DAEMON=1 sirepo service http

Codeless Server Execution

You can run Sirepo without any of the scientific codes it supports by running the server this way:

$ SIREPO_FEATURE_CONFIG_SIM_TYPES=myapp sirepo service http

This runs the demo app, which is available at the following link: http://v.radia.run:8000/myapp.

Full Stack Development (celery)

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 them.

Set up a few environment variables:

export PYKERN_PKDEBUG_REDIRECT_LOGGING=1 PYKERN_PKDEBUG_WANT_PID_TIME=1

Then run each of the following commands in separate windows:

sirepo service rabbitmq
SIREPO_CELERY_TASKS_CELERYD_CONCURRENCY=2 SIREPO_MPI_CORES=4 sirepo service celery
SIREPO_SERVER_JOB_QUEUE=Celery sirepo service uwsgi
sirepo service nginx_proxy
sirepo service flower

nginx will listen on port 8080 so you can browse Sirepo at http://v.radia.run: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://v.radia.run:5555 to see the workers, tasks, processes, queues, etc.

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

Updating VM

As user vagrant:

radia_run sirepo-dev

If radia_run fails, run with debug:

radia_run debug sirepo-dev
Clone this wiki locally
You can’t perform that action at this time.