endaq.cloud
¶
This module houses tools and functions to make both interacting with the enDAQ Cloud API and the [enDAQ Cloud](https://cloud.endaq.com) itself easier.
endaq.cloud.core¶
Core enDAQ Cloud communication API
- class endaq.cloud.core.EndaqCloud(api_key=None, env=None, test=True)¶
A representation of a connection to an enDAQ Cloud account, providing a high-level interface for accessing its contents.
Constructor for an EndaqCloud object, which provides access to an enDAQ Cloud account.
- Parameters
api_key (Optional[str]) – The Endaq Cloud API associated with your cloud.endaq.com account. If you do not have one created yet, they can be created on the following web page: https://cloud.endaq.com/account/api-keys
env (Optional[str]) – The cloud environment to connect to, which can be production, staging, or development. These can be easily accessed with the variables ENV_PRODUCTION, ENV_STAGING, and ENV_DEVELOP
test (bool) – If True (default), the connection to enDAQ Cloud will be tested before being returned. A failed test will generate a meaningful error message describing the problem.
- property account_email: Optional[str]¶
The email address associated with the enDAQ Cloud account.
- property account_id: Optional[str]¶
The enDAQ Cloud account’s unique ID.
- download_all_ide_files(output_directory='', should_download_file_fn=None, force_reload_file_table=False, file_limit=100)¶
Downloads all IDE files from the enDAQ Cloud (up to a specified file limit).
- Parameters
output_directory (Union[str, pathlib.Path]) – The directory to download the ide files to
should_download_file_fn (Optional[Callable]) – A function which accepts a row of the IDE file table and returns a boolean value which indicates if the IDE file should be downloaded or not. If this function is not given, the default function will always return True.
force_reload_file_table (bool) – If the file table to use as reference for what files exist in the cloud should be recomputed even if it is already stored (as self.file_table)
file_limit (int) – The maximum number of files to download. If the force_recompute_file_table parameter is True then this will also be used to limit the number of files put in the file table it creates.
- Returns
An array of the filenames which were just downloaded
- Return type
numpy.ndarray
- TO-DO:
Would be nice to have a parameter to get only ones with a certain tag
Maybe Have a blacklist and/or whitelist parameter
- get_account_info()¶
Get information about the connected account. Sets or updates the values of account_id and account_email.
- Returns
If successful, a dictionary containing (at minimum) the keys email and id.
- Return type
dict
- get_devices(limit=100)¶
Get dataframe of devices and associated attributes (part_number, description, etc.) attached to the account.
- Parameters
limit (int) – The maximum number of files to return.
- Returns
A DataFrame of recorder information.
- Return type
pandas.core.frame.DataFrame
- get_file(file_id, local_name=None)¶
Download the specified file to local_name if provided, use the file name from the cloud if no local name is provided.
- Parameters
file_id (Union[int, str]) – The file’s cloud ID.
local_name (Optional[str]) – The downloaded file’s destination pathname; defaults to the file’s original basename & located in the directory in which the Python interpreter was launched
- Returns
The imported file, as an idelib.Dataset.
- Return type
idelib.dataset.Dataset
- get_file_table(attributes='all', limit=100)¶
Get a table of the data that would be similar to that you’d get doing the CSV export on the my recordings page, up to the first limit files with attributes matching attributes.
- Parameters
limit (int) – The maximum number of files to return.
attributes (Union[list, str]) – A list of attribute strings (or a single comma-delimited string of attributes) to match.
- Returns
A DataFrame of file IDs and relevant information.
- Return type
pandas.core.frame.DataFrame
- set_attributes(file_id, attributes)¶
Set the ‘attributes’ (name/value metadata) of a file.
- Parameters
file_id (Union[int, str]) – The file’s cloud ID.
attributes (list) – A list of dictionaries of the following structure:
[{ "name": "attr_31", "type" : "float", "value" : 3.3, }]
- Returns
The list of the file’s new attributes.
- Return type
list
- endaq.cloud.core.count_tags(df)¶
Given the dataframe returned by
EndaqCloud.get_file_table()
, provide some info on the tags of the files in that account.- Parameters
df (pandas.core.frame.DataFrame) – A DataFrame of file information, as returned by
EndaqCloud.get_file_table()
.- Returns
A DataFrame summarizing the tags in df.
- Return type
pandas.core.frame.DataFrame
- endaq.cloud.core.json_table_to_df(data)¶
Convert JSON parsed from a custom report to a more user-friendly pandas.DataFrame.
- Parameters
data (list) – A list of data from a custom report’s JSON.
- Returns
A formatted DataFrame
- Return type
pandas.core.frame.DataFrame