envision.client module

class envision.client.Client(endpoint: str | None = None, wait_between_retries: float = 0.5, output_dir: str | None = None, sim_name: str | None = None, headless: bool = False, envision_state_filter: EnvisionStateFilter | None = None, data_formatter_args: EnvisionDataFormatterArgs | None = None)[source]

Used to push state from SMARTS to Envision server while the simulation is running.

class QueueDone[source]

A marker type to indicate termination of messages.

property envision_state_filter: EnvisionStateFilter

Filtering options for data.

property headless

Indicates if this client is disconnected from the remote.

static read_and_send(path: str, endpoint: str = 'ws://localhost:8081', fixed_timestep_sec: float = 0.1, wait_between_retries: float = 0.5)[source]

Send recorded envision simulation data to the envision server.

send(state: State | Preamble)[source]

Send the given envision state to the remote as the most recent state.

teardown()[source]

Clean up the client resources.

class envision.client.CustomJSONEncoder(*, skipkeys=False, ensure_ascii=True, check_circular=True, allow_nan=True, sort_keys=False, indent=None, separators=None, default=None)[source]

This custom encoder is to support serializing more complex data from SMARTS including numpy arrays, NaNs, and Infinity which don’t have standardized handling according to the JSON spec.

default(obj)[source]

Implement this method in a subclass such that it returns a serializable object for o, or calls the base implementation (to raise a TypeError).

For example, to support arbitrary iterators, you could implement default like this:

def default(self, o):
    try:
        iterable = iter(o)
    except TypeError:
        pass
    else:
        return list(iterable)
    # Let the base class default method raise the TypeError
    return JSONEncoder.default(self, o)
class envision.client.JSONEncodingState(data: Any)[source]

This class is necessary to ensure that the custom json encoder tries to deserialize the data. This is vital to ensure that non-standard json literals like Infinity, -Infinity, NaN are not added to the output json.

data: Any