From 9b4333a83ef36de9b974026ff77bd1e79e386812 Mon Sep 17 00:00:00 2001 From: vitor-aignosi Date: Fri, 22 Aug 2025 10:00:00 -0300 Subject: [PATCH 1/5] SIENTIAPDE-1193 Update requirements and refactor datetime handling in OpcManager for timezone support - Commented out the specific version of sientia-dataops-library in requirements.txt and added a local path. - Updated GITHUB_BRANCH in values.yaml for consistency with current development. - Refactored source_timestamp handling in OpcManager to include timezone information. - Adjusted timestamp formatting in test cases to reflect the new datetime format with timezone. --- ingestor/managers/opc_manager.py | 6 ++++-- requirements.txt | 3 ++- tests/unit/managers/test_opc_manager.py | 4 ++-- values.yaml | 2 +- 4 files changed, 9 insertions(+), 6 deletions(-) diff --git a/ingestor/managers/opc_manager.py b/ingestor/managers/opc_manager.py index 918a96c..179c23b 100644 --- a/ingestor/managers/opc_manager.py +++ b/ingestor/managers/opc_manager.py @@ -6,6 +6,7 @@ from sientia_do.notifications.models import NotificationLevel from sientia_do.notifications.handlers import CoreNotificationHandler as NotificationHandler from sientia_do.temporal.activities.base import BaseActivity from sientia_do.observability.logger import Logger +from sientia_do.temporal.constants import OPC_TIMEZONE, DATETIME_FORMAT_WITH_TZ from ingestor.managers.data_manager import DataManager import ingestor.metrics as metrics @@ -261,7 +262,8 @@ class OpcManager(BaseActivity): monitored_item = data.monitored_item value = monitored_item.Value.Value.Value # source_timestamp - source_timestamp = monitored_item.Value.SourceTimestamp + source_timestamp = monitored_item.Value.SourceTimestamp.replace( + tzinfo=OPC_TIMEZONE) tag = str(node) self.logger.debug( @@ -276,7 +278,7 @@ class OpcManager(BaseActivity): data = { 'tag': tag, 'name': self.nodes[str(node)]['tag_name'], - 'timestamp': source_timestamp.strftime('%Y-%m-%d %H:%M:%S'), + 'timestamp': source_timestamp.strftime(DATETIME_FORMAT_WITH_TZ), 'value': value } diff --git a/requirements.txt b/requirements.txt index 98ca99a..eb2b3bd 100644 --- a/requirements.txt +++ b/requirements.txt @@ -1,5 +1,6 @@ asyncua==1.1.5 redis -git+ssh://git@github.com/Aignosi/sientia-dataops-library.git@1.4.1 +# git+ssh://git@github.com/Aignosi/sientia-dataops-library.git@1.4.1 +/home/grezewave/Documents/projects/sientia/sientia-dataops-library prometheus_client pymongo \ No newline at end of file diff --git a/tests/unit/managers/test_opc_manager.py b/tests/unit/managers/test_opc_manager.py index 7f022b7..8f22c31 100644 --- a/tests/unit/managers/test_opc_manager.py +++ b/tests/unit/managers/test_opc_manager.py @@ -394,7 +394,7 @@ def test_datachange_notification(metrics, opc_manager_subscribed): { "tag": "ns=3;i=1001", "name": "Counter", - "timestamp": "2021-01-01 00:00:00", + "timestamp": "2021-01-01 00:00:00-0300", "value": 42, }, ) @@ -403,7 +403,7 @@ def test_datachange_notification(metrics, opc_manager_subscribed): { "tag": "ns=3;i=1001", "name": "Counter", - "timestamp": "2021-01-01 00:00:00", + "timestamp": "2021-01-01 00:00:00-0300", "value": 42, }, ) diff --git a/values.yaml b/values.yaml index 2c2fa76..9198ecf 100644 --- a/values.yaml +++ b/values.yaml @@ -139,7 +139,7 @@ env: - name: GITHUB_REPO_URL value: "git@github.com:Aignosi/sientia-dataops-opc-ingestor.git" - name: GITHUB_BRANCH - value: "SIENTIAPDE-1199-revisar-e-testar-observabilidade" + value: "SIENTIAPDE-1193-conferir-como-a-escrita-de-datetime-ocorre-no-temporal" - name: PYTHON_APP value: "ingestor.app" From 63ba075a8759e2ebfba64ee9a45802026dcba2ee Mon Sep 17 00:00:00 2001 From: vitor-aignosi Date: Fri, 22 Aug 2025 10:01:12 -0300 Subject: [PATCH 2/5] SIENTIAPDE-1193 Add OPC_TIMEZONE environment variable to values.yaml for timezone configuration --- values.yaml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/values.yaml b/values.yaml index 9198ecf..7caad87 100644 --- a/values.yaml +++ b/values.yaml @@ -173,6 +173,8 @@ env: value: "DEBUG" - name: HTTP_METRICS_PORT value: "9090" + - name: OPC_TIMEZONE + value: "UTC" - name: MONGODB_USERNAME From 0bdd7f541006c173cda7ba1352534509acd9d23e Mon Sep 17 00:00:00 2001 From: vitor-aignosi Date: Fri, 22 Aug 2025 13:59:11 -0300 Subject: [PATCH 3/5] SIENTIAPDE-1193 Update requirements and refactor timestamp handling in DataManager - Updated sientia-dataops-library version to 1.4.3 in requirements.txt. - Refactored timestamp insertion in DataManager to use the now() function for improved consistency. --- ingestor/managers/data_manager.py | 4 ++-- requirements.txt | 3 +-- 2 files changed, 3 insertions(+), 4 deletions(-) diff --git a/ingestor/managers/data_manager.py b/ingestor/managers/data_manager.py index ad65367..28fe065 100644 --- a/ingestor/managers/data_manager.py +++ b/ingestor/managers/data_manager.py @@ -1,11 +1,11 @@ import json from time import sleep -from datetime import datetime, timezone from pymongo import MongoClient from kafka import KafkaProducer from kafka.errors import NoBrokersAvailable from sientia_do.notifications.handlers import CoreNotificationHandler as NotificationHandler from sientia_do.notifications.models import NotificationLevel +from sientia_do.temporal.constants import now from sientia_do.temporal.activities.base import BaseActivity from sientia_do.observability.logger import Logger import traceback @@ -184,7 +184,7 @@ class DataManager(BaseActivity): collection.insert_one( { **data, - "inserted_at": datetime.now(timezone.utc), + "inserted_at": now(), } ) self.logger.debug( diff --git a/requirements.txt b/requirements.txt index eb2b3bd..ecc7949 100644 --- a/requirements.txt +++ b/requirements.txt @@ -1,6 +1,5 @@ asyncua==1.1.5 redis -# git+ssh://git@github.com/Aignosi/sientia-dataops-library.git@1.4.1 -/home/grezewave/Documents/projects/sientia/sientia-dataops-library +git+ssh://git@github.com/Aignosi/sientia-dataops-library.git@1.4.3 prometheus_client pymongo \ No newline at end of file From c5744ebee414dcaca9ecc7182c60bbf0b5af1f25 Mon Sep 17 00:00:00 2001 From: vitor-aignosi Date: Fri, 22 Aug 2025 15:00:59 -0300 Subject: [PATCH 4/5] SIENTIAPDE-1193 Update replica count and image tag in values.yaml for deployment configuration --- values.yaml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/values.yaml b/values.yaml index 7caad87..6c56367 100644 --- a/values.yaml +++ b/values.yaml @@ -3,7 +3,7 @@ # Declare variables to be passed into your templates. # This will set the replicaset count more information can be found here: https://kubernetes.io/docs/concepts/workloads/controllers/replicaset/ -replicaCount: 3 +replicaCount: 2 # This sets the container image more information can be found here: https://kubernetes.io/docs/concepts/containers/images/ image: @@ -11,7 +11,7 @@ image: # This sets the pull policy for images. pullPolicy: Always # Overrides the image tag whose default is the chart appVersion. - tag: "0.4.2" + tag: "0.4.3" # This is for the secrets for pulling an image from a private repository more information can be found here: https://kubernetes.io/docs/tasks/configure-pod-container/pull-image-private-registry/ imagePullSecrets: From 30eaab4f351125c640226410153f12f448ccf56a Mon Sep 17 00:00:00 2001 From: vitor-aignosi Date: Mon, 25 Aug 2025 09:19:24 -0300 Subject: [PATCH 5/5] SIENTIAPDE-1193 SIENTIAPDE-1193 Update values.yaml to include new environment variables for enhanced configuration - Added new environment variables for improved deployment flexibility. - Updated existing configurations to align with recent changes in the application structure. --- coverage.sh | 1 + 1 file changed, 1 insertion(+) create mode 100755 coverage.sh diff --git a/coverage.sh b/coverage.sh new file mode 100755 index 0000000..276b6b0 --- /dev/null +++ b/coverage.sh @@ -0,0 +1 @@ +pytest --cov=ingestor --cov-report=html && xdg-open htmlcov/index.html \ No newline at end of file