File size: 2,598 Bytes
ce4253e
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
76
77
78
79
80
81
import asyncio
import websockets
import json
import numpy as np

async def test_websocket():
    uri = "wss://8765-int35aifjdyxr46oxipjg-cf14c883.manusvm.computer"
    async with websockets.connect(uri) as websocket:
        print("Connected to websocket.")

        # Test VRAM write operation
        vram_data = np.random.rand(10, 10).tolist()
        vram_write_message = {
            "operation": "vram",
            "type": "write",
            "block_id": "test_block_1",
            "data": vram_data
        }
        await websocket.send(json.dumps(vram_write_message))
        response = await websocket.recv()
        print(f"VRAM write response: {response}")

        # Test VRAM read operation
        vram_read_message = {
            "operation": "vram",
            "type": "read",
            "block_id": "test_block_1"
        }
        await websocket.send(json.dumps(vram_read_message))
        response = await websocket.recv()
        print(f"VRAM read response: {response}")

        # Test state save operation
        state_data = {"gpu_temp": 65, "fan_speed": 2000}
        state_save_message = {
            "operation": "state",
            "type": "save",
            "component": "gpu_core",
            "state_id": "current_state",
            "data": state_data
        }
        await websocket.send(json.dumps(state_save_message))
        response = await websocket.recv()
        print(f"State save response: {response}")

        # Test state load operation
        state_load_message = {
            "operation": "state",
            "type": "load",
            "component": "gpu_core",
            "state_id": "current_state"
        }
        await websocket.send(json.dumps(state_load_message))
        response = await websocket.recv()
        print(f"State load response: {response}")

        # Test cache set operation
        cache_data = {"model_version": "v1.2", "accuracy": 0.98}
        cache_set_message = {
            "operation": "cache",
            "type": "set",
            "key": "model_info",
            "data": cache_data
        }
        await websocket.send(json.dumps(cache_set_message))
        response = await websocket.recv()
        print(f"Cache set response: {response}")

        # Test cache get operation
        cache_get_message = {
            "operation": "cache",
            "type": "get",
            "key": "model_info"
        }
        await websocket.send(json.dumps(cache_get_message))
        response = await websocket.recv()
        print(f"Cache get response: {response}")

asyncio.run(test_websocket())