How to use lein to do Clojush runs on single nodes of fly

Here are some instructions to get a run going on a single node of fly by using leiningen (lein). This page should be enough to get you there if you know what you’re doing. For example, you should know how to do a single Clojush run on your own computer. This file explains how to perform single runs of Clojush using leiningen launches. (see also this for an outdated method using direct java calls).

First, install leiningen in your fly account if you have not already done so:

  1. cd ~/bin
  2. wget –no-check-certificate https://raw.github.com/technomancy/leiningen/stable/bin/lein
  3. chmod +x lein
  4. lein

and then if everything goes well lein will be set up.

For the rest, two methods are presented, using Github or not:

Using Github:

To use this method, you should be at least somewhat familiar with Git, including creating branches, checking out branches, and pushing to a remote (such as GitHub). Otherwise, you should use the “Not Using GitHub” method below.

  1. Create a Git branch for your code on your local machine. You can use master if you want to use an example as-is; otherwise, let’s suppose your branch is named cool-problem.
  2. (optional) Make sure your code is working on your local machine. Run it by using “lein run clojush.problems.demos.cool-problem” from within your Clojush directory (that’s assuming that your problem file is in src/problems/demos/cool_problem.clj). If you don’t get errors by the first generation, you should be good and can kill the run.
  3. Push your code to GitHub. Use your own fork. This will entail something like “git push origin cool-problem”.
  4. ssh to fly. You will need a fly account to do so. If you need one, talk to Josiah. (example: “ssh yourname@fly.hampshire.edu”)
  5. ssh to a compute node (example: “ssh compute-4-2”)
  6. Start a screen session with something like “screen -S cool”
  7. (NOTE: read this whole step, including substeps, before you get started) If you alread have a git-cloned version of Clojush on fly, cd to that. Otherwise, “git clone git@github.com:lspector/Clojush.git” will get clone Clojush from GitHub. Then, “cd clojush”.
    1. If you are using your fork of Clojush, replace “lspector” with “yourname”.
    2. If you haven’t set up your fly account’s ssh keys with GitHub, you’ll have to do that before this step, but it’s totally worth it. This will entail following the directions here, though DO NOT generate new keys. Instead. just do steps 1, 3, and 4, using the keys you should already have on fly. If you delete your current fly ssh keys, you will not be able to ssh to compute nodes.
    3. If you don’t want to mess with ssh keys as in substep 2, you could instead clone Clojush using the read-only link: git://github.com/lspector/Clojush.git . If you do this, you won’t be able to push changes and new commits back to GitHub, but you won’t have to worry about ssh keys.
  8. Now you should be in your Clojush directory. Get the branch you want to run by “git fetch origin” and then “git branch cool-problem origin/cool-problem” and then “git checkout cool-problem”.
  9. You should now have the code you want to run. You can look around to make sure this is the case.
  10. Run your code. You’ll want to do something like “lein run clojush.examples.cool-problem | tee out.txt”.
  11. Make sure the run has started smoothly.
  12. Detach your screen “C-a d”.
  13. Logout of fly. Later, ssh back into the node you are running on. Resume screen with “screen -r cool”. If things are finished, you can look at the new out.txt file and do whatever else you want. When you’re done with screen, make sure you close it with “C-d”.

Not using Github:

  1. (optional) Make sure your code is working on your local machine. Run it by using “lein run clojush.problems.demos.cool-problem” from within your Clojush directory (that’s assuming that your problem file is in src/problems/demos/cool_problem.clj). If you don’t get errors by the first generation, you should be good and can kill the run.
  2. Zip up your Clojush directory and scp it to your fly account.
  3. ssh to fly. You will need a fly account to do so. If you need one, talk to Josiah. (example: “ssh yourname@fly.hampshire.edu”)
  4. ssh to a compute node. (example: “ssh compute-4-2”)
  5. Unzip your Clojush directory.
  6. Start a screen session with something like “screen -S cool”
  7. cd into your Clojush directory.
  8. Run your code. You’ll want to do something like “lein run clojush.examples.cool-problem | tee out.txt”.
  9. Make sure the run has started smoothly.
  10. Detach your screen “C-a d”.
  11. Logout of fly. Later, ssh back into the node you are running on. Resume screen with “screen -r cool”. If things are finished, you can look at the new out.txt file and do whatever else you want. When you’re done with screen, make sure you close it with “C-d”.

2 thoughts on “How to use lein to do Clojush runs on single nodes of fly

  1. Pingback: How to use single nodes of fly for Clojush runs | Computational Intelligence Laboratory

  2. Pingback: How to do multiple runs of Clojush using tractor | Computational Intelligence Laboratory

Leave a Reply

Your email address will not be published. Required fields are marked *