* Initial CLI implementation with click package * Adding fetch command for pulling examples and deepspeed configs * Automating default options for CliArgs classes * Mimicking existing no config behavior * bugfix in choose_config * Updating fetch to sync instead of re-download * bugfix * isort fix * fixing yaml isort order * pre-commit fixes * simplifying argument parsing -- pass through kwargs to do_cli * make accelerate launch default for non-preprocess commands * fixing arg handling * testing None placeholder approach * removing hacky --use-gpu argument to preprocess command * Adding brief README documentation for CLI * remove (New) * Initial CLI pytest tests * progress on CLI pytest * adding inference CLI tests; cleanup * Refactor train CLI tests to remove various mocking * Major CLI test refator; adding remaining CLI codepath test coverage * pytest fixes * remove integration markers * parallelizing examples, deepspeed config downloads; rename test to match other CLI test naming * moving cli pytest due to isolation issues; cleanup * testing fixes; various minor improvements * fix * tests fix * Update tests/cli/conftest.py Co-authored-by: Wing Lian <wing.lian@gmail.com> --------- Co-authored-by: Dan Saunders <dan@axolotl.ai> Co-authored-by: Wing Lian <wing.lian@gmail.com>
77 lines
2.3 KiB
Python
77 lines
2.3 KiB
Python
"""pytest tests for axolotl CLI shard command."""
|
|
# pylint: disable=duplicate-code
|
|
from unittest.mock import patch
|
|
|
|
from axolotl.cli.main import cli
|
|
|
|
|
|
def test_shard_with_accelerate(cli_runner, config_path):
|
|
"""Test shard command with accelerate"""
|
|
with patch("subprocess.run") as mock:
|
|
result = cli_runner.invoke(cli, ["shard", str(config_path), "--accelerate"])
|
|
|
|
assert mock.called
|
|
assert mock.call_args.args[0] == [
|
|
"accelerate",
|
|
"launch",
|
|
"-m",
|
|
"axolotl.cli.shard",
|
|
str(config_path),
|
|
"--debug-num-examples",
|
|
"0",
|
|
]
|
|
assert mock.call_args.kwargs == {"check": True}
|
|
assert result.exit_code == 0
|
|
|
|
|
|
def test_shard_no_accelerate(cli_runner, config_path):
|
|
"""Test shard command without accelerate"""
|
|
with patch("axolotl.cli.shard.do_cli") as mock:
|
|
result = cli_runner.invoke(cli, ["shard", str(config_path), "--no-accelerate"])
|
|
|
|
assert mock.called
|
|
assert result.exit_code == 0
|
|
|
|
|
|
def test_shard_with_model_dir(cli_runner, config_path, tmp_path):
|
|
"""Test shard command with model_dir option"""
|
|
model_dir = tmp_path / "model"
|
|
model_dir.mkdir()
|
|
|
|
with patch("axolotl.cli.shard.do_cli") as mock:
|
|
result = cli_runner.invoke(
|
|
cli,
|
|
[
|
|
"shard",
|
|
str(config_path),
|
|
"--no-accelerate",
|
|
"--model-dir",
|
|
str(model_dir),
|
|
],
|
|
catch_exceptions=False,
|
|
)
|
|
|
|
assert mock.called
|
|
assert mock.call_args.kwargs["config"] == str(config_path)
|
|
assert mock.call_args.kwargs["model_dir"] == str(model_dir)
|
|
assert result.exit_code == 0
|
|
|
|
|
|
def test_shard_with_save_dir(cli_runner, config_path):
|
|
with patch("axolotl.cli.shard.do_cli") as mock:
|
|
result = cli_runner.invoke(
|
|
cli,
|
|
[
|
|
"shard",
|
|
str(config_path),
|
|
"--no-accelerate",
|
|
"--save-dir",
|
|
"/path/to/save",
|
|
],
|
|
)
|
|
|
|
assert mock.called
|
|
assert mock.call_args.kwargs["config"] == str(config_path)
|
|
assert mock.call_args.kwargs["save_dir"] == "/path/to/save"
|
|
assert result.exit_code == 0
|