def cli(ctx, workflow_path, output=None, split_test=False, **kwds):
    """Initialize a Galaxy workflow test description for supplied workflow.

    Be sure to your lint your workflow with ``workflow_lint`` before calling this
    to ensure inputs and outputs comply with best practices that make workflow
    testing easier.
    """
    path_basename = os.path.basename(workflow_path)
    job = job_template(workflow_path)
    if output is None:
        output = new_workflow_associated_path(workflow_path)
    job_output = new_workflow_associated_path(workflow_path, suffix="job1")
    if not can_write_to_path(output, **kwds):
        ctx.exit(1)

    test_description = [{
         'doc': 'Test outline for %s' % path_basename,
         'job': job,
         'outputs': output_stubs_for_workflow(workflow_path),
    }]
    if split_test:
        job_output = new_workflow_associated_path(workflow_path, suffix="job1")
        if not can_write_to_path(job_output, **kwds):
            ctx.exit(1)

        test_description[0]['job'] = os.path.basename(job_output)
        with open(job_output, "w") as f_job:
            yaml.dump(job, f_job)
    with open(output, "w") as f:
        yaml.dump(test_description, f)
Esempio n. 2
0
def cli(ctx, workflow_identifier, output=None, **kwds):
    """Initialize a Galaxy workflow job description for supplied workflow.

    Be sure to your lint your workflow with ``workflow_lint`` before calling this
    to ensure inputs and outputs comply with best practices that make workflow
    testing easier.

    Jobs can be run with the planemo run command (``planemo run workflow.ga job.yml``).
    Planemo run works with Galaxy tools and CWL artifacts (both tools and workflows)
    as well so this command may be renamed to to job_init at something along those
    lines at some point.
    """
    if kwds["from_invocation"]:
        if not os.path.isdir('test-data'):
            ctx.log("Creating test-data directory.")
            os.makedirs("test-data")
        path_basename = get_workflow_from_invocation_id(
            workflow_identifier, kwds["galaxy_url"], kwds["galaxy_user_key"])

    job = job_template(workflow_identifier, **kwds)

    if output is None:
        output = new_workflow_associated_path(
            path_basename if kwds["from_invocation"] else workflow_identifier,
            suffix="job")
    if not can_write_to_path(output, **kwds):
        ctx.exit(1)
    with open(output, "w") as f_job:
        yaml.dump(job, f_job)
Esempio n. 3
0
def cli(ctx, workflow_identifier, output=None, **kwds):
    """Initialize a Galaxy workflow job description for supplied workflow.

    Be sure to your lint your workflow with ``workflow_lint`` before calling this
    to ensure inputs and outputs comply with best practices that make workflow
    testing easier.

    Jobs can be run with the planemo run command (``planemo run workflow.ga job.yml``).
    Planemo run works with Galaxy tools and CWL artifacts (both tools and workflows)
    as well so this command may be renamed to to job_init at something along those
    lines at some point.
    """
    job = job_template(workflow_identifier)
    if output is None:
        output = new_workflow_associated_path(workflow_identifier, suffix="job")
    if not can_write_to_path(output, **kwds):
        ctx.exit(1)
    with open(output, "w") as f_job:
        yaml.dump(job, f_job)
Esempio n. 4
0
def cli(ctx, workflow_identifier, output=None, split_test=False, **kwds):
    """Initialize a Galaxy workflow test description for supplied workflow.

    Be sure to your lint your workflow with ``workflow_lint`` before calling this
    to ensure inputs and outputs comply with best practices that make workflow
    testing easier.
    """
    if kwds["from_invocation"]:
        if not os.path.isdir('test-data'):
            ctx.log("Creating test-data directory.")
            os.makedirs("test-data")
        path_basename = get_workflow_from_invocation_id(workflow_identifier, kwds["galaxy_url"], kwds["galaxy_user_key"])
    else:
        path_basename = os.path.basename(workflow_identifier)
    job = job_template(workflow_identifier, **kwds)
    if output is None:
        output = new_workflow_associated_path(path_basename if kwds["from_invocation"] else workflow_identifier)
    job_output = new_workflow_associated_path(path_basename if kwds["from_invocation"] else workflow_identifier, suffix="job1")
    if not can_write_to_path(output, **kwds):
        ctx.exit(1)

    test_description = [{
         'doc': 'Test outline for %s' % path_basename,
         'job': job,
         'outputs': output_stubs_for_workflow(workflow_identifier, **kwds),
    }]
    if split_test:
        job_output = new_workflow_associated_path(path_basename if kwds["from_invocation"] else workflow_identifier, suffix="job1")
        if not can_write_to_path(job_output, **kwds):
            ctx.exit(1)

        test_description[0]['job'] = os.path.basename(job_output)
        with open(job_output, "w") as f_job:
            yaml.dump(job, f_job)
    with open(output, "w") as f:
        yaml.dump(test_description, f)