Feat: Pulumi S3

This commit is contained in:
2026-03-16 10:59:51 -03:00
parent 624f5dc7e6
commit a4d9583821
11 changed files with 74 additions and 157 deletions

View File

@@ -4,9 +4,8 @@ import os
from botocore.exceptions import ClientError
from langfuse import Langfuse
from .config import REGION, TABLE, SECRET_NAME
from .config import REGION, SECRET_NAME
dynamodb = boto3.resource("dynamodb", region_name=REGION)
def get_secret() -> str:
@@ -19,35 +18,9 @@ def get_secret() -> str:
return response["SecretString"]
secrets = json.loads(get_secret())
langfuse = Langfuse(
public_key=secrets["LANGFUSE-PUBLIC-KEY"],
secret_key=secrets["LANGFUSE-SECRET-KEY"],
host=os.environ["LANGFUSE_HOST"],
)
def get_contexto(dashboard: str) -> dict:
"""
Get contexto, filter, and items_disponiveis from DynamoDB for a given dashboard.
Returns:
Dict with 'contexto', 'filter', and 'items_disponiveis' keys
"""
try:
table = dynamodb.Table(TABLE)
response = table.get_item(Key={"id": dashboard + "_contexto"})
if "Item" not in response:
return {"contexto": "", "filter": "", "items_disponiveis": {}}
item = response["Item"]
return {
"contexto": item.get("contexto", ""),
"filter": item.get("filter_key", ""),
"items_disponiveis": item.get("itens_disponiveis", {}),
}
except ClientError as e:
error_message = e.response["Error"]["Message"]
return {"contexto": f"Error: {error_message}", "filter": "", "items_disponiveis": {}}
#secrets = json.loads(get_secret())
#langfuse = Langfuse(
# public_key=secrets["LANGFUSE-PUBLIC-KEY"],
# secret_key=secrets["LANGFUSE-SECRET-KEY"],
# host=os.environ["LANGFUSE_HOST"],
#)