metadata_api_loader
metadata_api_loader ¤
DatapointAPI ¤
DatapointAPI(
device_names: list[str],
base_url: str,
api_token: str,
output_path: str = "data",
required_uuid_list: list[str] | None = None,
filter_enabled: bool = True,
timeout: int = 30,
)
Loads datatron, device, and datapoint metadata from the Datadash REST API.
Authentication is bearer-token only — pass an externally obtained JWT token:
api = DatapointAPI(
base_url="https://datadash.example.com",
api_token="eyJhbGciOiJSUzI1NiJ9...",
device_names=["Sensor A"],
)
The three core GET methods mirror the API hierarchy and can be called
independently. get_all_uuids() aggregates them into the UUID lists
required by AzureBlobParquetLoader.
Initialize the loader and fetch metadata for all requested devices.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
device_names
|
list[str]
|
Device names to collect datapoints for. |
required |
base_url
|
str
|
API host, e.g. |
required |
api_token
|
str
|
JWT bearer token for |
required |
output_path
|
str
|
Directory to write per-device JSON exports. |
'data'
|
required_uuid_list
|
list[str] | None
|
Optional allowlist; only matching UUIDs are kept. |
None
|
filter_enabled
|
bool
|
When True, only datapoints with |
True
|
timeout
|
int
|
Per-request timeout in seconds; prevents an unresponsive server from hanging the loader indefinitely. |
30
|
get_devices ¤
get_devices(datatron_id: int | str) -> list[dict]
GET /api/datatrons/{datatron_id}/devices — return all devices for a datatron.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
datatron_id
|
int | str
|
Id of the datatron (the |
required |
get_datapoints ¤
get_datapoints(
datatron_id: int | str, device_id: int | str
) -> list[dict]
GET /api/datatrons/{datatron_id}/devices/{device_id}/data_points.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
datatron_id
|
int | str
|
Id of the datatron (the |
required |
device_id
|
int | str
|
Id of the device (the |
required |
search_datatrons ¤
search_datatrons(
query: str, fields: list[str] | None = None
) -> list[dict]
Filter datatrons whose fields contain query (case-insensitive).
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
query
|
str
|
Text to look for; matched as a case-insensitive substring. |
required |
fields
|
list[str] | None
|
Record fields to search. None searches |
None
|
search_devices ¤
search_devices(
datatron_id: int | str,
query: str,
fields: list[str] | None = None,
) -> list[dict]
Filter devices for a datatron whose fields contain query.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
datatron_id
|
int | str
|
Id of the datatron (the |
required |
query
|
str
|
Text to look for; matched as a case-insensitive substring. |
required |
fields
|
list[str] | None
|
Record fields to search. None searches |
None
|
search_datapoints ¤
search_datapoints(
datatron_id: int | str,
device_id: int | str,
query: str,
fields: list[str] | None = None,
) -> list[dict]
Filter datapoints for a device whose fields contain query.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
datatron_id
|
int | str
|
Id of the datatron (the |
required |
device_id
|
int | str
|
Id of the device (the |
required |
query
|
str
|
Text to look for; matched as a case-insensitive substring. |
required |
fields
|
list[str] | None
|
Record fields to search. None searches |
None
|
find_devices ¤
find_devices(
query: str, fields: list[str] | None = None
) -> list[dict]
Search all devices across all datatrons.
Each result dict includes an extra datatron_id key.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
query
|
str
|
Text to look for; matched as a case-insensitive substring. |
required |
fields
|
list[str] | None
|
Record fields to search. None searches |
None
|
find_datapoints ¤
find_datapoints(
query: str, fields: list[str] | None = None
) -> list[dict]
Search all datapoints across all datatrons and devices.
Each result dict includes extra datatron_id and device_id keys.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
query
|
str
|
Text to look for; matched as a case-insensitive substring. |
required |
fields
|
list[str] | None
|
Record fields to search. None searches |
None
|
get_all_uuids ¤
get_all_uuids() -> dict[str, list[str]]
Return {device_name: [uuid, ...]} — ready for the Azure parquet loader.
get_all_metadata ¤
get_all_metadata() -> dict[str, list[dict]]
Return {device_name: [record, ...]} with uuid/label/config columns.
display_dataframe ¤
display_dataframe(device_name: str | None = None) -> None
Log the metadata DataFrame for one device or all devices.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
device_name
|
str | None
|
Device to log. None logs every device loaded at init; an unknown name logs a warning. |
None
|