-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtest_combined_generation.cpp
More file actions
75 lines (60 loc) · 2.38 KB
/
test_combined_generation.cpp
File metadata and controls
75 lines (60 loc) · 2.38 KB
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
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
/*
Single-call pattern generation test (load + generate in one command)
*/
#include <iostream>
#include <string>
#include <cstdlib>
#include <fstream>
#include <random>
int main()
{
std::cout << "Testing Single-Call Pattern Generation..." << std::endl;
// Create command that loads and generates in one call
std::random_device rd;
std::mt19937 gen(rd());
std::uniform_int_distribution<> dis(1000, 9999);
std::string tempFileName = "/tmp/onnx_combined_" + std::to_string(dis(gen)) + ".json";
// First load the model, then immediately generate
std::string combinedCommand = R"({
"action": "load_and_generate",
"model_name": "midi-model"
})";
std::ofstream tempFile(tempFileName);
tempFile << combinedCommand;
tempFile.close();
// Test using our existing server with a new action
std::string pythonCommand = "source /Users/laurencedoby/Desktop/Development/spawn-clone/.venv/bin/activate && python3 -c \""
"import sys; sys.path.append('/Users/laurencedoby/Desktop/Development/spawn-clone'); "
"from midi_model_server import MIDIModelServer; "
"import json; "
"server = MIDIModelServer(); "
"result1 = server.handle_command({'action': 'load_model', 'model_name': 'midi-model'}); "
"result2 = server.handle_command({'action': 'generate_pattern', 'model_name': 'midi-model'}); "
"print(json.dumps(result2))\" 2>/tmp/debug.log";
std::cout << "🎵 Running combined load + generate..." << std::endl;
FILE* pipe = popen(pythonCommand.c_str(), "r");
std::string result;
char buffer[256];
while (fgets(buffer, sizeof(buffer), pipe) != nullptr)
{
result += buffer;
}
int exitCode = pclose(pipe);
std::remove(tempFileName.c_str());
std::cout << "Exit code: " << exitCode << std::endl;
std::cout << "Result length: " << result.length() << std::endl;
std::cout << "Result:" << std::endl;
std::cout << result << std::endl;
if (result.find("\"status\": \"success\"") != std::string::npos)
{
std::cout << "✅ SUCCESS: Combined load+generate worked!" << std::endl;
}
else
{
std::cout << "❌ Pattern generation failed" << std::endl;
// Show debug log
std::cout << "\nDebug log:" << std::endl;
system("cat /tmp/debug.log 2>/dev/null || echo 'No debug log'");
}
return 0;
}