AFL.automation.APIServer.DriverWebAppsMixin#

Functions

from_uri(uri[, structure_clients, cache, ...])

Connect to a Node on a local or remote server.

render_template(template_name_or_list, **context)

Render a template by name with the given context.

Classes

Contains(key, value)

Query where a given key's value contains the specified value.

DriverWebAppsMixin()

In(key, value)

Query if a given key's value is present in the specified sequence of values.

defaultdict

defaultdict(default_factory=None, /, [...]) --> dict with default factory

class AFL.automation.APIServer.DriverWebAppsMixin.DriverWebAppsMixin[source]#
TILED_RUN_DOCUMENTS_NODE = 'run_documents'#
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.

Reads tiled_server and tiled_api_key from ~/.afl/config.json. Returns dict with status and config values or helpful error message.

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 a dataset to Tiled from xarray, NetCDF bytes, CSV, TSV, or DAT.

Parameters:
  • dataset – Optional xarray.Dataset provided directly by Python callers.

  • upload_bytes – Optional bytes payload for file uploads.

  • filename – Original upload filename (used for format inference).

  • file_format – Optional explicit format (‘xarray’, ‘nc’, ‘csv’, ‘tsv’, ‘dat’).

  • coordinate_column – Optional column name used to populate sample coordinate.

  • metadata – Optional dict of metadata merged into dataset attrs.

  • delimiter – Optional delimiter override for table formats.

  • comment_prefix – Optional table comment prefix (e.g. ‘#’).

  • last_comment_as_header – If truthy, use the last comment row as headers.

Returns:

dict with status/message and dataset summary.

Proxy endpoint for Tiled metadata search to avoid CORS issues.

Parameters:
  • queries – JSON string of query list: [{“field”: “field_name”, “value”: “search_value”}, …]

  • filters – JSON string mapping fields to arrays of values

  • sort – JSON string sort model list: [{“colId”: “field”, “sort”: “asc|desc”}, …]

  • fields – JSON string list of metadata fields to return

  • offset – Result offset for pagination

  • limit – Number of results to return

Returns:

dict with status, data, total_count, or error message

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

Proxy endpoint to get xarray HTML representation from Tiled.

Parameters:

entry_id – Tiled entry ID

Returns:

dict with status and html, or error message

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

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

Reuses the combined-dataset cache shared with the plot manifest endpoint, so if the plot has already been rendered this call is effectively free.

Parameters:

entry_ids – JSON-encoded list of entry IDs

Returns:

dict with ‘status’ and ‘html’ (xarray HTML string)

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

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

This endpoint is intended as a same-origin fallback for browser clients when direct browser->Tiled CORS access is not available.

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

Proxy endpoint to get metadata from Tiled.

Parameters:

entry_id – Tiled entry ID

Returns:

dict with status and metadata, or error message

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

Get distinct/unique values for a metadata field using Tiled’s distinct() method.

Parameters:

field – Metadata field name (e.g., ‘sample_name’, ‘sample_uuid’, ‘AL_campaign_name’, ‘AL_uuid’)

Returns:

dict with status and list of unique values, or error message

tiled_concat_datasets(entry_ids, concat_dim='index', variable_prefix='')[source]#

Gather datasets from Tiled entries and concatenate them along a dimension.

This method fetches multiple datasets from a Tiled server, extracts metadata (sample_name, sample_uuid, sample_composition), and concatenates them along the specified dimension. It also supports prefixing variable names.

For a single entry, the dataset is returned as-is without concatenation, and the sample dimension is auto-detected from existing dimensions.

Parameters:
  • entry_ids (List[str]) – List of Tiled entry IDs to fetch and concatenate

  • concat_dim (str, default="index") – Dimension name along which to concatenate the datasets (ignored for single entry)

  • variable_prefix (str, default="") – Optional prefix to prepend to variable, coordinate, and dimension names (except the concat_dim itself)

Returns:

For single entry: The original dataset with metadata added as attributes For multiple entries: Concatenated dataset with: - All original data variables and coordinates from individual datasets - Additional coordinates along concat_dim:

  • sample_name: Sample name from metadata or entry_id

  • sample_uuid: Sample UUID from metadata or empty string

  • entry_id: The Tiled entry ID for each dataset

  • If sample_composition metadata exists:
    • composition: DataArray with dims [concat_dim, “components”] containing composition values for each sample

Return type:

xr.Dataset

Raises:

ValueError – If entry_ids is empty If any entry_id is not found in Tiled If datasets cannot be fetched or concatenated