Skip to content

Using Ganga with HPS MC Jobs

Jeremy McCormick edited this page Nov 1, 2017 · 10 revisions

The hps-mc toolkit has a built-in interface to the Ganga job toolkit, which allows sophisticated management of batch jobs in multiple systems (LSF, PBS, Condor, etc).

Adding Jobs to Ganga

hps-mc includes a workflow script for automatically adding jobs to Ganga.

python hps-mc/python/hpsmc/workflow.py -j 1 -n 10 -w ap -g \
    -d workdir -u -p 6 ap_job.py job.json

Script arguments from the above example:

  1. start at job number 1
  2. create 10 jobs (1-10)
  3. create workflow called 'ap'
  4. register the jobs in Ganga
  5. set the work dir for the unpacked JSON files (a lot of JSON files will be dumped here!)
  6. automatically unpack JSON files to work dir so that we can submit to Ganga
  7. use 6 character padding for the job numbers in various filenames
  8. use an A-prime gen script (uses hps-mc framework)
  9. use job parameters (format for hps-mc jobs)

In particular, the ‘-g’ switch activates automatic creation of Ganga jobs, and ‘-u’ automatically unpacks all the job JSON files into the work dir so that they are ready for immediate batch submission.

All the batch job management is now done with Ganga, which will manage all of the LSF jobs.

Using Ganga

To use the Ganga, interface you need to have it installed in the Python installation you are using.

You can setup a pre-installed python at SLAC using this command:

. /nfs/slac/g/hps/hps_soft/conda/setup.sh

Now, in a shell type ‘ganga’ which opens the special command shell.

Job Management

Type 'jobs' in this shell to see all the jobs in your Ganga repo and their statuses.

All of your jobs that were just created should have a status of ‘new’ and can be submitted using a simple command like this:

ganga> jobs.submit()

Sophisticated job manipulation can now be performed using interactive Python commands or the Ganga shell commands.

For example, see these docs on how to select jobs by id, status, etc.

Once the jobs are launched, they will be in the LSF system and you may still issue LSF commands like 'bsub' directly from your shell, and Ganga will automatically see the changes.

Help!

Questions about this interface or simple usage of Ganga can be posted to the #software channel in the HPS Slack or emailed to the hps software mailing list (the bug tracker of this project is an okay place to post technical questions/comments as well).

Clone this wiki locally