Logo ROOT  
Reference Guide
Loading...
Searching...
No Matches
parallelNotebooks.py
Go to the documentation of this file.
1try:
2 import dagger
3 from joblib import Parallel, delayed
4 import subprocess
5 import multiprocessing
6 import os
7
8 outDir = os.environ["DOXYGEN_NOTEBOOK_PATH_PARALLEL"]
9
10 inputs = [input.replace("../../tutorials/", "") for input in subprocess.check_output(["grep", "-r", "-l", "/// \\\\notebook\|## \\\\notebook", os.path.expandvars("$DOXYGEN_SOURCE_DIRECTORY/tutorials")]).split()]
11
12 dependenciesgraph = dagger.dagger()
13
14 for element in inputs:
15 dependenciesgraph.add(element)
16
17 dependenciesgraph.add("analysis/unfold/testUnfold5d.C",["analysis/unfold/testUnfold5c.C"])
18 dependenciesgraph.add("analysis/unfold/testUnfold5c.C",["analysis/unfold/testUnfold5b.C"])
19 dependenciesgraph.add("analysis/unfold/testUnfold5b.C",["analysis/unfold/testUnfold5a.C"])
20 dependenciesgraph.add("io/xml/xmlreadfile.C",["io/xml/xmlnewfile.C"])
21 dependenciesgraph.add("roofit/roofit/rf503_wspaceread.C",["roofit/roofit/rf502_wspacewrite.C"])
22 dependenciesgraph.add("io/readCode.C",["io/importCode.C"])
23 dependenciesgraph.add("math/fit/fit1.C",["hist/hist001_TH1_fillrandom.C"])
24 dependenciesgraph.add("math/fit/myfit.C",["math/fit/fitslicesy.C"])
25 dependenciesgraph.add("math/foam/foam_demopers.C",["math/foam/foam_demo.C"])
26 dependenciesgraph.add("io/tree/tree502_staff.C",["io/tree/tree500_cernbuild.C"])
27 dependenciesgraph.add("io/tree/tree501_cernstaff.C",["io/tree/tree500_cernbuild.C"])
28 dependenciesgraph.add("hist/hist006_TH1_bar_charts.C",["io/tree/tree500_cernbuild.C"])
29 dependenciesgraph.add("io/tree/ntuple1.py",["hsimple.py"])
30 dependenciesgraph.add("math/fit/fit1.py",["hist/hist001_TH1_fillrandom.py"])
31 dependenciesgraph.add("machine_learning/TMVAClassificationApplication.C",["machine_learning/TMVAClassification.C"])
32 dependenciesgraph.add("machine_learning/TMVAClassificationCategory.C",["machine_learning/TMVAClassification.C"])
33 dependenciesgraph.add("machine_learning/TMVAClassificationCategoryApplication.C",["machine_learning/TMVAClassificationCategory.C"])
34 dependenciesgraph.add("machine_learning/TMVAMulticlass.C",["machine_learning/TMVAMultipleBackgroundExample.C"])
35 dependenciesgraph.add("machine_learning/TMVAMulticlassApplication.C",["machine_learning/TMVAMulticlass.C"])
36 dependenciesgraph.add("machine_learning/TMVARegressionApplication.C",["machine_learning/TMVARegression.C"])
37
38 for node in dependenciesgraph.nodes:
39 dependenciesgraph.stale(node)
40
41 dependenciesgraph.run()
42
43 iterator = dependenciesgraph.iter()
44
45 newinputs = []
46 while len(iterator)>0:
47 todo = iterator.next(10000)
48 newinputs.append(todo)
49 # print todo
50 for element in todo:
51 iterator.remove(element)
52
53 for i in newinputs:
54 print(i)
55
56 def processInput(inputFile):
57 subprocess.call([sys.executable,
58 './converttonotebook.py',
59 os.path.join(os.environ['DOXYGEN_SOURCE_DIRECTORY'], 'tutorials', inputFile),
60 outDir])
61
62 num_cores = multiprocessing.cpu_count()
63
64 def parallel(input):
65 Parallel(n_jobs=num_cores,verbose=100)(delayed(processInput)(i) for i in input)
66
67 for input in newinputs:
68 parallel(input)
69
70except:
71 print('Parallel notebooks converter failed!!')
72 pass