SIENTIAPDE-1350: Configure cleanup test script and improve test isolation. This commit configures the cleanup test script to load environment variables from a .env file and use them for Temporal connection. It also adds a fixture to clean up temporary directories created by tests, ensuring better test isolation and preventing potential conflicts. Additionally, it adds the 'uri' property to the MongoDB config.
This commit is contained in:
@@ -15,7 +15,8 @@ import os
|
||||
import sys
|
||||
from datetime import timedelta
|
||||
from typing import Any
|
||||
|
||||
from dotenv import load_dotenv
|
||||
from pathlib import Path
|
||||
from temporalio.client import Client
|
||||
|
||||
# Ensure project root is on PYTHONPATH when running directly
|
||||
@@ -23,7 +24,14 @@ ROOT_DIR = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))
|
||||
if ROOT_DIR not in sys.path:
|
||||
sys.path.insert(0, ROOT_DIR)
|
||||
|
||||
from model_manager.workflows.cleanup_files import CleanupFiles # noqa: E402
|
||||
from model_manager.workflows.cleanup_files import CleanupFiles
|
||||
|
||||
|
||||
# Carrega variáveis de ambiente do arquivo .env na raiz do projeto
|
||||
PROJECT_ROOT = Path(__file__).resolve().parent.parent
|
||||
ENV_PATH = PROJECT_ROOT / '.env'
|
||||
if ENV_PATH.exists():
|
||||
load_dotenv(dotenv_path=ENV_PATH)
|
||||
|
||||
|
||||
async def main(argv: list[str]) -> None:
|
||||
@@ -34,11 +42,11 @@ async def main(argv: list[str]) -> None:
|
||||
"""
|
||||
|
||||
# Config from environment / defaults
|
||||
temporal_host = os.getenv('TEMPORAL_HOST', 'localhost:37463')
|
||||
temporal_namespace = os.getenv('TEMPORAL_NAMESPACE', 'model-manager')
|
||||
task_queue = 'cleanup-queue'
|
||||
|
||||
default_bucket = os.getenv('DEFAULT_CLEANUP_BUCKET', 'model-training')
|
||||
temporal_host = os.getenv('TEMPORAL_HOST')
|
||||
temporal_namespace = os.getenv('TEMPORAL_NAMESPACE')
|
||||
task_queue = os.getenv('CLEANUP_TASK_QUEUE')
|
||||
default_bucket = os.getenv('DEFAULT_CLEANUP_BUCKET')
|
||||
use_tls = os.getenv('TEMPORAL_USE_TLS', 'false').lower() == 'true'
|
||||
|
||||
# Optional CLI: bucket name override
|
||||
bucket_name = default_bucket
|
||||
@@ -46,7 +54,11 @@ async def main(argv: list[str]) -> None:
|
||||
bucket_name = argv[0]
|
||||
|
||||
print(f"Connecting to Temporal at {temporal_host} (namespace={temporal_namespace})...")
|
||||
client = await Client.connect(temporal_host, namespace=temporal_namespace)
|
||||
client = await Client.connect(
|
||||
target_host=temporal_host,
|
||||
namespace=temporal_namespace,
|
||||
tls=use_tls,
|
||||
)
|
||||
|
||||
input_data: dict[str, Any] = {
|
||||
'bucket_name': bucket_name,
|
||||
|
||||
Reference in New Issue
Block a user