AFL.automation.APIServer.Driver#
Functions
|
Return the ceiling of x as an Integral. |
|
Connect to a Node on a local or remote server. |
|
Serialize the given arguments as JSON, and return a |
|
|
|
Render a template by name with the given context. |
|
Return the square root of x. |
Classes
|
|
|
A dictionary-like class that serializes changes to disk |
- class AFL.automation.APIServer.Driver.Driver(name, defaults=None, overrides=None, useful_links=None)[source]#
- unqueued()#
- queued()#
- quickbar()#
- static_dirs = {'tiled_browser_css': PosixPath('/github/workspace/AFL/automation/driver_templates/tiled_browser/css'), 'tiled_browser_js': PosixPath('/github/workspace/AFL/automation/driver_templates/tiled_browser/js')}#
- 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:
- 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:
- 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.
- 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
- 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_search(queries='', offset=0, limit=50, **kwargs)[source]#
Proxy endpoint for Tiled metadata search to avoid CORS issues.
- Parameters:
queries – JSON string of query list: [{“field”: “field_name”, “value”: “search_value”}, …]
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_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
- tiled_get_combined_plot_data(entry_ids, **kwargs)[source]#
Get concatenated xarray datasets from multiple Tiled entries.
- Parameters:
entry_ids – JSON string array of entry IDs to concatenate
- Returns:
dict with combined dataset structure ready for plotting
- tiled_get_gantt_metadata(entry_ids, **kwargs)[source]#
Get metadata for Gantt chart from multiple Tiled entries.
This is a lightweight endpoint that only fetches metadata without loading or combining the actual datasets.
- Parameters:
entry_ids – JSON string array of entry IDs
- Returns:
dict with list of metadata for each entry