endaq.cloud

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.

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. TODO: This should be made to match endaq.ide.get_doc()

Parameters
  • file_id (Union[int, str]) – The file’s cloud ID.

  • local_name (Optional[str]) –

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