Skip to content
Snippets Groups Projects
Commit 912feb17 authored by Stefan Reck's avatar Stefan Reck
Browse files

draft for toml parser

parent 7f6a045e
No related branches found
No related tags found
1 merge request!20Parser
import os
import toml
from orcasong.core import FileGraph
from orcasong.extractors import get_neutrino_mc_info_extr
EXTRACTORS = {
"neutrino": get_neutrino_mc_info_extr,
}
def add_parser(subparsers):
parser = subparsers.add_parser(
"graph",
description='Produce graph dl file from aanet file.')
parser.add_argument('infile', type=str)
parser.add_argument('config', type=str)
parser.add_argument('detx_file', type=str)
parser.add_argument('--outfile', type=str, default=None)
return parser.parse_args()
def make_graph(infile, config, detx_file, outfile=None):
if outfile is None:
outfile = f"{os.path.splitext(os.path.basename(infile))[0]}_dl.h5"
cfg = toml.load(config)
extractor_cfg = cfg.pop("extractor")
extractor_name = extractor_cfg.pop("name")
inps = {"infile": infile, "config": config, "detx_file": detx_file, "outfile": outfile}
extractor = EXTRACTORS[extractor_name](inps, **extractor_cfg)
FileGraph(
det_file=detx_file,
extractor=extractor,
**cfg,
).run(infile=infile, outfile=outfile)
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment