MCPcopy Create free account
hub / github.com/MrNeRF/LichtFeld-Studio / TEST

Function TEST

tests/test_pytorch_install_proof.cpp:18–166  ·  view source on GitHub ↗

This test proves UV output streams correctly with a REAL large package Run with: ./build/tests/lichtfeld_tests --gtest_filter='*PyTorchInstall*'

Source from the content-addressed store, hash-verified

16// This test proves UV output streams correctly with a REAL large package
17// Run with: ./build/tests/lichtfeld_tests --gtest_filter='*PyTorchInstall*'
18TEST(PyTorchInstallProof, StreamingOutputWhileUIResponsive) {
19 auto& pm = PackageManager::instance();
20
21 if (!pm.is_uv_available()) {
22 GTEST_SKIP() << "UV not available";
23 }
24
25 ASSERT_TRUE(pm.ensure_venv()) << "Failed to create venv";
26
27 std::cout << "\n";
28 std::cout << "╔════════════════════════════════════════════════════════════════╗\n";
29 std::cout << "║ PROOF: Real PyTorch Installation with Streaming Output ║\n";
30 std::cout << "║ This demonstrates: ║\n";
31 std::cout << "║ 1) Output streams in real-time (not buffered until end) ║\n";
32 std::cout << "║ 2) UI remains responsive (60 FPS simulation) ║\n";
33 std::cout << "║ 3) Progress bars and download status are visible ║\n";
34 std::cout << "╚════════════════════════════════════════════════════════════════╝\n";
35 std::cout << std::endl;
36
37 auto start = steady_clock::now();
38 std::atomic<int> frame_count{0};
39 std::atomic<int> line_count{0};
40 std::atomic<bool> done{false};
41 std::atomic<bool> success{false};
42
43 // Track when each line arrives to prove streaming
44 std::vector<std::pair<long, std::string>> timestamped_output;
45 std::mutex output_mutex;
46
47 bool started = pm.install_torch_async(
48 "auto", "",
49 [&](const std::string& line, bool is_error, bool is_line_update) {
50 auto elapsed = duration_cast<milliseconds>(steady_clock::now() - start).count();
51 line_count++;
52
53 {
54 std::lock_guard<std::mutex> lock(output_mutex);
55 timestamped_output.emplace_back(elapsed, line);
56 }
57
58 // Format output nicely
59 if (is_line_update) {
60 std::cout << "\r\033[K"; // Clear line for progress updates
61 }
62 std::cout << "\033[36m[" << std::setw(6) << elapsed << "ms]\033[0m ";
63 if (is_error) {
64 std::cout << "\033[31m" << line << "\033[0m";
65 } else {
66 // Highlight download progress
67 if (line.find("Downloading") != std::string::npos ||
68 line.find("━") != std::string::npos) {
69 std::cout << "\033[33m" << line << "\033[0m";
70 } else if (line.find("Installed") != std::string::npos ||
71 line.find("+") != std::string::npos) {
72 std::cout << "\033[32m" << line << "\033[0m";
73 } else {
74 std::cout << line;
75 }

Callers

nothing calls this directly

Calls 11

instanceFunction · 0.85
is_uv_availableMethod · 0.80
install_torch_asyncMethod · 0.80
backMethod · 0.80
ensure_venvMethod · 0.45
countMethod · 0.45
findMethod · 0.45
pollMethod · 0.45
loadMethod · 0.45
sizeMethod · 0.45
frontMethod · 0.45

Tested by

no test coverage detected