Package: nittygriddy
NittygriddyNitty griddy aims to make the deployment of analyses using the Aliroot/Aliphysics framework easy, transparent, and reproducible.
The primary goal is to completely eliminate the ungodly practice of copy-pasting togetherrun.Cfiles from all over the place.
A nittygriddy “project” requires the user to only provide the settings for the specific analysis they want to run - nothing related to how or where you would like to run your analysis.
The way these settings are supplied is analogous to how one configures a LEGO train.
The deployment inlocal(sequential),proof lite(local parallel) orgridis then completely transparent and does not require the editing of any files.
Nittygriddy also makes it easy to download parts of a desired dataset for localofflinedevelopment - no need for running grid test mode.
On top of that, nittygriddy makes it easy to trigger the merging process once a grid analysis is finished.And last but not least, nittygriddy does not do a “vendor lock-in”: nittygriddy produces straight forwardrun.Cfiles, stores them in a tidy folder structure and enables you to always rerun your analysis without nittygriddy in the future with a simpleroot run.C.DisclaimerI am using nittygriddy daily for quite a while now and find it to be extremely helpful. I think/hope that it could also be a great tool for others. I will try hard to keep the current API stable, but if needed, I might have to make some breaking changes, which might need minor actions from the users. But as I said earlier, if that were to happen and you don’t want to use nittygriddy anymore, you can always use the generatedrun.Cfiles independently. If you have issues with nittygriddy, would love to see datasets added, or have any other comments and suggestions it is best to open an issue here on github or create a pull request straight away. See more on how to contribute at the bottom of this document.Installing nittygriddyNittygriddy is available onpypi. Thus installation is easily done withpip, but first you should make sure that the stuff you install withpipwill later be avialble on the command line. Add this to your.bashrcor similar:# .bashrc or similar
export PYTHONUSERBASE=$HOME/.local_pip
export PATH=$PYTHONUSERBASE/bin:$PATHThis will make everything installed as unprivileged user withpip –usergo
underPYTHONUSERBASE. Now you can run:pip install --user nittygriddyWhich installes nittygriddy into your home directory. The commandnittyshould now be avialable on the command line, along with its hopefully helpful--help.Using nittygriddy for the impatientDon’t wanna read instructions? This is how you start an analysis on local data:$ alien-token-init <your-cern-user-name>
$ nitty datasets --download LHC15o_pass1_HIR 1  # Download 1GB of the specified dataset
$ nitty new my-analysis    # Create an example analysis folder (runs AliMultSelectionTask)
$ cd my-analysis
$ # Run the analysis of this folder on the LHC15o dataset locally
$ nitty run local LHC15o_pass1_HIR
$ ls ./latest/  # marvel at the resulting AnalysisResults.root fileSetting up a “train” folderWhat I call a “train” in the following is really nothing more than a folder where you store the settings for a specific analysis. An analysis usually consists of several task (e.g.AliMultSelectionTaskand your own task). Currently, all the settings are in one single file (ConfigureTrain.C) which make any folder a “train folder”. Also, note that in order to use nittygriddyyour task must be present in your local aliphysics installation(which it really should anyways)!ConfigureTrain.CThe only.Cfile needed. It reflects setting up the options for your task analog to what is done in the lego trains. Note that this file will be compiled and therefore has to be valid cpp (thus all the#includesin the example below). The reason for this is that using the interpreter is just plain evil and will lead to undefined behavior and sad users eventually. The shortest possible version, would look something like this:#include"TROOT.h"#include"AliVEvent.h"#include"AliBasedNdetaTask.h"voidConfigureTrain(){// Load you AddTask macrogROOT->LoadMacro("$ALICE_PHYSICS/PWGLF/FORWARD/analysis2/AddTaskdNdeta.C");// Execute your AddTask macro. You can pass options in the function call if necessaryAliBasedNdetaTask*task=reinterpret_cast<AliBasedNdetaTask*>(gROOT->ProcessLine("AddTaskdNdeta()"));/*
    Set your task's options here:
    task->SelectCollisionCandidates(AliVEvent::kMB);
  */}nitty_datasets.ymlThis file contains information about custom datasets. If the standard ones are used this is not necessary. The file should be located in your home directory at~/nitty_datasets.yml. The file has to be inYamlformating. A typical entry looks like this:LHC15o_pass1_HIR_FMD:data_pattern:pass1/AOD/*/AliAOD.rootdatadir:/alice/data/2015/LHC15o/datatype:aodis_mc:'false'notes:5.02 TeV, Good runs with FMD, ITS, and V0. This is not the full run listsince it requires the FMD!run_list:246980, 246865, 246809, 246808, 246766, 246765, 246763, 246759, 246676,246675, 246495, 246493, 246276, 246275, 246225, 246185, 246153, 246089, 246052,245963, 245954, 245833, 245705, 245683run_number_prefix:'000'system:PbPbLHC15f_AOD171_FMD:...Note thatYaml, just like Python, is indention based. But don’t worry, if the syntax is faulty, nittygriddy will complain. This includes missing fields in each entry. Datasets which are defined innitty_datasets.ymlwill be merged with the default ones which come with nittygriddy.Using NittygriddyI’m lost. Note that--helpis also available for each subcommand:$ nitty --helpCreate a new train folder. I.e. create a new folder with a minimal workingConfigureTrain.C:$ nitty new a_new_trainList all avialable datasets:$ nitty datasets -lSearch all datasets for something (e.g. the collsions system):$ nitty datasets -s PbPbShow details about a dataset:$ nitty datasets --show LHC10h_AOD160Download 5GB of data from the given dataset for offline developing.
The files are saved in~/lhc_data/following the same folder structure as on the grid:$ nitty datasets --download LHC10h_AOD160 5Run your analysis in proof lite locally:$ nitty run lite LHC10h_AOD160Or submit it to the grid using a PARfile (see below):$ nitty run grid LHC10h_AOD160 --par_files="PWGCFCorrelationsC2.par"Once your analysis is finished on the grid, change to the output dir (latestis a link pointing to the latest thing nittygriddy started) and trigger the merging:$ cd latest
$ nitty merge onlineOnce all the final merging stages are reached, you can merge individual runs offline on your own computer:$ nitty merge offlineThere are many more things you can do. Just check--help.Tips and TricksPARfilesPar files can be used if you latest changes to your task are not yet in the latest aliphysics tag.
See Dario’spagefor a bit more background. Long story short, if your task is properly set up in AliPhysics, you should be able to do:$ cd $ALICE_PHYSICS/../build
$ make PWGCFCorrelationsC2.par # you can use TAB completion to find the right par file
$ make -j$MJ installThis should create the .par file for your analysis in$ALICE_PHYSICS/PARfiles. If you get an error instead, you might not have your analysis set up properly in cmake. Dario’s post should have you covered.My analysis crashes miserably when running in Proof liteProof lite is quite picky about initializing your task’s members in the constructors. This makes it a great test for running on the grid, but the error message is rather cryptic. Check if you initialized all your members in the constructor.I get a crash if I do something grid relatedDo you have a valid alien-token? Its on the todo-list to ask for it more gracefully if its not present.Migrate to LEGO trainsOnce your analysis works, you should be able to almost seamlessly use yourConfigureTrain.Ccontent in the LEGO wagon setup. Please use LEGO-trains whenever possible and reasonable to save resources!Debug your code like a boss (with GDB)There was a talk at one of the ALICE weeks about using GDB for debugging(link).
Unfortunately, the talk did not cover how to use GDB with your task in aliphysics.
Nittygriddy makes this quite easy now with the--wait_for_gdboption:$ nitty run local LHC10h_AOD160 --wait_for_gdbThe above sets up your analysis, prints out its process id (eg. 27575) and then waits for you to attach gdb. In principle it should be as easy as:$ gdb -p 27575But there might be a few caveats. I wrote a small blog post about how to use gdbhere.Profile your codeNittygriddy makes it easy to usegdbas a stochastic profiler. This means that the running analysis is interuped many times, and a statistic is made where the analysis spends most of its time. This kind of profiling can be very visualized in so called “Flame Graphs”. Nittygriddy packages some of the files from the original [FlameGraph project](https://github.com/adam-p/markdown-here/wiki/Markdown-Cheatsheet#links) to make this process as easy as possible and this is how.First, you have to start a local analysis. You probably want to start it with the--wait_for_gdbflag to get thepid, but you can also just find thepidany other way, if you prefer:$ nitty run local LHC10h_AOD160 --wait_for_gdbNow, you have to open a second terminal where you attach the profiler to thepidof the running analysis (e.g. 27575):$ nitty profile 27575 --nsamples=100Remember to resume the analysis in the first terminal! Now you can use your browser to check out the flamegraph. For the abovepidit would be at/tmp/27575.svg. Thesvgis updated every 5 samples, so give it some time!An example of a flamegraph might then look something like this:What is happening behind the scene?When running your analysis nitty griddy create a new folder in your train folder.
It then generates arun.Cfile from your options and copies it into that folder.
Thisrun.Ccan be run on independently and should be easy to read.
This has the advantage that you can always just stop usingnittygriddyand drop back to modifying the macros yourself - no vendor lockin!
However, if you would like to continue usingnittygriddy, you should not edit those macros directly since they might get overwritten and it defeats the purpose of this program in the first place.ContributingContributions of any kind (issues, pull requests, general comments…) are always welcome! If you would like to hack on nittygriddy (for example to add new datasets to the default ones) you should check out nitty griddy as an editable python package:$ git clone https://github.com/cbourjau/nittygriddy.git
$ cd nittygriddy
$ pip install -e .This installs nittygriddy ineditablemode, meaning that any changes to the files in the repository clone are immediately available to the command line tool without re-installation. This means that updates can be raked in with a simplegit pull origin/master.