def print_mc_datasets_simple(mc_datasets, keys):
  if nested_dict.is_nested_dict(mc_datasets, keys):
    paths = nested_dict.get_item_nested_dict(mc_datasets, keys)
    for path in paths:
      print(get_info_path_string_mc_datasets(path, mc_datasets, '  '))
  else:
    print(str(keys)+' do not exist in mc_datasets')
Esempio n. 2
0
def check_entries(job_argument_string):
    #try:
    print(job_argument_string)
    args = get_args(['dataset_files_info_filename', 'command'],
                    job_argument_string)
    args_command = get_args_command(args['command'])

    print(args)
    print(args_command)
    file_path = get_file_path(args_command['output_path'], "",
                              args_command['input_path'])
    #print(file_path)
    if not os.path.isfile(file_path):
        # Wait for file to appear on raid
        file_exists = False
        for iWait in range(10):
            time.sleep(10)
            if os.path.isfile(file_path):
                file_exists = True
                break
        if not file_exists:
            return '[For queue_system] fail: no file named ' + file_path

    root_file = ROOT.TFile.Open(file_path)
    if not root_file:
        return '[For queue_system] fail: Failed in opening ' + file_path
    root_tree = root_file.Get('Events')
    root_number_entries = root_tree.GetEntries()

    #print(args['dataset_files_info_filename'][1:-1])
    #datasets_files_info[dataset][filename] = {'number_events':number_events}
    dataset_files_info = nested_dict.load_json_file(
        args['dataset_files_info_filename'], False)
    path_to_keys_dataset_files_info = datasets.get_path_to_keys_dataset_files_info(
        dataset_files_info)
    keys = path_to_keys_dataset_files_info[args_command['input_path']]
    #print(keys)
    #print(nested_dict.get_item_nested_dict(dataset_files_info,keys))
    dataset_number_entries = nested_dict.get_item_nested_dict(
        dataset_files_info, keys)['number_events']

    #print(root_number_entries)
    #print(dataset_number_entries)
    if root_number_entries == dataset_number_entries:
        return '[For queue_system] success'
    else:
        return '[For queue_system] fail: root_number_entries: ' + str(
            root_number_entries) + ' and dataset_number_entries: ' + str(
                dataset_number_entries) + ' do not match'
Esempio n. 3
0
def get_info_path_string_mc_datasets(path, mc_datasets, prefix):
    out_info_path = ''
    # Make meta
    path_to_keys_mc_datasets = datasets.get_path_to_keys_mc_datasets(
        mc_datasets)
    mini_to_nanos_from_nanoaod = datasets.get_mini_to_nanos_from_nanoaod_mc_datasets(
        mc_datasets)
    nano_to_mini_from_miniaod = datasets.get_nano_to_mini_from_miniaod_mc_datasets(
        mc_datasets)

    keys = path_to_keys_mc_datasets[path]
    keys.append(path)
    path_info = nested_dict.get_item_nested_dict(mc_datasets, keys)
    bad_pu = filter_datasets_jsons.reject_bad_pu_2017_mc_datasets(
        '', mc_datasets, keys[0], keys[1], keys[2], keys[3])

    # Print extra info
    if bad_pu:
        out_info_path += '  BAD PU\n'
    same_parent_paths = datasets.get_same_parent_paths(mc_datasets)
    if has_same_parent(same_parent_paths, path):
        out_info_path += '  Has same parent\n'
    if 'miniaod' in keys:
        if path in mini_to_nanos_from_nanoaod:
            out_info_path += prefix + '  Matching nanoaod: ' + get_list_string(
                mini_to_nanos_from_nanoaod[path]) + '\n'
        else:
            out_info_path += prefix + '  No matching nanoaod.\n'
    if 'nanoaod' in keys:
        if path in nano_to_mini_from_miniaod:
            out_info_path += prefix + '  Matching miniaod: ' + nano_to_mini_from_miniaod[
                path] + '\n'
        else:
            out_info_path += prefix + '  No matching miniaod.'

    out_info_path += prefix + '  creation_time: ' + str(
        datasets.convert_timestamp(path_info['creation_time'])) + '\n'
    out_info_path += prefix + '  parent_chain:\n'
    parent_prefix = '    '
    for parent in path_info['parent_chain']:
        out_info_path += prefix + parent_prefix + parent + '\n'
        parent_prefix += '  '
    #if len(path_info['children']) != 0:
    #  out_info_path += prefix + '  children:\n'
    #  for child in path_info['children']:
    #    out_info_path += prefix + '  ' + child+'\n'
    #out_info_path = out_info_path.rstrip()
    return out_info_path