Merge pull request #18 from Aignosi/SIENTIAPDE-1205-alterar-opc-para-assincrono

SIENTIAPDE-1205: Standardize Datetime Handling in MongoDB Activities and Update Orchestration Notebook
This commit is contained in:
Bruno Domingues
2025-08-29 14:00:17 +00:00
committed by GitHub
6 changed files with 43 additions and 108 deletions

File diff suppressed because one or more lines are too long

View File

@@ -10,7 +10,7 @@ with workflow.unsafe.imports_passed_through():
from sientia_do.notifications.models import NotificationLevel
from sientia_do.temporal.activities.base import BaseActivity
from sientia_do.temporal.constants import DATETIME_FORMAT_MS_WITH_TZ, now
from datetime import datetime
from datetime import datetime, timezone
def clear_mongo_id(docs: list) -> list:
@@ -459,7 +459,7 @@ class MongoDB(BaseActivity):
)
for item in data:
item['timestamp'] = item['timestamp'].strftime(
item['timestamp'] = item['timestamp'].replace(tzinfo=timezone.utc).strftime(
DATETIME_FORMAT_MS_WITH_TZ)
self.info(

11
run_coverage.sh Executable file
View File

@@ -0,0 +1,11 @@
#!/bin/bash
# Exit on any error
set -e
echo "Activating virtual environment..."
source ./venv/bin/activate
pytest --cov=orchestrator --cov-report=html
xdg-open htmlcov/index.html

18
run_local.sh Executable file
View File

@@ -0,0 +1,18 @@
#!/bin/bash
# Exit on any error
set -e
echo "Activating virtual environment..."
source ./venv/bin/activate
echo "Loading environment variables from .env..."
if [ -f .env ]; then
export $(cat .env | grep -v '^#' | xargs)
echo "Environment variables loaded from .env"
else
echo "Warning: .env file not found. Continuing without environment variables."
fi
echo "Starting orchestrator application..."
python -m orchestrator.app

View File

@@ -5,6 +5,7 @@ from pytest import fixture, mark
from orchestrator.activities.mongo_db import clear_mongo_id
from orchestrator.activities.mongo_db import MongoDB
from sientia_do.notifications.models import NotificationLevel
from sientia_do.temporal.constants import DATETIME_FORMAT_MS_WITH_TZ
def test_clear_mongo_id():
@@ -532,7 +533,7 @@ async def test_load_latest_data_none_last_data_timestamp(mongo_db):
'name': 'test1',
'value': 1,
'timestamp': datetime.strptime(
'2023-01-01 12:00:00.000000', '%Y-%m-%d %H:%M:%S.%f')
'2023-01-01 12:00:00.000000+0000', DATETIME_FORMAT_MS_WITH_TZ)
}
]
@@ -558,7 +559,7 @@ async def test_load_latest_data_none_last_data_timestamp(mongo_db):
assert result == [{
'name': 'test1',
'value': 1,
'timestamp': '2023-01-01 12:00:00.000000'
'timestamp': '2023-01-01 12:00:00.000000+0000'
}]
@@ -573,7 +574,7 @@ async def test_load_latest_data_not_none_last_data_timestamp(mongo_db):
'name': 'test1',
'value': 1,
'timestamp': datetime.strptime(
'2023-01-01 12:00:00.000000+0000', '%Y-%m-%d %H:%M:%S.%f%z')
'2023-01-01 12:00:00.000000+0000', DATETIME_FORMAT_MS_WITH_TZ)
}
]
@@ -594,7 +595,7 @@ async def test_load_latest_data_not_none_last_data_timestamp(mongo_db):
'level': 'ERROR',
'timestamp': {
'$gt': datetime.strptime(
'2023-01-01 12:00:00.000000+0000', '%Y-%m-%d %H:%M:%S.%f%z')
'2023-01-01 12:00:00.000000+0000', DATETIME_FORMAT_MS_WITH_TZ)
}
},
{"_id": 0}

View File

@@ -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.4"
tag: "0.4.5"
# 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:
@@ -151,7 +151,7 @@ env:
- name: GITHUB_REPO_URL
value: "git@github.com:Aignosi/sientia-dataops-orchestrator_temporal.git"
- name: GITHUB_BRANCH
value: "SIENTIAPDE-1193-conferir-como-a-escrita-de-datetime-ocorre-no-temporal"
value: "SIENTIAPDE-1205-alterar-opc-para-assincrono"
- name: PYTHON_APP
value: "orchestrator.worker.worker"