mirror of
https://github.com/ggerganov/llama.cpp.git
synced 2025-01-12 13:27:21 +01:00
tests : conditional python & node json schema tests (#6207)
* json: only attempt python & node schema conversion tests if their bins are present Tests introduced in https://github.com/ggerganov/llama.cpp/pull/5978 disabled in https://github.com/ggerganov/llama.cpp/pull/6198 * json: orange warnings when tests skipped * json: ensure py/js schema conv tested on ubuntu-focal-make * json: print env vars in test
This commit is contained in:
parent
72114edf06
commit
f77a8ffd3b
11
.github/workflows/build.yml
vendored
11
.github/workflows/build.yml
vendored
@ -135,6 +135,9 @@ jobs:
|
|||||||
|
|
||||||
ubuntu-focal-make:
|
ubuntu-focal-make:
|
||||||
runs-on: ubuntu-20.04
|
runs-on: ubuntu-20.04
|
||||||
|
env:
|
||||||
|
LLAMA_NODE_AVAILABLE: true
|
||||||
|
LLAMA_PYTHON_AVAILABLE: true
|
||||||
|
|
||||||
steps:
|
steps:
|
||||||
- name: Clone
|
- name: Clone
|
||||||
@ -147,6 +150,14 @@ jobs:
|
|||||||
sudo apt-get update
|
sudo apt-get update
|
||||||
sudo apt-get install build-essential gcc-8
|
sudo apt-get install build-essential gcc-8
|
||||||
|
|
||||||
|
- uses: actions/setup-node@v4
|
||||||
|
with:
|
||||||
|
node-version: "20"
|
||||||
|
|
||||||
|
- uses: actions/setup-python@v4
|
||||||
|
with:
|
||||||
|
python-version: "3.11"
|
||||||
|
|
||||||
- name: Build
|
- name: Build
|
||||||
id: make_build
|
id: make_build
|
||||||
env:
|
env:
|
||||||
|
@ -799,6 +799,9 @@ static void test_all(const std::string & lang, std::function<void(const TestCase
|
|||||||
}
|
}
|
||||||
|
|
||||||
int main() {
|
int main() {
|
||||||
|
fprintf(stderr, "LLAMA_NODE_AVAILABLE = %s\n", getenv("LLAMA_NODE_AVAILABLE") ? "true" : "false");
|
||||||
|
fprintf(stderr, "LLAMA_PYTHON_AVAILABLE = %s\n", getenv("LLAMA_PYTHON_AVAILABLE") ? "true" : "false");
|
||||||
|
|
||||||
test_all("C++", [](const TestCase & tc) {
|
test_all("C++", [](const TestCase & tc) {
|
||||||
try {
|
try {
|
||||||
tc.verify(json_schema_to_grammar(nlohmann::ordered_json::parse(tc.schema)));
|
tc.verify(json_schema_to_grammar(nlohmann::ordered_json::parse(tc.schema)));
|
||||||
@ -808,18 +811,28 @@ int main() {
|
|||||||
tc.verify_status(FAILURE);
|
tc.verify_status(FAILURE);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
//test_all("Python", [](const TestCase & tc) {
|
|
||||||
// write("test-json-schema-input.tmp", tc.schema);
|
if (getenv("LLAMA_PYTHON_AVAILABLE") || (std::system("python --version") == 0)) {
|
||||||
// tc.verify_status(std::system(
|
test_all("Python", [](const TestCase & tc) {
|
||||||
// "python ./examples/json-schema-to-grammar.py test-json-schema-input.tmp > test-grammar-output.tmp") == 0 ? SUCCESS : FAILURE);
|
write("test-json-schema-input.tmp", tc.schema);
|
||||||
// tc.verify(read("test-grammar-output.tmp"));
|
tc.verify_status(std::system(
|
||||||
//});
|
"python ./examples/json-schema-to-grammar.py test-json-schema-input.tmp > test-grammar-output.tmp") == 0 ? SUCCESS : FAILURE);
|
||||||
//test_all("JavaScript", [](const TestCase & tc) {
|
tc.verify(read("test-grammar-output.tmp"));
|
||||||
// write("test-json-schema-input.tmp", tc.schema);
|
});
|
||||||
// tc.verify_status(std::system(
|
} else {
|
||||||
// "node ./tests/run-json-schema-to-grammar.mjs test-json-schema-input.tmp > test-grammar-output.tmp") == 0 ? SUCCESS : FAILURE);
|
fprintf(stderr, "\033[33mWARNING: Python not found, skipping Python JSON schema -> grammar tests.\n\033[0m");
|
||||||
// tc.verify(read("test-grammar-output.tmp"));
|
}
|
||||||
//});
|
|
||||||
|
if (getenv("LLAMA_NODE_AVAILABLE") || (std::system("node --version") == 0)) {
|
||||||
|
test_all("JavaScript", [](const TestCase & tc) {
|
||||||
|
write("test-json-schema-input.tmp", tc.schema);
|
||||||
|
tc.verify_status(std::system(
|
||||||
|
"node ./tests/run-json-schema-to-grammar.mjs test-json-schema-input.tmp > test-grammar-output.tmp") == 0 ? SUCCESS : FAILURE);
|
||||||
|
tc.verify(read("test-grammar-output.tmp"));
|
||||||
|
});
|
||||||
|
} else {
|
||||||
|
fprintf(stderr, "\033[33mWARNING: Node not found, skipping JavaScript JSON schema -> grammar tests.\n\033[0m");
|
||||||
|
}
|
||||||
|
|
||||||
test_all("Check Expectations Validity", [](const TestCase & tc) {
|
test_all("Check Expectations Validity", [](const TestCase & tc) {
|
||||||
if (tc.expected_status == SUCCESS) {
|
if (tc.expected_status == SUCCESS) {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user