Vuer API#
- class vuer.Vuer#
Bases:
PrefixProto,ServerA Vuer is a document that can be rendered in a browser.
- name = 'vuer'#
- uri = 'ws://localhost:8012'#
- domain = 'https://vuer.ai'#
- port = 8012#
- free_port = True#
- static_root = '.'#
- queue_len = 100#
- cors = 'https://vuer.ai,https://dash.ml,http://localhost:8000,http://127.0.0.1:8000,*'#
- queries = {}#
- device = 'cuda'#
- WEBSOCKET_MAX_SIZE = 268435456#
- host = 'localhost'#
- class vuer.VuerSession#
Bases:
object- async grab_render(ttl=2.0, **kwargs) ClientEvent#
Grab a render from the client.
- Parameters:
quality – The quality of the render. 0.0 - 1.0
subsample – The subsample of the render.
ttl – The time to live for the handler. If the handler is not called within the time it gets removed from the handler list.
- Return type:
- property set: At#
Used exclusively to set the scene.
the @SET operator is responsible for setting the root node of the scene.
- Examples:
proxy @ Set(Scene(children=[…]))
or
app.set @ Scene(children=[…])
- property update: At#
Used to update existing elements. NOOP if an element does not exist.
Supports passing in a list of elements. (Thank God I implemented this… so handy! - Ge)
Example Usage:
app.update @ [element1, element2, ...]
- property add: At#
Used to add elements to a specific parent.
Requires a parentKey, or treats the Scene root node as the default parent.
Example Usage:
app.add(element1, element2, ..., to=parentKey.)
or using the Scene root node as the default parent:
app.add @ element1
- property upsert: At#
Upsert elements to a specific parent.
Requires a parentKey, or treats the Scene root node as the default parent.
Example Usage:
app.upsert(element1, element2, ..., to=parentKey.)
or using the Scene root node as the default parent:
app.upsert @ element1
- property remove: At#
Remove elements by keys.
Example Usage:
app.remove @ ["key1", "key2", ...]
or a single key:
app.remove @ "key1"
- popleft()#
- pop()#
- clear()#
clears all client messages
- stream()#
vuer.base module#
- class vuer.base.Coroutine#
Bases:
Awaitable- close()#
Raise GeneratorExit inside coroutine.
- abstract send(value)#
Send a value into the coroutine. Return next yielded value or raise StopIteration.
- abstract throw(typ, val=None, tb=None)#
Raise an exception in the coroutine. Return next yielded value or raise StopIteration.
- exception vuer.base.CancelledError#
Bases:
ErrorThe Future was cancelled.
- class vuer.base.partial#
Bases:
objectpartial(func, *args, **keywords) - new function with partial application of the given arguments and keywords.
- __new__(**kwargs)#
- args#
tuple of arguments to future partial calls
- func#
function object to use in future partial calls
- keywords#
dictionary of keyword arguments to future partial calls
- class vuer.base.Path#
Bases:
PurePathPurePath subclass that can make system calls.
Path represents a filesystem path but unlike PurePath, also offers methods to do system calls on path objects. Depending on your system, instantiating a Path will return either a PosixPath or a WindowsPath object. You can also instantiate a PosixPath or WindowsPath directly, but cannot instantiate a WindowsPath on a POSIX system or vice versa.
- static __new__(cls, *args, **kwargs)#
Construct a PurePath from one or several strings and or existing PurePath objects. The strings and path objects are combined so as to yield a canonicalized path, which is incorporated into the new PurePath object.
- classmethod cwd()#
Return a new path pointing to the current working directory (as returned by os.getcwd()).
- classmethod home()#
Return a new path pointing to the user’s home directory (as returned by os.path.expanduser(‘~’)).
- samefile(other_path)#
Return whether other_path is the same or not as this file (as returned by os.path.samefile()).
- iterdir()#
Iterate over the files in this directory. Does not yield any result for the special paths ‘.’ and ‘..’.
- glob(pattern)#
Iterate over this subtree and yield all existing files (of any kind, including directories) matching the given relative pattern.
- rglob(pattern)#
Recursively yield all existing files (of any kind, including directories) matching the given relative pattern, anywhere in this subtree.
- absolute()#
Return an absolute version of this path. This function works even if the path doesn’t point to anything.
No normalization is done, i.e. all ‘.’ and ‘..’ will be kept along. Use resolve() to get the canonical path to a file.
- resolve(strict=False)#
Make the path absolute, resolving all symlinks on the way and also normalizing it (for example turning slashes into backslashes under Windows).
- stat()#
Return the result of the stat() system call on this path, like os.stat() does.
- owner()#
Return the login name of the file owner.
- group()#
Return the group name of the file gid.
- open(mode='r', buffering=-1, encoding=None, errors=None, newline=None)#
Open the file pointed by this path and return a file object, as the built-in open() function does.
- read_bytes()#
Open the file in bytes mode, read it, and close the file.
- read_text(encoding=None, errors=None)#
Open the file in text mode, read it, and close the file.
- write_bytes(data)#
Open the file in bytes mode, write to it, and close the file.
- write_text(data, encoding=None, errors=None)#
Open the file in text mode, write to it, and close the file.
- touch(mode=438, exist_ok=True)#
Create this file with the given access mode, if it doesn’t exist.
- mkdir(mode=511, parents=False, exist_ok=False)#
Create a new directory at this given path.
- chmod(mode)#
Change the permissions of the path, like os.chmod().
- lchmod(mode)#
Like chmod(), except if the path points to a symlink, the symlink’s permissions are changed, rather than its target’s.
- unlink(missing_ok=False)#
Remove this file or link. If the path is a directory, use rmdir() instead.
- rmdir()#
Remove this directory. The directory must be empty.
- lstat()#
Like stat(), except if the path points to a symlink, the symlink’s status information is returned, rather than its target’s.
- rename(target)#
Rename this path to the target path.
The target path may be absolute or relative. Relative paths are interpreted relative to the current working directory, not the directory of the Path object.
Returns the new Path instance pointing to the target path.
- replace(target)#
Rename this path to the target path, overwriting if that path exists.
The target path may be absolute or relative. Relative paths are interpreted relative to the current working directory, not the directory of the Path object.
Returns the new Path instance pointing to the target path.
- symlink_to(target, target_is_directory=False)#
Make this path a symlink pointing to the target path. Note the order of arguments (link, target) is the reverse of os.symlink.
- link_to(target)#
Make the target path a hard link pointing to this path.
Note this function does not make this path a hard link to target, despite the implication of the function and argument names. The order of arguments (target, link) is the reverse of Path.symlink_to, but matches that of os.link.
- exists()#
Whether this path exists.
- is_dir()#
Whether this path is a directory.
- is_file()#
Whether this path is a regular file (also True for symlinks pointing to regular files).
- is_mount()#
Check if this path is a POSIX mount point
- is_symlink()#
Whether this path is a symbolic link.
- is_block_device()#
Whether this path is a block device.
- is_char_device()#
Whether this path is a character device.
- is_fifo()#
Whether this path is a FIFO.
- is_socket()#
Whether this path is a socket.
- expanduser()#
Return a new path with expanded ~ and ~user constructs (as returned by os.path.expanduser)
- class vuer.base.Proto#
Bases:
SimpleNamespace- default = None#
- help = None#
- dtype = None#
- property value#
- async vuer.base.default_handler(request, ws)#
- async vuer.base.websocket_handler(request, handler, **ws_kwargs)#
- async vuer.base.handle_file_request(request, root)#
- class vuer.base.Server#
Bases:
object- host = Proto(default='localhost', dtype=<class 'str'>, help=":str 'localhost' ", metavar='\x08')#
- cors = Proto(default='*', dtype=<class 'str'>, help=":str '*' Enable CORS", metavar='\x08')#
- port = Proto(default=8012, dtype=<class 'int'>, help=':int 8012 ', metavar='\x08')#
- WEBSOCKET_MAX_SIZE = 268435456#
- run()#
vuer.events module#
- vuer.events.uuid4()#
Generate a random UUID.
- class vuer.events.Element#
Bases:
objectBase class for all elements
- tag: str = 'div'#
- serialize()#
Serialize the element to a dictionary for sending over the websocket. :return: Dictionary representing the element.
- class vuer.events.Scene#
Bases:
BlockElement- tag: str = 'Scene'#
- serialize()#
Serialize the element to a dictionary for sending over the websocket. :return: Dictionary representing the element.
- vuer.events.serializer(data)#
- class vuer.events.Event#
Bases:
objectAn event is a message sent from the server to the client.
- class vuer.events.InitEvent#
Bases:
ClientEvent
- class vuer.events.NullEvent#
Bases:
ClientEvent
- class vuer.events.ServerEvent#
Bases:
Event- serialize()#
Serialize the event to a dictionary for sending over the websocket. :return: A dictionary representing the event.
- class vuer.events.Noop#
Bases:
ServerEvent- etype = 'NOOP'#
- class vuer.events.Set#
Bases:
ServerEventSet Operation (Server Event).
SET Operator is used exclusively to set the root Scene node. Throws an error (on the client side) if the data is not a Scene object.
- etype = 'SET'#
The Event Type.
- class vuer.events.Update#
Bases:
ServerEventUPDATE Operator is used to update a specific node in the scene graph.
Use “$delete” value for elements you want to remove. Or “$strict” mode to copy the element verbatim.
- Example:
app.update @ { “key”: “my_key”, “value”: “$delete” }
app.update({ “key”: “my_key”, “value”: “$delete” }, strict=True)
app.update @ [ { “key”: “my_key”, “value”: “$delete” }, … ]
app.update({ “key”: “my_key”, “value”: “$delete” }, …, strict=True)
- etype = 'UPDATE'#
- serialize()#
Serialize the event to a dictionary for sending over the websocket. :return: A dictionary representing the event.
- class vuer.events.Add#
Bases:
ServerEventADD Operator is used to insert new nodes to the scene graph. By default it inserts into the root node, but you can specify a parent node to insert into via the to argument.
Note: only supports a single parent key right now.
- Example:
app.add @ Element(…)
app.add @ [ Element(…), Element(…), … ]
app.add(Element, to=”my_parent_key”)
app.add([Element, …], to=”my_parent_key”)
- etype = 'ADD'#
- serialize()#
Serialize the event to a dictionary for sending over the websocket. :return: A dictionary representing the event.
- class vuer.events.Upsert#
Bases:
ServerEventUPSERT Operator is used to update nodes to new values, when then they do not exist, insert new ones to the scene graph.
Note: only supports a single parent key right now.
- Example:
app.upsert @ Element(…)
app.upsert @ [ Element(…), Element(…), … ]
app.upsert(Element, to=”my_parent_key”)
app.upsert([Element, …], to=”my_parent_key”)
- etype = 'UPSERT'#
- serialize()#
Serialize the event to a dictionary for sending over the websocket. :return: A dictionary representing the event.
- class vuer.events.Remove#
Bases:
ServerEventAn Update ServerEvent is sent to the client when the server wants to update the client’s state. It appends the data sent in the Update ServerEvent to the client’s current state.
- etype = 'REMOVE'#
- class vuer.events.Frame#
Bases:
ServerEventA higher-level ServerEvent that wraps other ServerEvents
- ServerEvent: ServerEvent#
- etype = 'FRAME'#
- class vuer.events.End#
Bases:
ServerEventA higher-level ServerEvent that wraps other ServerEvents
- etype = 'TERMINATE'#
- class vuer.events.ServerRPC#
Bases:
ServerEvent- etype = 'RPC'#
- rtype = 'RPC_RESPONSE@{uuid}'#
- uuid: str#
vuer.schemas module#
- class vuer.schemas.Element#
Bases:
objectBase class for all elements
- tag: str = 'div'#
- serialize()#
Serialize the element to a dictionary for sending over the websocket. :return: Dictionary representing the element.
- class vuer.schemas.BlockElement#
Bases:
Element- serialize()#
Serialize the element to a dictionary for sending over the websocket. :return: Dictionary representing the element.
- class vuer.schemas.AutoScroll#
Bases:
BlockElement- tag: str = 'AutoScroll'#
- class vuer.schemas.Markdown#
Bases:
BlockElement- tag: str = 'Markdown'#
- class vuer.schemas.Page#
Bases:
BlockElementA Page is an element that contains other elements. It is represented by a div element in the DOM.
- tag: str = 'article'#
- class vuer.schemas.div#
Bases:
BlockElement- tag: str = 'Div'#
- class vuer.schemas.InputBox#
Bases:
ElementAn InputBox is an element that allows the user to input text. It is represented by an input element in the DOM.
- tag: str = 'Input'#
- class vuer.schemas.Header1#
Bases:
BlockElementA Text element is an element that displays text. It is represented by a text, or p element in the DOM.
- tag: str = 'h1'#
- class vuer.schemas.Paragraph#
Bases:
BlockElementA Text element is an element that displays text. It is represented by a text, or p element in the DOM.
- tag: str = 'p'#
- class vuer.schemas.Text#
Bases:
ElementA Text element is an element that displays text. It is represented by a text, or p element in the DOM.
- tag: str = 'Text'#
- class vuer.schemas.Button#
Bases:
ElementA Button element is an element that allows the user to click on it. It is represented by a button element in the DOM.
- tag: str = 'Button'#
- class vuer.schemas.Slider#
Bases:
ElementA Slider element is an element that allows the user to slide a value. It is represented by a slider element in the DOM.
- tag: str = 'Slider'#
- class vuer.schemas.Image#
Bases:
ElementAn Image element is an element that displays an image. It is represented by an img element in the DOM.
- tag: str = 'Img'#
- class vuer.schemas.ImageUpload#
Bases:
ElementA ImageUpload element is an element that allows the user to upload a file. It is represented by a file upload element in the DOM.
- tag: str = 'ImageUpload'#
- class vuer.schemas.Scene#
Bases:
BlockElement- tag: str = 'Scene'#
- serialize()#
Serialize the element to a dictionary for sending over the websocket. :return: Dictionary representing the element.
- class vuer.schemas.SceneElement#
Bases:
BlockElement
- class vuer.schemas.Frustum#
Bases:
SceneElement- tag: str = 'Frustum'#
- class vuer.schemas.CameraHelper#
Bases:
SceneElement- tag: str = 'CameraHelper'#
- class vuer.schemas.group#
Bases:
SceneElement- tag: str = 'group'#
- children = []#
- class vuer.schemas.mesh#
Bases:
SceneElement- tag: str = 'mesh'#
- children = []#
- class vuer.schemas.TriMesh#
Bases:
SceneElement- tag: str = 'TriMesh'#
- children = []#
- vertices: ndarray[Any, dtype[float16]] = None#
- faces: ndarray[Any, dtype[uint32]] = None#
- colors: ndarray[Any, dtype[uint8]] = None#
- class vuer.schemas.PointCloud#
Bases:
SceneElementPointCould element, highly optimized for payload size and speed.
- Parameters:
vertices (NDArray[np.float16]) – An optional numpy array of shape (N, 3) containing the vertices of the pointcloud.
colors – An optional numpy array of shape (N, 3) containing the colors of the point cloud.
size (float) – An optional float that sets the size of the points.
key (str) – str An optional string that sets the key of the element.
Usage:
sess.upsert @ PointCloud( vertices=np.random.rand(1000, 3), colors=np.random.rand(1000, 3), size=0.01, key="pointcloud", )
- tag: str = 'PointCloud'#
- vertices: ndarray[Any, dtype[float16]] = None#
An optional numpy array of shape (N, 3) containing the vertices of the point cloud.
- colors: ndarray[Any, dtype[uint8]] = None#
An optional numpy array of shape (N, 3) containing the colors of the point cloud.
- children = []#
- class vuer.schemas.Box#
Bases:
SceneElement- tag: str = 'Box'#
- class vuer.schemas.Capsule#
Bases:
SceneElement- tag: str = 'Capsule'#
- class vuer.schemas.Cone#
Bases:
SceneElement- tag: str = 'Cone'#
- class vuer.schemas.Circle#
Bases:
SceneElement- tag: str = 'Circle'#
- class vuer.schemas.Cylinder#
Bases:
SceneElement- tag: str = 'Cylinder'#
- class vuer.schemas.Dodecahedron#
Bases:
SceneElement- tag: str = 'Dodecahedron'#
- class vuer.schemas.Edges#
Bases:
SceneElement- tag: str = 'Edges'#
- class vuer.schemas.Extrude#
Bases:
SceneElement- tag: str = 'Extrude'#
- class vuer.schemas.Icosahedron#
Bases:
SceneElement- tag: str = 'Icosahedron'#
- class vuer.schemas.Lathe#
Bases:
SceneElement- tag: str = 'Lathe'#
- class vuer.schemas.Octahedron#
Bases:
SceneElement- tag: str = 'Octahedron'#
- class vuer.schemas.Plane#
Bases:
SceneElement- tag: str = 'Plane'#
- class vuer.schemas.Polyhedron#
Bases:
SceneElement- tag: str = 'Polyhedron'#
- class vuer.schemas.Ring#
Bases:
SceneElement- tag: str = 'Ring'#
- class vuer.schemas.Shape#
Bases:
SceneElement- tag: str = 'Shape'#
- class vuer.schemas.Sphere#
Bases:
SceneElement- tag: str = 'Sphere'#
- class vuer.schemas.Tetrahedron#
Bases:
SceneElement- tag: str = 'Tetrahedron'#
- class vuer.schemas.Torus#
Bases:
SceneElement- tag: str = 'Torus'#
- class vuer.schemas.TorusKnot#
Bases:
SceneElement- tag: str = 'TorusKnot'#
- class vuer.schemas.Tube#
Bases:
SceneElement- tag: str = 'Tube'#
- class vuer.schemas.Fog#
Bases:
SceneElementFog is a scene element that adds fog to the scene. This can be used to approximate depth.
- Arguments:
args: color, near, far
- Example Usage:
Fog(args=[0xcccccc, 10, 15])
- tag: str = 'fog'#
- class vuer.schemas.Wireframe#
Bases:
SceneElement- tag: str = 'Wireframe'#
- class vuer.schemas.Splat#
Bases:
SceneElement- tag: str = 'Splat'#
- class vuer.schemas.LumaSplats#
Bases:
SceneElement- tag: str = 'Splats'#
- class vuer.schemas.Pcd#
Bases:
SceneElement- tag: str = 'Pcd'#
- class vuer.schemas.CameraView#
Bases:
SceneElement- tag: str = 'CameraView'#
- class vuer.schemas.SceneBackground#
Bases:
Image,SceneElementSets the background of the scene to a static image. Does not work well with high frame rates. For displaying movies, use the ImageBackground element.
- tag: str = 'SceneBackground'#
- class vuer.schemas.ImageBackground#
Bases:
Image,SceneElementSets the background of the scene to an image, Supports high frame rates.
We use a plane that is always facing the camera to display the image.
- tag: str = 'ImageBackground'#
- class vuer.schemas.Gamepads#
Bases:
SceneElement- tag: str = 'Gamepads'#
- class vuer.schemas.DirectionalLight#
Bases:
SceneElement- tag: str = 'DirectionalLight'#
- class vuer.schemas.PointLight#
Bases:
SceneElement- tag: str = 'PointLight'#
- class vuer.schemas.SpotLight#
Bases:
SceneElement- tag: str = 'SpotLight'#
- class vuer.schemas.AmbientLight#
Bases:
SceneElement- tag: str = 'AmbientLight'#
- class vuer.schemas.Html#
Bases:
SceneElementas=’div’ // Wrapping element (default: ‘div’)
wrapperClass // The className of the wrapping element (default: undefined) prepend // Project content behind the canvas (default: false) center // Adds a -50%/-50% css transform (default: false) [ignored in transform mode] fullscreen // Aligns to the upper-left corner, fills the screen (default:false) [ignored in transform mode] distanceFactor={10} // If set (default: undefined), children will be scaled by this factor, and also by distance to a PerspectiveCamera / zoom by a OrthographicCamera. zIndexRange={[100, 0]} // Z-order range (default=[16777271, 0]) portal={domnodeRef} // Reference to target container (default=undefined) transform // If true, applies matrix3d transformations (default=false) sprite // Renders as sprite, but only in transform mode (default=false) calculatePosition={(el: Object3D, camera: Camera, size: { width: number; height: number }) => number[]} // Override default positioning function. (default=undefined) [ignored in transform mode] occlude={[ref]} // Can be true or a Ref<Object3D>[], true occludes the entire scene (default: undefined) onOcclude={(visible) => null} // Callback when the visibility changes (default: undefined) {…groupProps} // All THREE.Group props are valid {…divProps} // All HTMLDivElement props are valid
- tag: str = 'Html'#
- class vuer.schemas.Pivot#
Bases:
SceneElement- tag: str = 'Pivot'#
- class vuer.schemas.Movable#
Bases:
SceneElement- tag: str = 'Movable'#
- class vuer.schemas.Obj#
Bases:
SceneElement- tag: str = 'Obj'#
- class vuer.schemas.CoordsMarker#
Bases:
SceneElement- tag: str = 'CoordsMarker'#
- class vuer.schemas.Ply#
Bases:
SceneElement- tag: str = 'Ply'#
- class vuer.schemas.Glb#
Bases:
SceneElement- tag: str = 'Glb'#
- class vuer.schemas.Urdf#
Bases:
SceneElement- tag: str = 'Urdf'#
- class vuer.schemas.Gripper#
Bases:
SceneElement- tag: str = 'Gripper'#
- class vuer.schemas.SkeletalGripper#
Bases:
SceneElement- tag: str = 'SkeletalGripper'#
- class vuer.schemas.Grid#
Bases:
SceneElement- tag: str = 'Grid'#
- class vuer.schemas.GrabRender#
Bases:
SceneElement- tag: str = 'GrabRender'#
- key = 'DEFAULT'#
We do not want the client to set keys automatically since GrabRender is usually used a singleton component as default.
- class vuer.schemas.TimelineControls#
Bases:
SceneElement- tag: str = 'TimelineControls'#
- class vuer.schemas.PointerControls#
Bases:
SceneElement- tag: str = 'PointerControls'#
- class vuer.schemas.DefaultScene#
Bases:
SceneDefault Scene that includes a basic setup of ambient lights.
- Parameters:
children (SceneElement, ...) – list of children elements to be rendered in the scene.
rawChildren – list of children elements to be rendered in the scene.
htmlChildren – list of children elements to be rendered in the scene.
bgChildren – list of children elements to be rendered in the scene.
show_helper – list of children elements to be rendered in the scene.
startStep – list of children elements to be rendered in the scene.
endStep – list of children elements to be rendered in the scene.
up – list of children elements to be rendered in the scene.
kwargs – list of children elements to be rendered in the scene.
Example Usage:
DefaultScene( # Ambient Light does not have helper because it is ambient. AmbientLight(intensity=1.0, key="default_ambient_light"), DirectionalLight( intensity=1, key="default_directional_light", helper=show_helper ), *children, rawChildren=rawChildren, htmlChildren=htmlChildren, bgChildren=[ GrabRender(), *[ # we use a key here so that we can replace the timeline controls via update TimelineControls(start=startStep, end=endStep, key="timeline") if endStep else None, ], PointerControls(), Grid(), *bgChildren, ], up=up, **kwargs, )
vuer.serdes module#
- class vuer.serdes.BytesIO#
Bases:
_BufferedIOBaseBuffered I/O implementation using an in-memory bytes buffer.
- __new__(**kwargs)#
- close()#
Disable all I/O operations.
- closed#
True if the file is closed.
- flush()#
Does nothing.
- getbuffer()#
Get a read-write view over the contents of the BytesIO object.
- getvalue()#
Retrieve the entire contents of the BytesIO object.
- isatty()#
Always returns False.
BytesIO objects are not connected to a TTY-like device.
- read(size=-1, /)#
Read at most size bytes, returned as a bytes object.
If the size argument is negative, read until EOF is reached. Return an empty bytes object at EOF.
- read1(size=-1, /)#
Read at most size bytes, returned as a bytes object.
If the size argument is negative or omitted, read until EOF is reached. Return an empty bytes object at EOF.
- readable()#
Returns True if the IO object can be read.
- readinto(buffer, /)#
Read bytes into buffer.
Returns number of bytes read (0 for EOF), or None if the object is set not to block and has no data to read.
- readline(size=-1, /)#
Next line from the file, as a bytes object.
Retain newline. A non-negative size argument limits the maximum number of bytes to return (an incomplete line may be returned then). Return an empty bytes object at EOF.
- readlines(size=None, /)#
List of bytes objects, each a line from the file.
Call readline() repeatedly and return a list of the lines so read. The optional size argument, if given, is an approximate bound on the total number of bytes in the lines returned.
- seek(pos, whence=0, /)#
Change stream position.
- Seek to byte offset pos relative to position indicated by whence:
0 Start of stream (the default). pos should be >= 0; 1 Current position - pos may be negative; 2 End of stream - pos usually negative.
Returns the new absolute position.
- seekable()#
Returns True if the IO object can be seeked.
- tell()#
Current file position, an integer.
- truncate(size=None, /)#
Truncate the file to at most size bytes.
Size defaults to the current file position, as returned by tell(). The current file position is unchanged. Returns the new size.
- writable()#
Returns True if the IO object can be written.
- write(b, /)#
Write bytes to file.
Return the number of bytes written.
- writelines(lines, /)#
Write lines to the file.
Note that newlines are not added. lines can be any iterable object producing bytes-like objects. This is equivalent to calling write() for each element.
- vuer.serdes.serializer(data)#
- vuer.serdes.jpg(image, quality: int = 90)#
base64 encode the image into a string, using JPEG encoding
Does not support transparency.
- Parameters:
quality (int) –
- vuer.serdes.png(image)#
base64 encode the image into a string, using PNG encoding
- vuer.serdes.b64jpg(image, quality: int = 90)#
base64 encode the image into a string, using JPEG encoding
Does not support transparency.
- Parameters:
quality (int) –
- vuer.serdes.b64png(image)#
base64 encode the image into a string, using PNG encoding
vuer.server module#
- async vuer.server.sleep(delay, result=None, *, loop=None)#
Coroutine that completes after a given time (in seconds).
- class vuer.server.deque#
Bases:
objectdeque([iterable[, maxlen]]) –> deque object
A list-like sequence optimized for data accesses near its endpoints.
- __new__(**kwargs)#
- append()#
Add an element to the right side of the deque.
- appendleft()#
Add an element to the left side of the deque.
- clear()#
Remove all elements from the deque.
- copy()#
Return a shallow copy of a deque.
- count(value) integer -- return number of occurrences of value#
- extend()#
Extend the right side of the deque with elements from the iterable
- extendleft()#
Extend the left side of the deque with elements from the iterable
- index(value[, start[, stop]]) integer -- return first index of value.#
Raises ValueError if the value is not present.
- insert()#
D.insert(index, object) – insert object before index
- maxlen#
maximum size of a deque or None if unbounded
- pop()#
Remove and return the rightmost element.
- popleft()#
Remove and return the leftmost element.
- remove()#
D.remove(value) – remove first occurrence of value.
- reverse()#
D.reverse() – reverse IN PLACE
- rotate()#
Rotate the deque n steps to the right (default n=1). If n is negative, rotates left.
- class vuer.server.defaultdict#
Bases:
dictdefaultdict(default_factory[, …]) –> dict with default factory
The default factory is called without arguments to produce a new value when a key is not present, in __getitem__ only. A defaultdict compares equal to a dict with the same items. All remaining arguments are treated the same as if they were passed to the dict constructor, including keyword arguments.
- copy() a shallow copy of D.#
- default_factory#
Factory for default value called by __missing__().
- class vuer.server.partial#
Bases:
objectpartial(func, *args, **keywords) - new function with partial application of the given arguments and keywords.
- __new__(**kwargs)#
- args#
tuple of arguments to future partial calls
- func#
function object to use in future partial calls
- keywords#
dictionary of keyword arguments to future partial calls
- vuer.server.cast(typ, val)#
Cast a value to a type.
This returns the value unchanged. To the type checker this signals that the return value has the designated type, but at runtime we intentionally don’t check anything (we want this to be as fast as possible).
- vuer.server.uuid4()#
Generate a random UUID.
- vuer.server.packb(o, **kwargs)#
Pack object o and return packed bytes
See
Packerfor options.
- vuer.server.unpackb(packed, *, object_hook=None, list_hook=None, bool use_list=True, bool raw=False, int timestamp=0, bool strict_map_key=True, unicode_errors=None, object_pairs_hook=None, ext_hook=ExtType, Py_ssize_t max_str_len=-1, Py_ssize_t max_bin_len=-1, Py_ssize_t max_array_len=-1, Py_ssize_t max_map_len=-1, Py_ssize_t max_ext_len=-1)#
Unpack packed_bytes to object. Returns an unpacked object.
Raises
ExtraDatawhen packed contains extra bytes. RaisesValueErrorwhen packed is incomplete. RaisesFormatErrorwhen packed is not valid msgpack. RaisesStackErrorwhen packed contains too nested. Other exceptions can be raised during unpacking.See
Unpackerfor options.max_xxx_len options are configured automatically from
len(packed).
- class vuer.server.Proto#
Bases:
SimpleNamespace- default = None#
- help = None#
- dtype = None#
- property value#
- class vuer.server.PrefixProto#
Bases:
ParamsProtoA ParamsProto class with prefix set to True.
Since we override the __init_subclass__ method, the returned classes instance is still a ParamsProto class. NOT a PrefixProto class.
- class vuer.server.Server#
Bases:
object- host = Proto(default='localhost', dtype=<class 'str'>, help=":str 'localhost' ", metavar='\x08')#
- cors = Proto(default='*', dtype=<class 'str'>, help=":str '*' Enable CORS", metavar='\x08')#
- port = Proto(default=8012, dtype=<class 'int'>, help=':int 8012 ', metavar='\x08')#
- WEBSOCKET_MAX_SIZE = 268435456#
- run()#
- class vuer.server.NullEvent#
Bases:
ClientEvent
- class vuer.server.ServerEvent#
Bases:
Event- serialize()#
Serialize the event to a dictionary for sending over the websocket. :return: A dictionary representing the event.
- class vuer.server.Frame#
Bases:
ServerEventA higher-level ServerEvent that wraps other ServerEvents
- ServerEvent: ServerEvent#
- etype = 'FRAME'#
- class vuer.server.Set#
Bases:
ServerEventSet Operation (Server Event).
SET Operator is used exclusively to set the root Scene node. Throws an error (on the client side) if the data is not a Scene object.
- etype = 'SET'#
The Event Type.
- class vuer.server.Update#
Bases:
ServerEventUPDATE Operator is used to update a specific node in the scene graph.
Use “$delete” value for elements you want to remove. Or “$strict” mode to copy the element verbatim.
- Example:
app.update @ { “key”: “my_key”, “value”: “$delete” }
app.update({ “key”: “my_key”, “value”: “$delete” }, strict=True)
app.update @ [ { “key”: “my_key”, “value”: “$delete” }, … ]
app.update({ “key”: “my_key”, “value”: “$delete” }, …, strict=True)
- etype = 'UPDATE'#
- serialize()#
Serialize the event to a dictionary for sending over the websocket. :return: A dictionary representing the event.
- class vuer.server.Remove#
Bases:
ServerEventAn Update ServerEvent is sent to the client when the server wants to update the client’s state. It appends the data sent in the Update ServerEvent to the client’s current state.
- etype = 'REMOVE'#
- class vuer.server.Add#
Bases:
ServerEventADD Operator is used to insert new nodes to the scene graph. By default it inserts into the root node, but you can specify a parent node to insert into via the to argument.
Note: only supports a single parent key right now.
- Example:
app.add @ Element(…)
app.add @ [ Element(…), Element(…), … ]
app.add(Element, to=”my_parent_key”)
app.add([Element, …], to=”my_parent_key”)
- etype = 'ADD'#
- serialize()#
Serialize the event to a dictionary for sending over the websocket. :return: A dictionary representing the event.
- class vuer.server.ServerRPC#
Bases:
ServerEvent- etype = 'RPC'#
- rtype = 'RPC_RESPONSE@{uuid}'#
- uuid: str#
- class vuer.server.GrabRender#
Bases:
ServerRPCA higher-level ServerEvent that wraps other ServerEvents
- etype = 'GRAB_RENDER'#
- uuid: str#
- class vuer.server.Upsert#
Bases:
ServerEventUPSERT Operator is used to update nodes to new values, when then they do not exist, insert new ones to the scene graph.
Note: only supports a single parent key right now.
- Example:
app.upsert @ Element(…)
app.upsert @ [ Element(…), Element(…), … ]
app.upsert(Element, to=”my_parent_key”)
app.upsert([Element, …], to=”my_parent_key”)
- etype = 'UPSERT'#
- serialize()#
Serialize the event to a dictionary for sending over the websocket. :return: A dictionary representing the event.
- class vuer.server.Page#
Bases:
BlockElementA Page is an element that contains other elements. It is represented by a div element in the DOM.
- tag: str = 'article'#
- class vuer.server.At#
Bases:
objectProxy Object for using the @ notation. Also supports being called direction, which supports more complex arguments.
- class vuer.server.VuerSession#
Bases:
object- async grab_render(ttl=2.0, **kwargs) ClientEvent#
Grab a render from the client.
- Parameters:
quality – The quality of the render. 0.0 - 1.0
subsample – The subsample of the render.
ttl – The time to live for the handler. If the handler is not called within the time it gets removed from the handler list.
- Return type:
- property set: At#
Used exclusively to set the scene.
the @SET operator is responsible for setting the root node of the scene.
- Examples:
proxy @ Set(Scene(children=[…]))
or
app.set @ Scene(children=[…])
- property update: At#
Used to update existing elements. NOOP if an element does not exist.
Supports passing in a list of elements. (Thank God I implemented this… so handy! - Ge)
Example Usage:
app.update @ [element1, element2, ...]
- property add: At#
Used to add elements to a specific parent.
Requires a parentKey, or treats the Scene root node as the default parent.
Example Usage:
app.add(element1, element2, ..., to=parentKey.)
or using the Scene root node as the default parent:
app.add @ element1
- property upsert: At#
Upsert elements to a specific parent.
Requires a parentKey, or treats the Scene root node as the default parent.
Example Usage:
app.upsert(element1, element2, ..., to=parentKey.)
or using the Scene root node as the default parent:
app.upsert @ element1
- property remove: At#
Remove elements by keys.
Example Usage:
app.remove @ ["key1", "key2", ...]
or a single key:
app.remove @ "key1"
- popleft()#
- pop()#
- clear()#
clears all client messages
- stream()#
- class vuer.server.Vuer#
Bases:
PrefixProto,ServerA Vuer is a document that can be rendered in a browser.
- name = 'vuer'#
- uri = 'ws://localhost:8012'#
- domain = 'https://vuer.ai'#
- port = 8012#
- free_port = True#
- static_root = '.'#
- queue_len = 100#
- cors = 'https://vuer.ai,https://dash.ml,http://localhost:8000,http://127.0.0.1:8000,*'#
- queries = {}#
- device = 'cuda'#
- WEBSOCKET_MAX_SIZE = 268435456#
- host = 'localhost'#
vuer.types module#
- vuer.types.namedtuple(typename, field_names, *, rename=False, defaults=None, module=None)#
Returns a new subclass of tuple with named fields.
>>> Point = namedtuple('Point', ['x', 'y']) >>> Point.__doc__ # docstring for the new class 'Point(x, y)' >>> p = Point(11, y=22) # instantiate with positional args or keywords >>> p[0] + p[1] # indexable like a plain tuple 33 >>> x, y = p # unpack like a regular tuple >>> x, y (11, 22) >>> p.x + p.y # fields also accessible by name 33 >>> d = p._asdict() # convert to a dictionary >>> d['x'] 11 >>> Point(**d) # convert from a dictionary Point(x=11, y=22) >>> p._replace(x=100) # _replace() is like str.replace() but targets named fields Point(x=100, y=22)
- class vuer.types.NamedTuple#
Bases:
objectTyped version of namedtuple.
Usage in Python versions >= 3.6:
class Employee(NamedTuple): name: str id: int
This is equivalent to:
Employee = collections.namedtuple('Employee', ['name', 'id'])
The resulting class has an extra __annotations__ attribute, giving a dict that maps field names to types. (The field names are also in the _fields attribute, which is part of the namedtuple API.) Alternative equivalent keyword syntax is also accepted:
Employee = NamedTuple('Employee', name=str, id=int)
In Python versions <= 3.5 use:
Employee = NamedTuple('Employee', [('name', str), ('id', int)])
- static __new__(cls, typename, fields=None, /, **kwargs)#
- class vuer.types.UUID#
Bases:
objectInstances of the UUID class represent UUIDs as specified in RFC 4122. UUID objects are immutable, hashable, and usable as dictionary keys. Converting a UUID to a string with str() yields something in the form ‘12345678-1234-1234-1234-123456789abc’. The UUID constructor accepts five possible forms: a similar string of hexadecimal digits, or a tuple of six integer fields (with 32-bit, 16-bit, 16-bit, 8-bit, 8-bit, and 48-bit values respectively) as an argument named ‘fields’, or a string of 16 bytes (with all the integer fields in big-endian order) as an argument named ‘bytes’, or a string of 16 bytes (with the first three fields in little-endian order) as an argument named ‘bytes_le’, or a single 128-bit integer as an argument named ‘int’.
UUIDs have these read-only attributes:
- bytes the UUID as a 16-byte string (containing the six
integer fields in big-endian byte order)
- bytes_le the UUID as a 16-byte string (with time_low, time_mid,
and time_hi_version in little-endian byte order)
- fields a tuple of the six integer fields of the UUID,
which are also available as six individual attributes and two derived attributes:
time_low the first 32 bits of the UUID time_mid the next 16 bits of the UUID time_hi_version the next 16 bits of the UUID clock_seq_hi_variant the next 8 bits of the UUID clock_seq_low the next 8 bits of the UUID node the last 48 bits of the UUID
time the 60-bit timestamp clock_seq the 14-bit sequence number
hex the UUID as a 32-character hexadecimal string
int the UUID as a 128-bit integer
urn the UUID as a URN as specified in RFC 4122
- variant the UUID variant (one of the constants RESERVED_NCS,
RFC_4122, RESERVED_MICROSOFT, or RESERVED_FUTURE)
- version the UUID version number (1 through 5, meaningful only
when the variant is RFC_4122)
- is_safe An enum indicating whether the UUID has been generated in
a way that is safe for multiprocessing applications, via uuid_generate_time_safe(3).
- property bytes#
- property bytes_le#
- property fields#
- property time_low#
- property time_mid#
- property time_hi_version#
- property clock_seq_hi_variant#
- property clock_seq_low#
- property time#
- property clock_seq#
- property node#
- property hex#
- property urn#
- property variant#
- property version#
- int#
- is_safe#
- class vuer.types.Event#
Bases:
objectAn event is a message sent from the server to the client.
- class vuer.types.ServerEvent#
Bases:
Event- serialize()#
Serialize the event to a dictionary for sending over the websocket. :return: A dictionary representing the event.
- class vuer.types.Vector3#
Bases:
tupleVector3(x, y, z)
- static __new__(_cls, x, y, z)#
Create new instance of Vector3(x, y, z)
- x#
Alias for field number 0
- y#
Alias for field number 1
- z#
Alias for field number 2
- class vuer.types.Euler#
Bases:
tupleEuler(x, y, z, order)
- x: int#
Alias for field number 0
- y: int#
Alias for field number 1
- z: int#
Alias for field number 2
- order: str#
Alias for field number 3
- static __new__(_cls, x: int, y: int, z: int, order: str = 'XYZ')#
Create new instance of Euler(x, y, z, order)
- Parameters:
x (int) –
y (int) –
z (int) –
order (str) –
- class vuer.types.Body#
Bases:
tupleBody(position, rotation, scale)
- scale: float#
Alias for field number 2
- class vuer.types.RenderNode#
Bases:
object