MCPcopy Create free account
hub / github.com/apache/tvm / rpc_proxy_check

Function rpc_proxy_check

tests/python/contrib/test_rpc_proxy.py:28–64  ·  view source on GitHub ↗

This is a simple test function for RPC Proxy It is not included as pytests, because: - It depends on tornado - It relies on the fact that Proxy starts before client and server connects, which is often the case but not always User can directly run this script to verify correct

()

Source from the content-addressed store, hash-verified

26
27
28def rpc_proxy_check():
29 """This is a simple test function for RPC Proxy
30
31 It is not included as pytests, because:
32 - It depends on tornado
33 - It relies on the fact that Proxy starts before client and server connects,
34 which is often the case but not always
35
36 User can directly run this script to verify correctness.
37 """
38
39 try:
40 # pylint: disable=import-outside-toplevel
41 from tvm.rpc import proxy
42
43 web_port = 8888
44 prox = proxy.Proxy("127.0.0.1", web_port=web_port)
45
46 def check():
47 if not tvm.runtime.enabled("rpc"):
48 return
49
50 server = multiprocessing.Process(
51 target=proxy.websocket_proxy_server, args=(f"ws://localhost:{web_port}/ws", "x1")
52 )
53 # Need to make sure that the connection start after proxy comes up
54 time.sleep(0.1)
55 server.deamon = True
56 server.start()
57 client = rpc.connect(prox.host, prox.port, key="x1")
58 f1 = client.get_function("testing.echo")
59 assert f1(10) == 10
60 assert f1("xyz") == "xyz"
61
62 check()
63 except ImportError:
64 print("Skipping because tornado is not avaliable...")
65
66
67if __name__ == "__main__":

Callers 1

test_rpc_proxy.pyFile · 0.85

Calls 2

printFunction · 0.85
checkFunction · 0.70

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…