AFL.automation.APIServer.Driver#

Functions

Classes

Driver(name[, defaults, overrides, ...])

DriverWebAppsMixin()

PersistentConfig(path[, defaults, ...])

A dictionary-like class that serializes changes to disk

ProxyDriver(name[, defaults, overrides, ...])

Base driver for forwarding commands to one or more AFL APIServers.

Exceptions

ProxyConnectionError

Raised when a proxy driver cannot establish or use a remote Client.

AFL.automation.APIServer.Driver.makeRegistrar()[source]#
class AFL.automation.APIServer.Driver.Driver(name, defaults=None, overrides=None, useful_links=None, afl_home=None)[source]#
unqueued()#
queued()#
quickbar()#
__init__(name, defaults=None, overrides=None, useful_links=None, afl_home=None)[source]#
static_dirs = {}#
log_info(message)[source]#
log_error(message)[source]#
log_debug(message)[source]#
log_warning(message)[source]#
classmethod gather_defaults()[source]#

Gather all inherited static class-level dictionaries called default.

classmethod gather_static_dirs()[source]#

Gather all inherited class-level dictionaries named static_dirs.

This method walks through the Method Resolution Order (MRO) to collect static_dirs definitions from all parent classes. Child class definitions override parent definitions for the same subpath key.

Returns:

Dictionary mapping subpaths to pathlib.Path objects for directories containing static files to be served by the API server.

Return type:

dict

set_config(**kwargs)[source]#
get_config(name, print_console=False)[source]#
get_configs(print_console=False)[source]#
clean_config()[source]#

Remove any config keys that are not present in defaults.

This method gathers all defaults from the class hierarchy, makes a copy of the current config, and removes any keys that don’t exist in the defaults. The cleaned config is then saved back to the persistent config.

Returns:

Dictionary containing the keys that were removed from config

Return type:

dict

set_sample(sample_name, sample_uuid=None, **kwargs)[source]#
get_sample()[source]#
reset_sample()[source]#
status()[source]#
pre_execute(**kwargs)[source]#

Executed before each call to execute

All of the kwargs passed to execute are also pass to this method. It is expected that this method be overridden by subclasses.

post_execute(**kwargs)[source]#

Executed after each call to execute

All of the kwargs passed to execute are also pass to this method. It is expected that this method be overridden by subclasses.

execute(**kwargs)[source]#
set_object(serialized=True, **kw)[source]#
get_object(name, serialize=True)[source]#
set_data(data: dict)[source]#

Set data in the DataPacket object

Parameters:
  • data (dict) – Dictionary of data to store in the driver object

  • variables (Note! if the keys in data are not system or sample)

:param : :param they will be erased at the end of this function call.:

retrieve_obj(uid, delete=True)[source]#

Retrieve an object from the dropbox

Parameters:

uid (str) – The uuid of the file to retrieve

deposit_obj(obj, uid=None)[source]#

Store an object in the dropbox

Parameters:
  • obj (object) – The object to store in the dropbox

  • uid (str) – The uuid to store the object under

tiled_browser(**kwargs)[source]#

Serve the Tiled database browser HTML interface.

tiled_plot(**kwargs)[source]#

Serve the Tiled plotting interface for selected entries.

tiled_gantt(**kwargs)[source]#

Serve the Tiled Gantt chart interface for selected entries.

tiled_config(**kwargs)[source]#

Return Tiled server configuration from shared config file.

Proxy endpoint for Tiled metadata search to avoid CORS issues.

tiled_get_data(entry_id, **kwargs)[source]#

Proxy endpoint to get xarray HTML representation from Tiled.

tiled_get_xarray_html(entry_ids, **kwargs)[source]#

Return xarray _repr_html_() for one or more Tiled entries.

tiled_get_plot_manifest(entry_ids, **kwargs)[source]#

Return plot-manifest metadata for one or more Tiled entries.

tiled_get_plot_variable(entry_ids, var_name, **kwargs)[source]#

Return one variable from the cached combined plot dataset.

tiled_get_metadata(entry_id, **kwargs)[source]#

Proxy endpoint to get metadata from Tiled.

tiled_get_full_json(entry_id, **kwargs)[source]#

Proxy endpoint to get JSON-serializable full data for one entry.

tiled_get_distinct_values(field, **kwargs)[source]#

Get distinct values for a metadata field from Tiled.

tiled_upload_dataset(dataset=None, upload_bytes=None, filename='', file_format='', coordinate_column='', metadata=None, delimiter='', comment_prefix='', last_comment_as_header='', **kwargs)[source]#

Upload xarray/csv/tsv/dat data into Tiled.

exception AFL.automation.APIServer.Driver.ProxyConnectionError[source]#

Raised when a proxy driver cannot establish or use a remote Client.

class AFL.automation.APIServer.Driver.ProxyDriver(name, defaults=None, overrides=None, proxy_clients=None)[source]#

Base driver for forwarding commands to one or more AFL APIServers.

Subclasses retain their own API and safety policy, while this class owns lazy Client construction and optional injected clients for testing. A proxy connection is not opened during driver construction.

__init__(name, defaults=None, overrides=None, proxy_clients=None)[source]#
get_proxy_client(proxy_name, *, ip, port, username=None, client_factory=None)[source]#

Return a cached Client for proxy_name, creating it on first use.

enqueue_proxy(proxy_name, task_name, **kwargs)[source]#

Enqueue a command on a named remote driver and return its task UUID.

query_proxy(proxy_name, command, **kwargs)[source]#

Call a named unqueued operation on a remote driver.