vuer 0.0.26rc3__py3-none-any.whl → 0.0.27__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.

Potentially problematic release.


This version of vuer might be problematic. Click here for more details.

Binary file
Binary file
vuer/base.py CHANGED
@@ -42,10 +42,12 @@ async def handle_file_request(request, root, filename=None):
42
42
  filename = request.match_info["filename"]
43
43
 
44
44
  filepath = Path(root) / filename
45
+ print(filepath)
45
46
 
46
47
  if not filepath.is_file():
47
48
  raise web.HTTPNotFound()
48
49
 
50
+ print("return the file")
49
51
  return web.FileResponse(filepath)
50
52
 
51
53
 
@@ -82,17 +84,21 @@ class Server:
82
84
  ws_handler = partial(
83
85
  websocket_handler, handler=handler, max_msg_size=self.WEBSOCKET_MAX_SIZE
84
86
  )
85
- self._route(path, ws_handler, method="GET")
87
+ self._route(path, ws_handler)
86
88
 
87
89
  @staticmethod
88
90
  def _add_task(fn: Coroutine, name=None):
89
91
  loop = asyncio.get_event_loop()
90
92
  loop.create_task(fn, name=name)
91
93
 
92
- def _static(self, path, root, filename=None):
93
- _fn = partial(handle_file_request, root=root, filename=None)
94
+ def _static(self, path, root):
95
+ _fn = partial(handle_file_request, root=root)
94
96
  self._route(f"{path}/{{filename:.*}}", _fn, method="GET")
95
97
 
98
+ def _static_file(self, path, root, filename=None):
99
+ _fn = partial(handle_file_request, root=root, filename=filename)
100
+ self._route(f"{path}", _fn, method="GET")
101
+
96
102
  def run(self):
97
103
  async def init_server():
98
104
  runner = web.AppRunner(self.app)
vuer/server.py CHANGED
@@ -6,14 +6,15 @@ from pathlib import Path
6
6
  from typing import cast, Callable, Coroutine, Dict
7
7
  from uuid import uuid4
8
8
 
9
- from aiohttp.web_request import Request
9
+ from aiohttp.hdrs import UPGRADE
10
+ from aiohttp.web_request import Request, BaseRequest
10
11
  from aiohttp.web_response import Response
11
12
  from aiohttp.web_ws import WebSocketResponse
12
13
  from msgpack import packb, unpackb
13
14
  from params_proto import Proto, PrefixProto
14
15
  from websockets import ConnectionClosedError
15
16
 
16
- from vuer.base import Server
17
+ from vuer.base import Server, handle_file_request, websocket_handler
17
18
  from vuer.events import (
18
19
  ClientEvent,
19
20
  NullEvent,
@@ -248,6 +249,9 @@ class VuerSession:
248
249
  yield from self.downlink_queue
249
250
 
250
251
 
252
+ DEFAULT_PORT = 8012
253
+
254
+
251
255
  class Vuer(PrefixProto, Server):
252
256
  """Vuer Server
253
257
 
@@ -282,16 +286,16 @@ class Vuer(PrefixProto, Server):
282
286
  """
283
287
 
284
288
  name = "vuer"
285
- uri = "ws://localhost:8012"
286
- # change to vuer.dash.ml
287
289
  domain = "https://vuer.ai"
288
- port = 8012
290
+ port = DEFAULT_PORT
289
291
  free_port = True
290
292
  static_root = "."
291
293
  queue_len = 100 # use a max length to avoid the memory from blowing up.
292
294
  cors = "https://vuer.ai,https://dash.ml,http://localhost:8000,http://127.0.0.1:8000,*"
293
295
  queries = Proto({}, help="query parameters to pass")
294
296
 
297
+ client_root = Path(__file__).parent / "client_build"
298
+
295
299
  device = "cuda"
296
300
 
297
301
  def _proxy(self, ws_id) -> "VuerSession":
@@ -432,11 +436,20 @@ class Vuer(PrefixProto, Server):
432
436
  Get the URL for the Tassa.
433
437
  :return: The URL for the Tassa.
434
438
  """
435
- if self.queries:
436
- query_str = "&".join([f"{k}={v}" for k, v in self.queries.items()])
437
- return f"{self.domain}?ws={self.uri}&" + query_str
439
+ if self.port != DEFAULT_PORT:
440
+ uri = f"ws://localhost:{self.port}"
441
+
442
+ if self.queries:
443
+ query_str = "&".join([f"{k}={v}" for k, v in self.queries.items()])
444
+ return f"{self.domain}?ws={uri}&" + query_str
445
+
446
+ return f"{self.domain}?ws={uri}"
447
+ else:
448
+ if self.queries:
449
+ query_str = "&".join([f"{k}={v}" for k, v in self.queries.items()])
450
+ return f"{self.domain}?" + query_str
438
451
 
439
- return f"{self.domain}?ws={self.uri}"
452
+ return f"{self.domain}"
440
453
 
441
454
  async def send(self, ws_id, event: ServerEvent = None, event_bytes=None):
442
455
  ws = self.ws[ws_id]
@@ -672,12 +685,31 @@ class Vuer(PrefixProto, Server):
672
685
 
673
686
  return ttl_handler()
674
687
 
688
+ async def socket_index(self, request: BaseRequest):
689
+ """This is the relay object for sending events to the server.
690
+
691
+ Todo: add API for specifying the websocket ID. Or just broadcast to all.
692
+ Todo: add type hint
693
+
694
+ Interface:
695
+ <uri>/relay?sid=<websocket_id>
696
+
697
+ :return:
698
+ - Status 200
699
+ - Status 400
700
+
701
+ """
702
+ headers = request.headers
703
+ if "websocket" != headers.get(UPGRADE, "").lower().strip():
704
+ return await handle_file_request(request, self.client_root, filename="index.html")
705
+ else:
706
+ return await websocket_handler(request, self.downlink)
707
+
675
708
  def run(self, kill=None, *args, **kwargs):
676
709
  import os
677
710
 
678
711
  # protocol, host, _ = self.uri.split(":")
679
712
  # port = int(_)
680
-
681
713
  if kill or self.free_port:
682
714
  import time
683
715
  from killport import kill_ports
@@ -685,12 +717,14 @@ class Vuer(PrefixProto, Server):
685
717
  kill_ports(ports=[self.port])
686
718
  time.sleep(0.01)
687
719
 
688
- self._socket("", self.downlink)
689
-
690
720
  # Serve the client build locally.
691
- self._static("/client", Path(__file__).parent / "client_build", filename="index.html")
692
- self._static("/assets", Path(__file__).parent / "client_build/assets")
693
- self._static("/hands", Path(__file__).parent / "client_build/hands")
721
+ # self._socket("", self.downlink)
722
+ # self._static_file("", Path(__file__).parent / "client_build", filename="index.html")
723
+
724
+ # use the same endpoint for websocket and file serving.
725
+ self._route("", self.socket_index, method="GET")
726
+ self._static("/assets", self.client_root / "assets")
727
+ self._static("/hands", self.client_root / "hands")
694
728
 
695
729
  # serve local files via /static endpoint
696
730
  self._static("/static", self.static_root)
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: vuer
3
- Version: 0.0.26rc3
3
+ Version: 0.0.27
4
4
  Home-page: https://github.com/geyang/vuer
5
5
  Author: Ge Yang<ge.ike.yang@gmail.com>
6
6
  Author-email: ge.ike.yang@gmail.com
@@ -1,16 +1,16 @@
1
1
  vuer/__init__.py,sha256=cP-Ua-bx3mq-3hsnFHAbiGwTnm25hm4wcXp1KhMKCJg,455
2
- vuer/base.py,sha256=IahJKIdN7CbubU5mC_YLXhpXyQVq2EX1vupApICo314,3154
2
+ vuer/base.py,sha256=9osGTVqkX4jDn2xwjaPFJ9PC9dYgLHqa-75lUYbPXpw,3338
3
3
  vuer/events.py,sha256=8AAzkfbm5jHkeMh17Z57n8YTxF4mheWC3Qbya4XkQSc,7291
4
4
  vuer/schemas.py,sha256=aZOocE02gO43SLLfeYSxxac0x38TmyTcfs_iFh5hsJ4,18152
5
5
  vuer/serdes.py,sha256=gD2iA9Yypu1QjocneOT3Nc0y6q_mdHn9zW1ko5j3I7c,2600
6
- vuer/server.py,sha256=JBArX9UCNGKHDjnzNHNW_DD1yPjN8p9l8KVP4DLbFSc,21230
6
+ vuer/server.py,sha256=mNbRAR59AyZsF01OEBVrN77IOzCKn02zu-a7yI9hyxU,22398
7
7
  vuer/types.py,sha256=N2KLa0fl6z8Jm6cJwZoD8Vqrins_AayG5BCGk1p3Eek,1279
8
8
  vuer/__pycache__/__init__.cpython-38.pyc,sha256=TZwyVHL5u0P7WrGMPA7crPL24QD4IGqK_Mc49i_AhrE,580
9
- vuer/__pycache__/base.cpython-38.pyc,sha256=xujTmsYu8GhoivoH0-2kbMK-ypye2xPuw2jXJ6wcLRQ,3844
9
+ vuer/__pycache__/base.cpython-38.pyc,sha256=5g9zSvLYkacji6nEgmytTtSsWmdwRfIUa4OiJACvDU0,4059
10
10
  vuer/__pycache__/events.cpython-38.pyc,sha256=zx3bXeJixqOyCFe2nA7qpq6jiCJ49kRaXO-xONGUyeQ,9616
11
11
  vuer/__pycache__/schemas.cpython-38.pyc,sha256=hvY9Aak8zE-zKcWiwuNe6DghOw9qH_zSe_FtkBOAPPk,23234
12
12
  vuer/__pycache__/serdes.cpython-38.pyc,sha256=KMxTjPEWuSGn2bqBAl5OLIDSCSoqfPDGfk3fvNnRDYA,2253
13
- vuer/__pycache__/server.cpython-38.pyc,sha256=Lgh3c7KWdlOZP2gAPS--QVE4XGz1hUGI8AtFNOCbtu0,19892
13
+ vuer/__pycache__/server.cpython-38.pyc,sha256=nNWECHle-JuKsMTveG7APYe0mjeRDj-qByhoBfQqojU,20493
14
14
  vuer/__pycache__/types.cpython-38.pyc,sha256=IhlXtkT-XWM0V1420FDuoqIYnpvRvekYVkGqEK7fAV8,1819
15
15
  vuer/addons/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
16
16
  vuer/addons/nerf_vuer/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
@@ -53,9 +53,9 @@ vuer/schemas/__pycache__/__init__.cpython-38.pyc,sha256=NRnVrpIDBKne93xOUY1-Wpav
53
53
  vuer/schemas/__pycache__/drei_components.cpython-38.pyc,sha256=g_ufcKxf-XKfZLdUV-HqKnjIrgxGWFv51aHLWQgH-ws,7712
54
54
  vuer/schemas/__pycache__/html_components.cpython-38.pyc,sha256=q0DMFwNkYbnaH1A8w3BowMiQAlmGpFWOOKsjLVE6CIk,8215
55
55
  vuer/schemas/__pycache__/scene_components.cpython-38.pyc,sha256=NjlInOQt1FVLHXNmmQ_bkRb-GZp2ffbBLwZxmb2bpWc,21917
56
- vuer-0.0.26rc3.dist-info/LICENSE,sha256=MGF-inVBUaGe2mEjqT0g6XsHIXwoNXgNHqD7Z1MzR0k,1063
57
- vuer-0.0.26rc3.dist-info/METADATA,sha256=2o4EVFimCQZonokNg3I2cRutY6zsNdT-E-oUMETqdiY,5342
58
- vuer-0.0.26rc3.dist-info/WHEEL,sha256=yQN5g4mg4AybRjkgi-9yy4iQEFibGQmlz78Pik5Or-A,92
59
- vuer-0.0.26rc3.dist-info/entry_points.txt,sha256=J_NM6fbpipmD9oP7cdxd1UyBR8mVEQVx0xjlE_56yss,41
60
- vuer-0.0.26rc3.dist-info/top_level.txt,sha256=ermmVkwvGFAK4gfSgDIwOmKpxwpqNt-oo7gVQQUSHok,5
61
- vuer-0.0.26rc3.dist-info/RECORD,,
56
+ vuer-0.0.27.dist-info/LICENSE,sha256=MGF-inVBUaGe2mEjqT0g6XsHIXwoNXgNHqD7Z1MzR0k,1063
57
+ vuer-0.0.27.dist-info/METADATA,sha256=OZJst5em2LrP9AuwFZmDtzP863P9p6KFTOmmPWlWvN8,5339
58
+ vuer-0.0.27.dist-info/WHEEL,sha256=yQN5g4mg4AybRjkgi-9yy4iQEFibGQmlz78Pik5Or-A,92
59
+ vuer-0.0.27.dist-info/entry_points.txt,sha256=J_NM6fbpipmD9oP7cdxd1UyBR8mVEQVx0xjlE_56yss,41
60
+ vuer-0.0.27.dist-info/top_level.txt,sha256=ermmVkwvGFAK4gfSgDIwOmKpxwpqNt-oo7gVQQUSHok,5
61
+ vuer-0.0.27.dist-info/RECORD,,