Skip to content

Commit

Permalink
review comments
Browse files Browse the repository at this point in the history
  • Loading branch information
mafrahm committed Feb 12, 2024
1 parent e09f567 commit ea5566a
Showing 1 changed file with 20 additions and 16 deletions.
36 changes: 20 additions & 16 deletions scripts/get_das_info.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
import law


def convert_to_desired_structure(data: dict) -> str:
def convert_default(data: dict) -> str:
"""
Function that converts dataset info into one order Dataset per query
"""
Expand All @@ -39,25 +39,27 @@ def convert_to_desired_structure(data: dict) -> str:
"_MT-171p5_": "mtop_down",
"_MT-173p5_": "mtop_up",
# dataset types that I have no use for but want to keep anyways
"_MT-166p5_": "xxx",
"_MT-169p5_": "xxx",
"_MT-175p5_": "xxx",
"_MT-178p5_": "xxx",
"_DS_TuneCP5_": "xxx",
"_TuneCP5_ERDOn_": "xxx",
"_TuneCH3_": "xxx",
"_MT-166p5_": "comment",
"_MT-169p5_": "comment",
"_MT-175p5_": "comment",
"_MT-178p5_": "comment",
"_DS_TuneCP5_": "comment",
"_TuneCP5_ERDOn_": "comment",
"_TuneCH3_": "comment",
# dataset types that I want to skip completely
# "example_key": "ignore",
# nominal entry as the last one such that other dataset types get priority
"_TuneCP5_": "nominal",
}


def convert_for_top_queries(data: dict) -> str:
def convert_top(data: dict) -> str:
"""
Function that converts dataset info into either an order Datset for nominal datasets
or to a DatasetInfo for variations of datasets such as tune or mtop.
Exemplary usage:
python get_das_info.py -f convert_for_top_queries -d "/TTtoLNu2Q*/Run3Summer22EENanoAODv12-130X_*/NANOAODSIM"
python get_das_info.py -f convert_top -d "/TTtoLNu2Q*/Run3Summer22EENanoAODv12-130X_*/NANOAODSIM"
"""
dataset_type = None

Expand Down Expand Up @@ -88,15 +90,17 @@ def convert_for_top_queries(data: dict) -> str:
),
),
)"""
elif dataset_type == "xxx":
elif dataset_type == "comment":
# comment out this dataset
return f""" # {dataset_type}=DatasetInfo(
# keys=[
# "{data['name']}", # noqa
# "xxx", # noqa
# ],
# n_files={data['nfiles']},
# n_events={data['nevents']},
# ),"""
elif dataset_type == "ignore":
return ""
else:
# some known variation of the dataset
return f""" {dataset_type}=DatasetInfo(
Expand All @@ -109,8 +113,8 @@ def convert_for_top_queries(data: dict) -> str:


convert_functions = {
"convert_to_desired_structure": convert_to_desired_structure,
"convert_for_top_queries": convert_for_top_queries,
"convert_default": convert_default,
"convert_top": convert_top,
}


Expand All @@ -121,7 +125,7 @@ def print_das_info(
):
# get the requested convert function
if not convert_function_str:
convert_function_str = "convert_to_desired_structure"
convert_function_str = "convert_default"
convert_function = convert_functions[convert_function_str]

for das_string in das_strings:
Expand Down Expand Up @@ -181,6 +185,6 @@ def print_das_info(
if __name__ == "__main__":
parser = ArgumentParser()
parser.add_argument("-d", "--dataset", dest="dataset", nargs="+", help="das name")
parser.add_argument("-f", "--function", dest="function", help="function that converts info into code")
parser.add_argument("-c", "--convert", dest="convert", help="function that converts info into code")
args = parser.parse_args()
print_das_info(args.dataset, convert_function_str=args.function)

0 comments on commit ea5566a

Please sign in to comment.