Module h2o_wave.core

Functions

clone_expando

def clone_expando(source:¬†Expando, exclude_keys:¬†Union[list,¬†tuple,¬†NoneType]¬†=¬†None, include_keys:¬†Union[list,¬†tuple,¬†NoneType]¬†=¬†None) ‚ÄĎ>¬†Expando

Clone an expando instance. Creates a shallow clone.

Args
source
The expando to clone.
exclude_keys
Keys to exclude while cloning.
include_keys
Keys to include while cloning.
Returns

The expando clone.

copy_expando

def copy_expando(source:¬†Expando, target:¬†Expando, exclude_keys:¬†Union[list,¬†tuple,¬†NoneType]¬†=¬†None, include_keys:¬†Union[list,¬†tuple,¬†NoneType]¬†=¬†None) ‚ÄĎ>¬†Expando

Copy all entries from the source expando instance to the target expando instance.

Args
source
The expando to copy from.
target
The expando to copy to.
exclude_keys
Keys to exclude while copying.
include_keys
Keys to include while copying.
Returns

The target expando.

data

def data(fields:¬†Union[str,¬†tuple,¬†list], size:¬†int¬†=¬†0, rows:¬†Union[dict,¬†list,¬†NoneType]¬†=¬†None, columns:¬†Union[dict,¬†list,¬†NoneType]¬†=¬†None, pack=False) ‚ÄĎ>¬†Union[Data,¬†str]

Create a Data instance for associating data with cards.

data()(fields, size) creates a placeholder for data and allocates memory on the Wave server.

data()(fields, size, rows) creates a placeholder and initializes it with the provided rows.

If pack() is True, the size parameter is ignored, and the function returns a packed string representing the data.

Args
fields
The names of the fields (columns names) in the data, either a list or tuple or string containing space-separated names.
size
The number of rows to allocate memory for. Positive for fixed buffers, negative for circular buffers and zero for variable length buffers.
rows
The rows in this data.
columns
The columns in this data.
pack
True to return a packed string representing the data instead of a Data placeholder.
Returns

Either a Data placeholder or a packed string representing the data.

expando_to_dict

def expando_to_dict(e:¬†Expando) ‚ÄĎ>¬†dict

Extract an expando's underlying dictionary. Any modifications to the dictionary also affect the original expando.

Args
e
The expando instance.
Returns

The expando's dictionary.

marshal

def marshal(d:¬†Any) ‚ÄĎ>¬†str

Marshal to JSON.

Args
d
Any object or value.
Returns

A string containing the JSON-serialized form.

pack

def pack(data:¬†Any) ‚ÄĎ>¬†str

Pack (compress) the provided value.

Args
data
Any object or value.

The object or value compressed into a string.

unmarshal

def unmarshal(s:¬†str) ‚ÄĎ>¬†Any

Unmarshal a JSON string.

Args
s
A string containing JSON-serialized data.
Returns

The deserialized object or value.

Classes

AsyncPage

class AsyncPage(site: AsyncSite, url: str)

Represents a reference to a remote Wave page. Similar to Page except that this class exposes async methods.

Args
site
The parent site.
url
The URL of this page.

Methods

load

async def load(self) ‚ÄĎ>¬†dict

Retrieve the serialized form of this page from the remote site.

Returns

The serialized form of this page

push

async def push(self)

DEPRECATED: Use AsyncPage.save() instead.

save

async def save(self)

Save the page. Sends all local changes made to this page to the remote site.

Ancestors

Inherited members

AsyncSite

class AsyncSite

Represents a reference to the remote Wave site. Similar to Site except that this class exposes async methods.

Methods

download

async def download(self, url:¬†str, path:¬†str) ‚ÄĎ>¬†str

Download a file from the site.

Args
url
The URL of the file.
path
The local directory or file path to download to. If a directory is provided, the original name of the file is retained.
Returns

The path to the downloaded file.

load

async def load(self, url) ‚ÄĎ>¬†dict

Retrieve data at the given URL, typically the serialized form of a page.

Args
url
The URL to read.
Returns

The serialized page.

unload

async def unload(self, url: str)

Delete an uploaded file from the site.

Args
url
The URL of the file to delete.

upload

async def upload(self, files:¬†List[str]) ‚ÄĎ>¬†List[str]

Upload local files to the site.

Args
files
A list of file paths of the files to be uploaded..
Returns

A list of remote URLs for the uploaded files, in order.

Data

class Data(fields: Union[str, tuple, list], size: int = 0, data: Union[dict, list, NoneType] = None)

Represents a data placeholder. A data placeholder is used to allocate memory on the Wave server to store data.

Args
fields
The names of the fields (columns names) in the data, either a list or tuple or string containing space-separated names.
size
The number of rows to allocate memory for. Positive for fixed buffers, negative for circular buffers and zero for variable length buffers.
data
Initial data. Must be either a key-row dict for variable-length buffers OR a row list for fixed-size and circular buffers.

Methods

dump

def dump(self)

Expando

class Expando(args: Optional[Dict] = None)

Represents an object whose members (attributes) can be dynamically added and removed at run time.

Args
args
An optional dict of attribute-value pairs to initialize the expando instance with.

Page

class Page(site: Site, url: str)

Represents a reference to a remote Wave page.

Args
site
The parent site.
url
The URL of this page.

Methods

load

def load(self) ‚ÄĎ>¬†dict

Retrieve the serialized form of this page from the remote site.

Returns

The serialized form of this page

save

def save(self)

Save the page. Sends all local changes made to this page to the remote site.

sync

def sync(self)

DEPRECATED: Use Page.save() instead.

Ancestors

Inherited members

PageBase

class PageBase(url: str)

Represents a remote page.

Args
url
The URL of the remote page.

Methods

add

def add(self, key:¬†str, card:¬†Any) ‚ÄĎ>¬†Ref

Add a card to this page.

Args
key
The card's key. Must uniquely identify the card on the page. Overwrites any other card with the same key.
card
A card. Use one of the ui.*_card() to create cards.
Returns

A reference to the added card.

drop

def drop(self)

Delete this page from the remote site. Same as del site[url].

Subclasses

Ref

class Ref(page: PageBase, key: str)

Represents a local reference to an element on a Page. Any changes made to this local reference are tracked and sent to the remote Wave server when the page is saved.

ServiceError

class ServiceError(*args, **kwargs)

Common base class for all non-exit exceptions.

Ancestors

  • builtins.Exception
  • builtins.BaseException

Site

class Site

Represents a reference to the remote Wave site. A Site instance is used to obtain references to the site's pages.

Methods

download

def download(self, url:¬†str, path:¬†str) ‚ÄĎ>¬†str

Download a file from the site.

Args
url
The URL of the file.
path
The local directory or file path to download to. If a directory is provided, the original name of the file is retained.
Returns

The path to the downloaded file.

load

def load(self, url) ‚ÄĎ>¬†dict

Retrieve data at the given URL, typically the serialized form of a page.

Args
url
The URL to read.
Returns

The serialized page.

unload

def unload(self, url: str)

Delete an uploaded file from the site.

Args
url
The URL of the file to delete.

upload

def upload(self, files:¬†List[str]) ‚ÄĎ>¬†List[str]

Upload local files to the site.

Args
files
A list of file paths of the files to be uploaded..
Returns

A list of remote URLs for the uploaded files, in order.