From 80ff39a44e26c586439d85c86330adb95903a409 Mon Sep 17 00:00:00 2001 From: NicholasTurner23 Date: Sun, 1 Dec 2024 12:00:22 +0300 Subject: [PATCH] Clean up --- src/workflows/airqo_etl_utils/airqo_utils.py | 2 +- src/workflows/airqo_etl_utils/data_sources.py | 9 ++++----- 2 files changed, 5 insertions(+), 6 deletions(-) diff --git a/src/workflows/airqo_etl_utils/airqo_utils.py b/src/workflows/airqo_etl_utils/airqo_utils.py index 91f0aafdaf..c0520d2260 100644 --- a/src/workflows/airqo_etl_utils/airqo_utils.py +++ b/src/workflows/airqo_etl_utils/airqo_utils.py @@ -632,7 +632,7 @@ def extract_devices_data_( logger.exception(f"An error occured: {e} - device {device['name']}") continue if isinstance(data, pd.DataFrame) and data.empty: - logger.exception(f"No data received from {device['name']}") + logger.warning(f"No data received from {device['name']}") continue if isinstance(data, pd.DataFrame) and not data.empty: diff --git a/src/workflows/airqo_etl_utils/data_sources.py b/src/workflows/airqo_etl_utils/data_sources.py index ad4b2ecd9f..edce7897a2 100644 --- a/src/workflows/airqo_etl_utils/data_sources.py +++ b/src/workflows/airqo_etl_utils/data_sources.py @@ -57,7 +57,7 @@ def thingspeak( read_key (str): The API key to authenticate the request for the specified channel. Returns: - Optional[Tuple[List[Dict[str, Any]], Dict[str, Any]]]: + Optional[Tuple[List[Dict[str, Any]], Dict[str, Any], bool]]: - A list of dictionaries containing the channel feeds data. - A dictionary containing metadata about the channel. - Returns `None` if no valid data is found or an error occurs. @@ -116,7 +116,7 @@ def iqair( - "monthly": Monthly aggregated data. Returns: - pd.DataFrame: A DataFrame containing the retrieved data, or an empty DataFrame in case of errors or no data. + Union[List, Dict]: A list or dictionary containing the retrieved data, or `None` in case of errors or no data. Raises: ValueError: If an invalid resolution is provided or if the response data is invalid or malformed. @@ -142,10 +142,9 @@ def iqair( device_id = device.get("serial_number") if not base_url or not device_id: logger.exception( - ValueError( - "Device information must include 'api_code' and 'serial_number'." - ) + "Device information must include 'api_code' and 'serial_number'." ) + url = f"{base_url}/{device_id}" logger.info(f"Fetching data from URL: {url}")