From 14a75b3f2734d8db00567f3f83ad80c7097efe1f Mon Sep 17 00:00:00 2001 From: chandrika Date: Mon, 30 Sep 2024 22:02:42 -0700 Subject: [PATCH 1/6] made suffix of devices topic configurable in base historian. By default, historian now only cares about devices//multi instead of devices//all --- src/historian/base/base_historian.py | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/src/historian/base/base_historian.py b/src/historian/base/base_historian.py index 8cd0bc8..0c097a8 100644 --- a/src/historian/base/base_historian.py +++ b/src/historian/base/base_historian.py @@ -260,7 +260,6 @@ def loads(data_string): time_parser = None ACTUATOR_TOPIC_PREFIX_PARTS = len(topics.ACTUATOR_VALUE.split('/')) -ALL_REX = re.compile('.*/all$') # Register a better datetime parser in sqlite3. fix_sqlite3_datetime() @@ -353,6 +352,7 @@ def __init__(self, time_tolerance=None, time_tolerance_topics=None, cache_only_enabled=False, + devices_topic_suffix="multi", **kwargs): super(BaseHistorianAgent, self).__init__(**kwargs) @@ -417,6 +417,9 @@ def __init__(self, else: raise ValueError(f"cache_only_enabled should be either True or False") + self._devices_topic_suffix = devices_topic_suffix + + self._all_multi_regex = re.compile(f'.*/{self._devices_topic_suffix}$') self._default_config = { "retry_period":self._retry_period, "submit_size_limit": self._submit_size_limit, @@ -438,7 +441,8 @@ def __init__(self, "all_platforms": self._all_platforms, "time_tolerance": self._time_tolerance, "time_tolerance_topics": self._time_tolerance_topics, - "cache_only_enabled": self._cache_only_enabled + "cache_only_enabled": self._cache_only_enabled, + "devices_topic_suffix": self._devices_topic_suffix } self.vip.config.set_default("config", self._default_config) @@ -586,7 +590,8 @@ def _configure(self, config_name, action, contents): self._message_publish_count = message_publish_count self._time_tolerance = time_tolerance self._time_tolerance_topics = time_tolerance_topics - + self._devices_topic_suffix = config.get("devices_topic_suffix", "multi") + self._all_multi_regex = re.compile(f'.*/{self._devices_topic_suffix}$') custom_topics_list = [] for handler, topic_list in config.get("custom_topics", {}).items(): if handler == "capture_device_data": @@ -851,10 +856,10 @@ def _capture_device_data(self, peer, sender, bus, topic, headers, message): """Capture device data and submit it to be published by a historian. - Filter out only the */all topics for publishing to the historian. + Filter out only the */all or */multi topics for publishing to the historian. """ - if not ALL_REX.match(topic): + if not self._all_multi_regex.match(topic): return # Anon the topic if necessary. From 2c99cffff84dd84452ff9fd6305aae6b16b33c02 Mon Sep 17 00:00:00 2001 From: chandrika Date: Mon, 30 Sep 2024 22:04:35 -0700 Subject: [PATCH 2/6] import cleanup --- tests/test_base_historian.py | 3 --- tests/test_base_historian_unit.py | 2 -- 2 files changed, 5 deletions(-) diff --git a/tests/test_base_historian.py b/tests/test_base_historian.py index 2cff79d..adc556b 100644 --- a/tests/test_base_historian.py +++ b/tests/test_base_historian.py @@ -22,11 +22,8 @@ # ===----------------------------------------------------------------------=== # }}} -from datetime import datetime from time import sleep -from volttron.utils import format_timestamp - from historian.base import BaseHistorianAgent diff --git a/tests/test_base_historian_unit.py b/tests/test_base_historian_unit.py index a4644fe..93c2352 100644 --- a/tests/test_base_historian_unit.py +++ b/tests/test_base_historian_unit.py @@ -30,8 +30,6 @@ import pytest from pytz import UTC -from volttrontesting.server_mock import TestServer -from volttron.client import Agent from historian.base import BaseHistorianAgent From 36f1de9d23b75b41d89a5a77a0acd808af2c853d Mon Sep 17 00:00:00 2001 From: chandrika Date: Mon, 30 Sep 2024 22:10:01 -0700 Subject: [PATCH 3/6] pointing to volttron-core instead of volttron --- pyproject.toml | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/pyproject.toml b/pyproject.toml index b4e0191..fa673bd 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -12,8 +12,7 @@ packages = [ { include = "historian", from = "src" }, { include = "historian", f [tool.poetry.dependencies] python = ">=3.10,<4.0" -volttron = ">=10.0.3a9,<11.0" - +volttron-core = { path="../volttron-core", develop = true} ply = "^3.11" [tool.poetry.group.dev.dependencies] From 43c71ea3a881ed00846c7f88ee22e80769e174af Mon Sep 17 00:00:00 2001 From: chandrika Date: Tue, 1 Oct 2024 13:25:17 -0700 Subject: [PATCH 4/6] updated version and volttron-core dependency --- pyproject.toml | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/pyproject.toml b/pyproject.toml index fa673bd..b743d2b 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -1,6 +1,6 @@ [tool.poetry] name = "volttron-lib-base-historian" -version = "0.2.0-rc" +version = "1.0.0" description = "A base library with extension points for using with the VOLTTRON platform." authors = ["VOLTTRON Team "] license = "Apache License 2.0" @@ -12,7 +12,8 @@ packages = [ { include = "historian", from = "src" }, { include = "historian", f [tool.poetry.dependencies] python = ">=3.10,<4.0" -volttron-core = { path="../volttron-core", develop = true} +#volttron-core = { path="../volttron-core", develop = true} +volttron-core =">=2.0.0rc" ply = "^3.11" [tool.poetry.group.dev.dependencies] From dbbe62a9b195c47c1ca2c789d1c399024877a668 Mon Sep 17 00:00:00 2001 From: chandrika Date: Tue, 1 Oct 2024 14:03:12 -0700 Subject: [PATCH 5/6] removed volttron-testing --- pyproject.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pyproject.toml b/pyproject.toml index b743d2b..5106d95 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -30,7 +30,7 @@ coverage = "^6.3.2" pytest-cov = "^3.0.0" Sphinx = "^6.0.0" sphinx-rtd-theme = "^1.2.0" -volttron-testing = "^0.4.0rc3" +#volttron-testing = "^0.4.0rc3" [tool.yapfignore] ignore_patterns = [ From a8dcaf72ffee318ca4e0dcda7178ab084a733188 Mon Sep 17 00:00:00 2001 From: Chandrika Date: Tue, 1 Oct 2024 17:22:20 -0700 Subject: [PATCH 6/6] bumped version --- pyproject.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pyproject.toml b/pyproject.toml index 5106d95..9023015 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -1,6 +1,6 @@ [tool.poetry] name = "volttron-lib-base-historian" -version = "1.0.0" +version = "2.0.0rc0" description = "A base library with extension points for using with the VOLTTRON platform." authors = ["VOLTTRON Team "] license = "Apache License 2.0"