Thanks to visit codestin.com
Credit goes to github.com

Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 1 addition & 8 deletions src/api/v1/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -486,24 +486,17 @@ def __init__(
class TimeWeightedAverageQueryParams:
def __init__(
self,
window_size_mins: int = Query(
None,
description="window_size_mins is deprecated and will be removed in v1.0.0. Please use time_interval_rate and time_interval_unit instead.",
examples=[20],
deprecated=True,
),
time_interval_rate: str = DuplicatedQueryParameters.time_interval_rate,
time_interval_unit: str = DuplicatedQueryParameters.time_interval_unit,
window_length: int = Query(
..., description="Window Length in days", examples=[1]
),
step: str = Query(
...,
default="metadata",
description='Step can be "true", "false" or "metadata". "metadata" will retrieve the step value from the metadata table.',
examples=["true", "false", "metadata"],
),
):
self.window_size_mins = window_size_mins
self.time_interval_rate = time_interval_rate
self.time_interval_unit = time_interval_unit
self.window_length = window_length
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
# limitations under the License.
import logging
import pandas as pd

from ._time_series_query_builder import _query_builder


Expand All @@ -37,7 +38,6 @@ def get(connection: object, parameters_dict: dict) -> pd.DataFrame:
tag_names (list): List of tagname or tagnames
start_date (str): Start date (Either a utc date in the format YYYY-MM-DD or a utc datetime in the format YYYY-MM-DDTHH:MM:SS or specify the timezone offset in the format YYYY-MM-DDTHH:MM:SS+zz:zz)
end_date (str): End date (Either a utc date in the format YYYY-MM-DD or a utc datetime in the format YYYY-MM-DDTHH:MM:SS or specify the timezone offset in the format YYYY-MM-DDTHH:MM:SS+zz:zz)
window_size_mins (int): (deprecated) Window size in minutes. Please use time_interval_rate and time_interval_unit below instead.
time_interval_rate (str): The time interval rate (numeric input)
time_interval_unit (str): The time interval unit (second, minute, day, hour)
window_length (int): Add longer window time in days for the start or end of specified date to cater for edge cases.
Expand Down Expand Up @@ -65,12 +65,8 @@ def get(connection: object, parameters_dict: dict) -> pd.DataFrame:
if parameters_dict["pivot"] is True and parameters_dict["display_uom"] is True:
raise ValueError("pivot True and display_uom True cannot be used together")

if "window_size_mins" in parameters_dict:
logging.warning(
"Parameter window_size_mins is deprecated and will be removed in v1.0.0. Please use time_interval_rate and time_interval_unit instead."
)
parameters_dict["time_interval_rate"] = str(parameters_dict["window_size_mins"])
parameters_dict["time_interval_unit"] = "minute"
if "step" not in parameters_dict: # default step to metadata if not provided
parameters_dict["step"] = "metadata"

try:
query = _query_builder(parameters_dict, "time_weighted_average")
Expand Down
2 changes: 0 additions & 2 deletions tests/api/v1/api_test_objects.py
Original file line number Diff line number Diff line change
Expand Up @@ -152,12 +152,10 @@
RAW_MOCKED_PARAMETER_ERROR_DICT.copy()
)

TIME_WEIGHTED_AVERAGE_MOCKED_PARAMETER_DICT["window_size_mins"] = "15"
TIME_WEIGHTED_AVERAGE_MOCKED_PARAMETER_DICT["time_interval_rate"] = "15"
TIME_WEIGHTED_AVERAGE_MOCKED_PARAMETER_DICT["time_interval_unit"] = "minute"
TIME_WEIGHTED_AVERAGE_MOCKED_PARAMETER_DICT["window_length"] = 10
TIME_WEIGHTED_AVERAGE_MOCKED_PARAMETER_DICT["step"] = "metadata"
TIME_WEIGHTED_AVERAGE_MOCKED_PARAMETER_ERROR_DICT["window_size_mins"] = "15"
TIME_WEIGHTED_AVERAGE_MOCKED_PARAMETER_ERROR_DICT["time_interval_rate"] = "15"
TIME_WEIGHTED_AVERAGE_MOCKED_PARAMETER_ERROR_DICT["time_interval_unit"] = "minute"
TIME_WEIGHTED_AVERAGE_MOCKED_PARAMETER_ERROR_DICT["window_length"] = 10
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -60,18 +60,7 @@ def test_time_weighted_average_check_tags(mocker: MockerFixture):
TWA_MOCKED_QUERY_CHECK_TAGS,
time_weighted_average_get,
)


def test_time_weighted_average_with_window_size_mins(mocker: MockerFixture):
MOCKED_TWA_PARAMETER_DICT["case_insensitivity_tag_search"] = False
MOCKED_TWA_PARAMETER_DICT["window_size_mins"] = 15

_test_base_succeed(
mocker,
MOCKED_TWA_PARAMETER_DICT,
TWA_MOCKED_QUERY,
time_weighted_average_get,
)


def test_time_weighted_average_metadata_step(mocker: MockerFixture):
Expand Down