Esempio n. 1
0
def test_run_args_from_cli(mocker, dvc):
    args = parse_args(["run", "echo", "foo"])
    cmd = args.func(args)
    m = mocker.patch.object(cmd.repo, "run", autospec=True)
    assert cmd.run() == 0
    assert called_once_with_subset(
        m,
        deps=[],
        outs=[],
        outs_no_cache=[],
        metrics=[],
        metrics_no_cache=[],
        plots=[],
        plots_no_cache=[],
        live=None,
        live_no_cache=None,
        live_no_summary=False,
        live_no_html=False,
        outs_persist=[],
        outs_persist_no_cache=[],
        checkpoints=[],
        params=[],
        fname=None,
        wdir=None,
        no_exec=False,
        force=False,
        run_cache=True,
        no_commit=False,
        always_changed=False,
        cmd="echo foo",
        name=None,
        single_stage=False,
        external=False,
        desc=None,
    )
Esempio n. 2
0
def test_experiments_init_extra_args(extra_args, expected_kw, mocker):
    cli_args = parse_args(["exp", "init", *extra_args, "cmd"])
    cmd = cli_args.func(cli_args)
    assert isinstance(cmd, CmdExperimentsInit)

    m = mocker.patch("dvc.repo.experiments.init.init")
    assert cmd.run() == 0
    assert called_once_with_subset(m, ANY(Repo), **expected_kw)
Esempio n. 3
0
def test_experiments_init_cmd_not_required_for_interactive_mode(dvc, mocker):
    cli_args = parse_args(["exp", "init", "--interactive"])
    cmd = cli_args.func(cli_args)
    assert isinstance(cmd, CmdExperimentsInit)

    m = mocker.patch("dvc.repo.experiments.init.init")
    assert cmd.run() == 0
    assert called_once_with_subset(m, ANY(Repo), interactive=True)
Esempio n. 4
0
def test_stage_add(mocker, dvc, command, parsed_command):
    cli_args = parse_args(
        [
            "stage",
            "add",
            "--name",
            "name",
            "--deps",
            "deps",
            "--outs",
            "outs",
            "--outs-no-cache",
            "outs-no-cache",
            "--metrics",
            "metrics",
            "--metrics-no-cache",
            "metrics-no-cache",
            "--plots",
            "plots",
            "--plots-no-cache",
            "plots-no-cache",
            "--live",
            "live",
            "--live-no-summary",
            "--live-no-html",
            "--wdir",
            "wdir",
            "--force",
            "--outs-persist",
            "outs-persist",
            "--outs-persist-no-cache",
            "outs-persist-no-cache",
            "--checkpoints",
            "checkpoints",
            "--always-changed",
            "--params",
            "file:param1,param2",
            "--params",
            "param3",
            "--external",
            "--desc",
            "description",
            "--force",
            *command,
        ]
    )
    assert cli_args.func == CmdStageAdd

    cmd = cli_args.func(cli_args)
    m = mocker.patch.object(cmd.repo.stage, "add")

    assert cmd.run() == 0
    assert called_once_with_subset(
        m,
        name="name",
        deps=["deps"],
        outs=["outs"],
        outs_no_cache=["outs-no-cache"],
        params=[
            {"file": ["param1", "param2"]},
            {"params.yaml": ["param3"]},
        ],
        metrics=["metrics"],
        metrics_no_cache=["metrics-no-cache"],
        plots=["plots"],
        plots_no_cache=["plots-no-cache"],
        live="live",
        live_no_summary=True,
        live_no_html=True,
        wdir="wdir",
        outs_persist=["outs-persist"],
        outs_persist_no_cache=["outs-persist-no-cache"],
        checkpoints=["checkpoints"],
        always_changed=True,
        external=True,
        desc="description",
        cmd=parsed_command,
        force=True,
    )
Esempio n. 5
0
def test_run(mocker, dvc):
    cli_args = parse_args([
        "run",
        "--name",
        "nam",
        "--deps",
        "deps",
        "--outs",
        "outs",
        "--outs-no-cache",
        "outs-no-cache",
        "--metrics",
        "metrics",
        "--metrics-no-cache",
        "metrics-no-cache",
        "--plots",
        "plots",
        "--plots-no-cache",
        "plots-no-cache",
        "--live",
        "live",
        "--live-no-cache",
        "live-no-cache",
        "--live-no-summary",
        "--live-no-html",
        "--file",
        "file",
        "--wdir",
        "wdir",
        "--no-exec",
        "--force",
        "--no-run-cache",
        "--no-commit",
        "--outs-persist",
        "outs-persist",
        "--outs-persist-no-cache",
        "outs-persist-no-cache",
        "--checkpoints",
        "checkpoints",
        "--always-changed",
        "--params",
        "file:param1,param2",
        "--params",
        "param3",
        "--external",
        "--desc",
        "description",
        "command",
    ])
    assert cli_args.func == CmdRun

    cmd = cli_args.func(cli_args)
    m = mocker.patch.object(cmd.repo, "run", autospec=True)

    assert cmd.run() == 0

    assert called_once_with_subset(
        m,
        deps=["deps"],
        outs=["outs"],
        outs_no_cache=["outs-no-cache"],
        metrics=["metrics"],
        metrics_no_cache=["metrics-no-cache"],
        plots=["plots"],
        plots_no_cache=["plots-no-cache"],
        outs_persist=["outs-persist"],
        outs_persist_no_cache=["outs-persist-no-cache"],
        checkpoints=["checkpoints"],
        params=["file:param1,param2", "param3"],
        live="live",
        live_no_cache="live-no-cache",
        live_no_summary=True,
        live_no_html=True,
        fname="file",
        wdir="wdir",
        no_exec=True,
        force=True,
        run_cache=False,
        no_commit=True,
        always_changed=True,
        cmd="command",
        name="nam",
        single_stage=False,
        external=True,
        desc="description",
    )