Skip to content

Instantly share code, notes, and snippets.

View flolas's full-sized avatar
🧭

Felipe Lolas flolas

🧭
  • Santiago, Chile
View GitHub Profile
@flolas
flolas / dynamodb_state_persistence.py
Created August 25, 2025 22:50
DynamoDBStatePersistence for pydantic-ai pydantic-graph
from __future__ import annotations
import dataclasses
import json
import logging
import time
from contextlib import asynccontextmanager
from datetime import datetime
from enum import Enum
from typing import Any, AsyncIterator, Generic, List, Optional, TypeVar
@flolas
flolas / chatgpt_llm.py
Last active September 21, 2024 10:33
Working example of Langchain custom LLM for revChatGPT (ChatGPT API)
from langchain.llms.base import BaseLLM
from langchain.schema import Generation, LLMResult
from langchain.utils import get_from_dict_or_env
import asyncio
from revChatGPT.V2 import Chatbot
import nest_asyncio
from retrying_async import retry
from typing import (
Any,
@flolas
flolas / spark_submit_hook.py
Last active December 16, 2021 09:33
Spark Submit Hook with SSH capability. Tested with Airflow 1.10.x and 1.9.x (Python 3)
# -*- coding: utf-8 -*-
#
# Licensed to the Apache Software Foundation (ASF) under one
# or more contributor license agreements. See the NOTICE file
# distributed with this work for additional information
# regarding copyright ownership. The ASF licenses this file
# to you under the Apache License, Version 2.0 (the
# "License"); you may not use this file except in compliance
# with the License. You may obtain a copy of the License at
#
@flolas
flolas / sftp_sensor.py
Last active July 20, 2021 18:39
SFTP Sensor Airflow 1.9.0
# -*- coding: utf-8 -*-
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
def get_slack_on_retry_callback(owners_list):
def retry_callback(context):
from airflow.operators import SlackAPIPostOperator
slack_conf = getVarIfExists("slack_conf", json=True)
message = '[{DS}]\n[{DAG}]\n[{TASK}]\n :warning: La tarea se está reintentando :warning: \n Alerta para {OWNERS} \n -----------'\
.format(
DAG = context['dag'].dag_id,
TASK = context['task'].task_id,
DS = context['ds'],
OWNERS = ' '.join(owners_list)
@flolas
flolas / README.md
Last active August 20, 2018 04:08
Siddhi with Kerberized Kafka Source

Kerberized Kafka with Siddhi

  • krb5-user package with krb.conf
  • crt in JKS
  • valid keytab for renewing token
@flolas
flolas / teradata_hook.sql
Created January 12, 2018 12:55
Teradata Hook for Apache Airflow using PyTd (Teradata Python Module)
# -*- coding: utf-8 -*-
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
@flolas
flolas / index.html
Last active January 3, 2018 15:46
PBI
<!DOCTYPE html>
<html>
<head>
<title>Minimal sample using ADAL.JS</title>
<meta charset="utf-8" />
<script src="https://secure.aadcdn.microsoftonline-p.com/lib/1.0.11/js/adal.min.js"></script>
<script src="powerbi.js"></script>
<script src="https://code.jquery.com/jquery-3.2.1.min.js" integrity="sha256-hwg4gsxgFZhOsEEamdOYGBf13FyQuiTwlAQgxVSNgt4=" crossorigin="anonymous"></script>
<script>window.jQuery || document.write('<script src="js/vendor/jquery-3.2.1.min.js"><\/script>')</script>
</head>
sudo apt-get -y update
sudo apt-get -y install default-jre libc6-i386 libc6-dev-i386 curl unzip vim netcat telnet
sudo useradd james
sudo mkdir /home/james
sudo chown -R james:james /home/james
sudo adduser james sudo
mkdir /opt/james
sudo curl -o /opt/james/james-server-app-3.0.0-app.zip http://www.apache.org/dist/james/server/3.0.0/james-server-app-3.0.0-app.zip
sudo unzip /opt/james/james-server-app-3.0.0-app.zip -d /opt/james
sudo chown -R james:james /opt/james
from airflow.contrib.operators.teradata_operator import TeradataOperator
task = TeradataOperator(sql='query.sql', teradata_conn_id='teradata-prod', task_id='Ejecuta_query_sql', dag=dag)