示例#1
0
def test_get_run():
    r"""Use run function to start a run."""
    namespace = "test_run_%s" % str(uuid.uuid4)
    runner.run([ex_yamls['hello']['python']],
               namespace=namespace)
    runner.run([ex_yamls['model_error']['python']],
               namespace=namespace)
示例#2
0
def validate_model_submission(fname):
    r"""Validate a YAML file according to the standards for submission to
    the yggdrasil model repository.

    Args:
        fname (str): YAML file to validate or directory in which to check
            each of the YAML files.

    """
    from yggdrasil import yamlfile, runner
    if isinstance(fname, list):
        for x in fname:
            validate_model_submission(x)
        return
    elif os.path.isdir(fname):
        files = sorted(
            glob.glob(os.path.join(fname, '*.yml')) +
            glob.glob(os.path.join(fname, '*.yaml')))
        for x in files:
            validate_model_submission(x)
        return
    # 1-2. YAML syntax and schema
    yml = yamlfile.parse_yaml(fname, model_submission=True)
    # 3a. LICENSE
    repo_dir = yml['models'][0]['working_dir']
    patterns = ['LICENSE', 'LICENSE.*']
    for x in patterns:
        if ((glob.glob(os.path.join(repo_dir, x.upper()))
             or glob.glob(os.path.join(repo_dir, x.lower())))):
            break
    else:
        raise RuntimeError("Model repository does not contain a LICENSE file.")
    # 4. Run & validate
    runner.run(fname, validate=True)
示例#3
0
def main(language, typename, language_ext=None):
    yamlfile = os.path.join(_this_dir, 'types.yml')
    modelfile = TestExampleTypes.setup_model(
        language, typename, language_ext=language_ext)
    try:
        run(yamlfile)
    finally:
        if os.path.isfile(modelfile):
            os.remove(modelfile)
示例#4
0
def yggrun():
    r"""Start a run."""
    from yggdrasil import runner
    parser = argparse.ArgumentParser(description='Run an integration.')
    parser.add_argument('yamlfile', nargs='+',
                        help='One or more yaml specification files.')
    args = parser.parse_args()
    prog = sys.argv[0].split(os.path.sep)[-1]
    runner.run(args.yamlfile, ygg_debug_prefix=prog)
示例#5
0
def main(language, transform, language_ext=None):
    yamlfile = os.path.join(_this_dir, 'transforms.yml')
    modelfile, env = TestExampleTransforms.setup_model(
        language, transform, language_ext=language_ext)
    os.environ.update(env)
    try:
        run(yamlfile)
    finally:
        if os.path.isfile(modelfile):
            os.remove(modelfile)
示例#6
0
def yggrun():
    r"""Start a run."""
    from yggdrasil import runner, config
    parser = argparse.ArgumentParser(description='Run an integration.')
    parser.add_argument('yamlfile',
                        nargs='+',
                        help='One or more yaml specification files.')
    config.get_config_parser(parser, skip_sections='testing')
    args = parser.parse_args()
    prog = sys.argv[0].split(os.path.sep)[-1]
    with config.parser_config(args):
        runner.run(args.yamlfile,
                   ygg_debug_prefix=prog,
                   production_run=args.production_run)
示例#7
0
def test_run_process_connections():
    r"""Test run with process based connections."""
    namespace = "test_run_%s" % str(uuid.uuid4)
    runner.run([ex_yamls['hello']['python']],
               connection_task_method='process',
               namespace=namespace)