Belle II Software light-2406-ragdoll
batchToTxt.py
1# @cond
2import json
3skimfiles = json.loads(open(snakemake.input.skim_dirs, "r").read())
4outputfiles = snakemake.output
5BatchesPerSkim = snakemake.params.BatchesPerSkim
6
7binwidth = int(len(skimfiles)/BatchesPerSkim)
8if(binwidth < 1.):
9 raise ValueError("Attempting to batching with binwidth smaller 1. Decrease the number of batches!")
10
11batches = {}
12for batch in range(BatchesPerSkim):
13 if(batch == BatchesPerSkim - 1):
14 batches.update({outputfiles[batch]: list(skimfiles[binwidth*batch:])})
15 else:
16 batches.update({outputfiles[batch]: list(skimfiles[binwidth*batch:binwidth*(batch+1)])})
17
18for key, file_list in batches.items():
19 with open(key, "w") as f:
20 f.write(json.dumps(file_list))
21# @endcond