File size: 1,212 Bytes
fcca8c8
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
"""General pytest tests for axolotl.cli.main interface."""

from axolotl.cli.main import build_command, cli


def test_build_command():
    """Test converting dict of options to CLI arguments"""
    base_cmd = ["accelerate", "launch"]
    options = {
        "learning_rate": 1e-4,
        "batch_size": 8,
        "debug": True,
        "use_fp16": False,
        "null_value": None,
    }

    result = build_command(base_cmd, options)
    assert result == [
        "accelerate",
        "launch",
        "--learning-rate",
        "0.0001",
        "--batch-size",
        "8",
        "--debug",
    ]


def test_invalid_command_options(cli_runner):
    """Test handling of invalid command options"""
    result = cli_runner.invoke(
        cli,
        [
            "train",
            "config.yml",
            "--invalid-option",
            "value",
        ],
    )
    assert result.exit_code != 0
    assert "No such option" in result.output


def test_required_config_argument(cli_runner):
    """Test commands fail properly when config argument is missing"""
    result = cli_runner.invoke(cli, ["train"])
    assert result.exit_code != 0
    assert "Missing argument 'CONFIG'" in result.output