Exemple #1
0
def main():
    import argparse
    from edflow.config import parse_unknown_args

    import sys

    sys.path.append(os.getcwd())  # convenience: load implementations from cwd

    A = argparse.ArgumentParser(description="""
Use edeval for running callbacks on data generated using the
``edflow.eval_pipeline.eval_pipeline.EvalHook``. Once the data is created all
you have to do is pass the ``csv``-file created by the hook. It specifies all
the relevant information: Which dataset was used to create the data, along with
all config parameters and where all generated samples live.

Callbacks will be evaluated in the order they have been passed to this
function. They must be supplied in `name:callback` pairs.

For more documentation take a look at ``edflow/eval_pipeline/eval_pipeline.py``
""")

    A.add_argument(
        "-c",
        "--csv",
        default="model_output.csv",
        type=str,
        help="path to a csv-file created by the EvalHook containing"
        " samples generated by a model.",
    )
    A.add_argument(
        "-cb",
        "--callback",
        type=str,
        nargs="*",
        help="Import string to the callback functions used for the "
        "standalone evaluation.",
    )
    A.add_argument(
        "-cf",
        "--other_config",
        type=str,
        default=None,
        help=
        "Other config, which can be used to e.g. update eval_pipeline related "
        "parameters, but also others.",
    )

    args, unknown = A.parse_known_args()
    additional_kwargs = parse_unknown_args(unknown)

    callbacks = cbargs2cbdict(args.callback)

    standalone_eval_csv_file(args.csv, callbacks, additional_kwargs,
                             args.other_config)
Exemple #2
0
def test_basic_parsing():
    import argparse

    A = argparse.ArgumentParser()

    A.add_argument("--a", default="a", type=str)

    passed = [
        "--a",
        "c",
        "--b",
        "b",
        "--c",
        "12.5",
        "--d",
        "True",
        "--e",
        "[14, 15]",
        "--f",
        "a.b.c",
        "--g",
        "a/b/c",
        "--i",
        "1",
        "--j",
        "2",
        "--k",
        "3.",
        "--l",
        "abc",
        "--m",
        "{'asd': 3.5}",
        "--abc/def",
        "1.0",
        "--abc/def/ghi",
        "2.0",
        "--abc/jkl",
        "3.0",
        "--xyz/0",
        "4.0",
    ]

    print(passed)
    args, unknown = A.parse_known_args(passed)

    unknown = parse_unknown_args(unknown)

    assert not "a" in unknown
    ref = {
        "b": "b",
        "c": 12.5,
        "d": True,
        "e": [14, 15],
        "f": "a.b.c",
        "g": "a/b/c",
        "i": 1,
        "j": 2,
        "k": 3.0,
        "l": "abc",
        "m": {
            "asd": 3.5
        },
        "abc/def": 1.0,
        "abc/def/ghi": 2.0,
        "abc/jkl": 3.0,
        "xyz/0": 4.0,
    }
    assert ref == unknown
Exemple #3
0
    parser.add_argument(
        "-d",
        "--disable_cache",
        action="store_true",
        help="Disable caching dataset instantiation.",
    )
    parser.add_argument(
        "-b",
        "--base",
        nargs="*",
        metavar="config.yaml",
        help="Paths to base configs.",
        default=list(),
    )
    try:
        sys.path.append(os.getcwd())
        opt, unknown = parser.parse_known_args()
        additional_kwargs = parse_unknown_args(unknown)
        config = dict()
        for base_config in opt.base:
            with open(base_config) as f:
                config.update(yaml.full_load(f))
        update_config(config, additional_kwargs)
    except SystemExit as e:
        # This exception will be raised if --help or invalid command line arguments
        # are used. Currently streamlit prevents the program from exiting normally
        # so we have to do a hard exit.
        os._exit(e.code)

    explore(config, disable_cache=opt.disable_cache)