O2-DQ User Interface 1.0.0
Loading...
Searching...
No Matches
descriptor.py
Go to the documentation of this file.
1#!/usr/bin/env python
2# PYTHON_ARGCOMPLETE_OK
3# -*- coding: utf-8 -*-
4
5# Copyright 2019-2020 CERN and copyright holders of ALICE O2.
6# See https://alice-o2.web.cern.ch/copyright for details of the copyright holders.
7# All rights not expressly granted are reserved.
8#
9# This software is distributed under the terms of the GNU General Public
10# License v3 (GPL Version 3), copied verbatim in the file "COPYING".
11#
12# In applying this license CERN does not waive the privileges and immunities
13# granted to it by virtue of its status as an Intergovernmental Organization
14# or submit itself to any jurisdiction.
15
16# This script generates Input - Output Descriptors
17
18import json
19import logging
20
21
22def inputDescriptors(tablesToProduce: dict, tables: dict, readerConfigFileName = "aodReaderTempConfig.json"):
23 """Generates Input Descriptors for Reading Tables from AO2D with json config file
24
25 Args:
26 tablesToProduce (dict): Tables are required in the output
27 tables (dict): Definition of all the tables can be produced
28 readerConfigFileName (str, optional): Output name of reader config. Defaults to "aodReaderTempConfig.json".
29 """
30
31 iTable = 0
32
33 # Generate the aod-reader output descriptor json file
34 readerConfig = {}
35 readerConfig["InputDirector"] = {
36 "debugmode": True,
37 "InputDescriptors": []
38 }
39
40 for table in tablesToProduce.keys():
41 readerConfig["InputDirector"]["InputDescriptors"].insert(iTable, tables[table])
42 iTable += 1
43
44 readerConfigFileName = "aodReaderTempConfig.json"
45 with open(readerConfigFileName, "w") as readerConfigFile:
46 json.dump(readerConfig, readerConfigFile, indent = 2)
47
48 logging.info("aodReaderTempConfig==========")
49 print(readerConfig)
50
51
52def outputDescriptors(tablesToProduce: dict, tables: dict, writerConfigFileName = "aodWriterTempConfig.json"):
53 """Generates Output Descriptors for Reading Tables from AO2D with json config file
54
55 Args:
56 tablesToProduce (dict): Tables are required in the output
57 tables (dict): Definition of all the tables can be produced
58 writerConfigFileName (str, optional): Output name of writer config. Defaults to "aodWriterTempConfig.json".
59 """
60
61 iTable = 0
62
63 # Generate the aod-writer output descriptor json file
64 writerConfig = {}
65 writerConfig["OutputDirector"] = {
66 "debugmode": True,
67 "resfile": "reducedAod",
68 "resfilemode": "RECREATE",
69 "ntfmerge": 1,
70 "OutputDescriptors": [],
71 }
72
73 for table in tablesToProduce.keys():
74 writerConfig["OutputDirector"]["OutputDescriptors"].insert(iTable, tables[table])
75 iTable += 1
76
77 writerConfigFileName = "aodWriterTempConfig.json"
78 with open(writerConfigFileName, "w") as writerConfigFile:
79 json.dump(writerConfig, writerConfigFile, indent = 2)
80
81 logging.info("aodWriterTempConfig==========")
82 print(writerConfig)