Skip to content

Instantly share code, notes, and snippets.

View Kilo59's full-sized avatar

Gabriel Kilo59

  • North Carolina
  • 18:22 (UTC -04:00)
View GitHub Profile
@Kilo59
Kilo59 / dep_dec_api.py
Last active April 18, 2024 14:52
FastAPI Decorators with Dependencies
"""
pip install fastapi uvicorn
uvicorn dep_dec_api:app --reload
"""
import base64
import enum
import logging
from collections.abc import Mapping
from pprint import pformat as pf
@Kilo59
Kilo59 / update.py
Created March 29, 2024 14:16
GX Update a Datasource
import great_expectations as gx
context = gx.get_context()
my_datasource = context.get_datasource("my_datasource")
print(f"{my_datasource!r}")
# update the connection string (or any other property)
my_datasource.connection_string = "my_protocol://user:password@host/db"
@Kilo59
Kilo59 / add_overrides.py
Last active November 29, 2023 15:35
Add `@override` decoraters
from __future__ import annotations
import pathlib
import sys
from collections import Counter
from pprint import pformat as pf
from typing import Iterable, Iterator, NamedTuple
from mypy import api
from typing_extensions import override
@Kilo59
Kilo59 / custom_sql.py
Last active June 1, 2023 23:41
Custom Datasource
from great_expectations.datasource.fluent import SQLDatasource
import sqlalchemy.engine
from typing import Literal, Optional
class CustomSQLDatasource(SQLDatasource):
type: Literal["my_custom_sql"] = "my_custom_sql"
connection_string: Optional[str] = None # this makes this field optional
some_new_param: dict = {}
@Kilo59
Kilo59 / collisions.ipynb
Created May 30, 2023 12:37
ID Collisions
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@Kilo59
Kilo59 / pydantic_coercion.ipynb
Created May 23, 2023 23:26
Pydantic Type Coercion
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@Kilo59
Kilo59 / Pipfile
Last active December 8, 2022 21:13
gx-pydantic-dc-transform-import-error
[[source]]
url = "https://pypi.org/simple"
verify_ssl = true
name = "pypi"
[packages]
great-expectations = "==0.15.36"
pydantic = "==1.10.2"
typing_extensions = "==4.4.0"
# used to get package versions
@Kilo59
Kilo59 / id_fun.py
Last active August 19, 2022 18:11
Fun with Python id()
# ##############
# at what number does this error?
# 0? 100,000? never?
# ##############
try:
for i, n in enumerate(range(0, 100000)):
assert i is n, f"{i} is {n}"
except AssertionError as e:
print(f"Error on -> {e}")
@Kilo59
Kilo59 / response_hooks.py
Last active February 17, 2023 20:29
Httpx Jokes
import asyncio
import time
import httpx
async def print_joke(r: httpx.Response):
r.raise_for_status()
await r.aread()
value = r.json()["value"]
@Kilo59
Kilo59 / airflow_pipx_install.sh
Last active April 1, 2021 20:03
Install Apache Airflow into a pipx venv with the correct requirements.
# assuming pipx is already installed
# https://pipxproject.github.io/pipx/installation/
# airflow needs a home, ~/airflow is the default,
# but you can lay foundation somewhere else if you prefer
# (optional)
export AIRFLOW_HOME=~/airflow
AIRFLOW_VERSION=2.0.1
PYTHON_VERSION="$(python3 --version | cut -d " " -f 2 | cut -d "." -f 1-2)"