Exemplo n.º 1
0
def bar(ctx, benchmark, filter_name, output, x_field, y_field):
    """
    Create a bar graph from BENCHMARK data (default stdin) using X_FIELD and Y_FIELD
    as the fields for the x- and y-data respectively, rendering to OUTPUT.
    """

    root, ext = os.path.splitext(output)

    bar_spec = {
        "type": "bar",
        "series": [{
            "input_file": benchmark,
        }],
    }

    bar_spec["series"][0]["label"] = ""
    if x_field:
        bar_spec["series"][0]["xfield"] = x_field
        bar_spec["xaxis"] = {"label": x_field}
    if y_field:
        bar_spec["series"][0]["yfield"] = y_field
        bar_spec["yaxis"] = {"label": y_field, "type": "log"}
    if filter_name:
        bar_spec["series"][0]["regex"] = filter_name
        bar_spec["title"] = filter_name

    bar_spec = Specification.load_dict(bar_spec)
    backend_str = backend.infer_from_path(output)
    jobs = backend.construct_jobs(bar_spec, [(output, backend_str)])
    for job in jobs:
        backend.run(job)
Exemplo n.º 2
0
def generate_html(name):
    figure_spec = Specification.load_yaml(os.path.join(THIS_DIR, name))
    figure_spec.find_input_files([THIS_DIR])
    path = "test.html"
    backend_str = backend.infer_from_path(path)
    jobs = backend.construct_jobs(figure_spec, [(path, backend_str)])
    for job in jobs:
        backend.run(job)
Exemplo n.º 3
0
def spec(ctx, output, output_prefix, spec):
    """Create a figure from a spec file."""
    include = ctx.obj["INCLUDE"]

    # load YAML spec file
    figure_spec = Specification.load_yaml(spec)

    # apply include directories
    if include:
        utils.debug("searching dirs {}".format(include))
        figure_spec.find_input_files(include)

    # output path from command line or spec
    if output:
        utils.debug("output path from command line: {}".format(output))
        backend_str = backend.infer_from_path(output)
        utils.debug("inferred backend: {}".format(backend_str))
        output_specs = [(output, backend_str)]
    else:
        output_specs = figure_spec.output_specs()

    # prepend prefix to output_path
    if output_prefix:
        output_specs = [(os.path.join(output_prefix, path), backend_str)
                        for path, backend_str in output_specs]
        for (path, backend_str) in output_specs:
            utils.debug("prefixed output path: {}".format(path))

    # determine the figures that need to be constructed
    jobs = backend.construct_jobs(figure_spec, output_specs)

    utils.debug("{} jobs to run".format(len(jobs)))

    # run the jobs
    for job in jobs:
        backend.run(job)