Skip to content

Commit

Permalink
fix imports
Browse files Browse the repository at this point in the history
  • Loading branch information
Hellcassius committed Dec 13, 2023
1 parent 53b5e1d commit c9f22c5
Showing 1 changed file with 18 additions and 11 deletions.
29 changes: 18 additions & 11 deletions pipelines/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,17 +37,24 @@
from pipelines.implicit_ftp import ImplicitFtpTls
from pipelines.constants import constants

from prefeitura_rio.pipelines_utils.prefect import (
log,
get_vault_secret,
send_discord_message,
get_redis_client,
) #TODO: add or relocate imports

from prefeitura_rio.pipelines_utils.logging import log #TODO: add or relocate imports
from prefeitura_rio.pipelines_utils.infisical import get_secret

# Set BD config to run on cloud #
bd.config.from_file = True

def send_discord_message(
message: str,
webhook_url: str,
) -> None:
"""
Sends a message to a Discord channel.
"""
requests.post(
webhook_url,
data={"content": message},
)


def log_critical(message: str, secret_path: str = constants.CRITICAL_SECRET_PATH.value):
"""Logs message to critical discord channel specified
Expand All @@ -58,7 +65,7 @@ def log_critical(message: str, secret_path: str = constants.CRITICAL_SECRET_PATH
Defaults to constants.CRITICAL_SECRETPATH.value.
"""
url = get_vault_secret(secret_path=secret_path)["data"]["url"]
url = get_secret(secret_path=secret_path)["data"]["url"]
return send_discord_message(message=message, webhook_url=url)


Expand Down Expand Up @@ -215,7 +222,7 @@ def connect_ftp(secret_path: str = None, secure: bool = True):
ImplicitFTP_TLS: ftp client
"""

ftp_data = get_vault_secret(secret_path)["data"]
ftp_data = get_secret(secret_path)["data"]
if secure:
ftp_client = ImplicitFtpTls()
else:
Expand Down Expand Up @@ -563,7 +570,7 @@ def get_raw_data_api( # pylint: disable=R0912
if secret_path is None:
headers = secret_path
else:
headers = get_vault_secret(secret_path)["data"]
headers = get_secret(secret_path)["data"]

response = requests.get(
url,
Expand Down Expand Up @@ -684,7 +691,7 @@ def get_raw_data_db(
filetype = "json"

try:
credentials = get_vault_secret(secret_path)["data"]
credentials = get_secret(secret_path)["data"]

with connector_mapping[engine](
host=host,
Expand Down

0 comments on commit c9f22c5

Please sign in to comment.