mirror of
https://github.com/explosion/spaCy.git
synced 2025-06-24 23:13:04 +03:00
Add evaluate test and some cleanup
This commit is contained in:
parent
a060ed21e8
commit
2f74158b32
|
@ -202,28 +202,39 @@ def noop_config():
|
||||||
|
|
||||||
@pytest.mark.parametrize(
|
@pytest.mark.parametrize(
|
||||||
"cmd",
|
"cmd",
|
||||||
[
|
["debug config", "debug data", "train", "assemble"],
|
||||||
["debug", "config"],
|
|
||||||
["debug", "data"],
|
|
||||||
["train"],
|
|
||||||
["assemble"],
|
|
||||||
],
|
|
||||||
)
|
)
|
||||||
def test_multi_code(cmd, code_paths, data_paths, noop_config):
|
def test_multi_code(cmd, code_paths, data_paths, noop_config):
|
||||||
# check that it fails without the code arg
|
# check that it fails without the code arg
|
||||||
output = ["."] if cmd[0] in ("pretrain", "assemble") else []
|
cmd = cmd.split()
|
||||||
|
output = ["."] if cmd[0] == "assemble" else []
|
||||||
cmd = ["python", "-m", "spacy"] + cmd
|
cmd = ["python", "-m", "spacy"] + cmd
|
||||||
result = subprocess.run([*cmd, str(noop_config), *output, *data_paths])
|
result = subprocess.run([*cmd, str(noop_config), *output, *data_paths])
|
||||||
assert result.returncode == 1
|
assert result.returncode == 1
|
||||||
|
|
||||||
# check that it succeeds with the code arg
|
# check that it succeeds with the code arg
|
||||||
result = subprocess.run(
|
result = subprocess.run([*cmd, str(noop_config), *output, *data_paths, *code_paths])
|
||||||
[
|
assert result.returncode == 0
|
||||||
*cmd,
|
|
||||||
str(noop_config),
|
|
||||||
*output,
|
def test_multi_code_evaluate(code_paths, data_paths, noop_config):
|
||||||
*data_paths,
|
# Evaluation requires a model, not a config, so this works differently from
|
||||||
*code_paths,
|
# the other commands.
|
||||||
]
|
|
||||||
)
|
# Train a model to evaluate
|
||||||
|
cmd = f"python -m spacy train {noop_config} -o model".split()
|
||||||
|
result = subprocess.run([*cmd, *data_paths, *code_paths])
|
||||||
|
assert result.returncode == 0
|
||||||
|
|
||||||
|
# now do the evaluation
|
||||||
|
|
||||||
|
eval_data = data_paths[-1]
|
||||||
|
cmd = f"python -m spacy evaluate model/model-best {eval_data}".split()
|
||||||
|
|
||||||
|
# check that it fails without the code arg
|
||||||
|
result = subprocess.run(cmd)
|
||||||
|
assert result.returncode == 1
|
||||||
|
|
||||||
|
# check that it succeeds with the code arg
|
||||||
|
result = subprocess.run([*cmd, *code_paths])
|
||||||
assert result.returncode == 0
|
assert result.returncode == 0
|
||||||
|
|
Loading…
Reference in New Issue
Block a user