コード例 #1
0
    return checksum_dict


if __name__ == '__main__':
    parser = argparse.ArgumentParser()
    parser.add_argument('config_file', nargs='?', type=str, 
                        default='', help="Configuration file.")
    args = parser.parse_args()

    header = """
        # This file was produced by make_file_checksums.py and is used by the
        # test_*_checksums.py unit tests. Don't modify it by hand!
        #
        """

    config = shared.get_configuration(args.config_file, check_input=True, check_output=True)
    md5_path = config['paths']['md5_path']
    obs_path = config['paths']['OBS_ROOT_DIR']
    model_path = config['paths']['MODEL_ROOT_DIR']
    out_path = config['paths']['OUTPUT_DIR']

    case_list = shared.get_test_data_configuration()

    print 'Hashing input observational data'
    checksum_dict = checksum_in_subtree_1(obs_path, case_list['pods'])
    with open(os.path.join(md5_path, 'checksum_obs_data.yml'), 'w') as file_obj:
        file_obj.write(textwrap.dedent(header))
        yaml.dump(checksum_dict, file_obj)

    print 'Hashing input model data'
    checksum_dict = checksum_in_subtree_1(model_path, case_list['models'])
コード例 #2
0
    else:
        import subprocess
from src.util import write_yaml
import shared_test_utils as shared

DOING_TRAVIS = (os.environ.get('TRAVIS', False) == 'true')
DOING_MDTF_DATA_TESTS = ('--data_tests' in sys.argv)
DOING_SETUP = DOING_MDTF_DATA_TESTS and not DOING_TRAVIS
# All this is a workaround because tests are programmatically generated at
# import time, but the tests are skipped at runtime. We're skipping tests
# because we're not in an environment where we have the data to set them up,
# so we just throw everything in an if-block to ensure they don't get generated
# if they're going to be skipped later.

if DOING_SETUP:
    config = shared.get_configuration('', check_input=True)
    out_path = config['paths']['OUTPUT_DIR']

    case_list = shared.get_test_data_configuration()

    # write temp configuration, one for each POD
    temp_config = config.copy()
    temp_config['pod_list'] = []
    temp_config['settings']['make_variab_tar'] = False
    temp_config['settings']['test_mode'] = True

    pod_configs = shared.configure_pods(case_list,
                                        config_to_insert=temp_config)
    for pod in case_list['pods']:
        write_yaml(pod_configs[pod], os.path.join(out_path, pod + '_temp.yml'))