Ganga 3 CLIP Tutorial Jakub T. Moscicki ARDA/LHCb Ganga Tutorial, April 2005
Ganga Tutorial, April Contents Quick introduction to Python Statements, variables, functions Modules, classes, objects Basics of Ganga Scripting Interface simple executable jobs Simple DaVinci jobs Job Registry and looping
Ganga Tutorial, April Python Website: Excelent Python Tutorial: Documentation: How to start on lxplus at CERN (python 2.2) % python Python (#1, Jan , 21:26:22) >>> ^D % Python Quickstart
Ganga Tutorial, April x = 2 print x*3 if x==2: print "yes, x==2" # NOTE INITIAL SPACES! alist = [1,2,3] for y in alist: print y print len(alist) # built-in function len help(len) Statements, Variables
Ganga Tutorial, April print range(10) help(range) def square(v): return v*v print square(x) alist = [1,2,3] for i in range(len(alist)): alist[i] = square(alist[i]) Functions
Ganga Tutorial, April import sys print sys.argv sys.exit(-1) import os print os.environ['HOME'] from os import environ from os import * import math, cmath Modules
Ganga Tutorial, April # user defined classes a = MyClass(2,3) a.my_method(1) #built-in classes: for example strings s = "hello at the tutorial" s.split() s.count('a') s.upper() dir(s) Classes and Objects
Ganga Tutorial, April Start Ganga in text mode: % ganga -t >>> from Ganga.CLIP import * Job Objects and Job Registry j = Job() print j print j.application print j.backend print jobs print jobs[1] Ganga Scripting
Ganga Tutorial, April Jobs Job { status = 'new', name = '', stdout = None, stderr = None, directory = '/afs/cern.ch/user/k/kuba/myGangaJobs/Job ', exitcode = None, id = 7, application = Executable { outputfiles = [], inputfiles = [], parameters = [], exe = '/afs/cern.ch/user/k/kuba' }, backend = Local { id = None }
Ganga Tutorial, April j = Job() j.application.exe = '/bin/hostname' j.name = "MyTest" print j j.submit() print j.status print j.directory+'/output' ### open new terminal and inspect output % cat OUTPUTDIR/std.out Basic Job Submission
Ganga Tutorial, April for i in range(5): j = Job(exe="/bin/echo", parameters=["hello ",str(i)]) for j in jobs: print j.id, j.directory print j.submit() Jobs in a loop
Ganga Tutorial, April j = Job(application="DaVinci") print j j.submit() Default DaVinci Job Submission
Ganga Tutorial, April Questions? Practical exercises Questions?