SIENTIAPDE-1478
Enhance API class to format timestamps correctly and improve logging. Update test cases to include 'end_time' parameter for better data retrieval flexibility.
This commit is contained in:
@@ -10,6 +10,7 @@ with workflow.unsafe.imports_passed_through():
|
|||||||
from sientia_do.observability.metrics_controller import MetricsController
|
from sientia_do.observability.metrics_controller import MetricsController
|
||||||
from sientia_do.observability.sientia_monitoring import SientiaMonitoring
|
from sientia_do.observability.sientia_monitoring import SientiaMonitoring
|
||||||
from sientia_do.repository.pi_web_api_client import PIWebAPIClient
|
from sientia_do.repository.pi_web_api_client import PIWebAPIClient
|
||||||
|
from sientia_do.temporal.constants import DATETIME_FORMAT_WITH_TZ
|
||||||
|
|
||||||
|
|
||||||
class API(SientiaMonitoring):
|
class API(SientiaMonitoring):
|
||||||
@@ -137,13 +138,13 @@ class API(SientiaMonitoring):
|
|||||||
)
|
)
|
||||||
raise e
|
raise e
|
||||||
|
|
||||||
# latest_values['timestamp'] = latest_values['timestamp'].dt.strftime(DATETIME_FORMAT_WITH_TZ)
|
latest_values['timestamp'] = latest_values['timestamp'].dt.strftime(DATETIME_FORMAT_WITH_TZ)
|
||||||
|
|
||||||
# self.debug(f'Latest values: {latest_values.to_string()}', metadata=metadata)
|
self.debug(f'Latest values: {latest_values.to_string()}', metadata=metadata)
|
||||||
|
|
||||||
# # Normalize the package timestamp
|
# Normalize the package timestamp
|
||||||
# valid_timestamp_values = latest_values['timestamp'].dropna()
|
valid_timestamp_values = latest_values['timestamp'].dropna()
|
||||||
# latest_values['timestamp'] = valid_timestamp_values.max()
|
latest_values['timestamp'] = valid_timestamp_values.max()
|
||||||
|
|
||||||
self.info(f'Gathered {len(latest_values)} tag values', metadata=metadata)
|
self.info(f'Gathered {len(latest_values)} tag values', metadata=metadata)
|
||||||
|
|
||||||
|
|||||||
@@ -139,6 +139,7 @@ async def test_get_tag_values_success(api_activity):
|
|||||||
'tag3': {'webid': 'webid3', 'aggr_function': 'avg', 'data_range': [0, 100]},
|
'tag3': {'webid': 'webid3', 'aggr_function': 'avg', 'data_range': [0, 100]},
|
||||||
},
|
},
|
||||||
start_time='*-1d',
|
start_time='*-1d',
|
||||||
|
end_time='*',
|
||||||
max_count=10,
|
max_count=10,
|
||||||
metadata=metadata['metadata'],
|
metadata=metadata['metadata'],
|
||||||
request_timeout=30,
|
request_timeout=30,
|
||||||
@@ -193,6 +194,7 @@ async def test_get_tag_values_with_default_max_count(api_activity):
|
|||||||
endpoint='/streamsets/recorded',
|
endpoint='/streamsets/recorded',
|
||||||
web_ids={'tag1': {'webid': 'webid1', 'aggr_function': 'avg', 'data_range': [0, 100]}},
|
web_ids={'tag1': {'webid': 'webid1', 'aggr_function': 'avg', 'data_range': [0, 100]}},
|
||||||
start_time='*-1h',
|
start_time='*-1h',
|
||||||
|
end_time='*',
|
||||||
max_count=1,
|
max_count=1,
|
||||||
metadata=metadata['metadata'],
|
metadata=metadata['metadata'],
|
||||||
request_timeout=15,
|
request_timeout=15,
|
||||||
|
|||||||
Reference in New Issue
Block a user