Skip to content

Instantly share code, notes, and snippets.

View jaeyow's full-sized avatar

JO Reyes jaeyow

View GitHub Profile
@jaeyow
jaeyow / build-table-schema-index.py
Created July 4, 2024 01:57
Snippets for the Candle Glow e-commerce Text2SQL
table_node_mapping = SQLTableNodeMapping(sql_database)
table_schema_objs = []
for table_name, table_description in all_tables:
table_schema_objs.append(
SQLTableSchema(table_name=table_name, context_str=table_description))
print(table_node_mapping)
print(table_schema_objs)
table_node_mapping = SQLTableNodeMapping(sql_database)
table_schema_objs = []
for table_name, table_description in all_tables:
table_schema_objs.append(
SQLTableSchema(table_name=table_name, context_str=table_description))
print(table_node_mapping)
print(table_schema_objs)
@jaeyow
jaeyow / recommender.py
Created July 30, 2023 11:21
Metaflow step that deploys the best model using AWS SAM
@step
def deploy_best_model(self):
"""
Deploy the best model to AWS Lambda using SAM CLI
"""
try:
AWS_REGION = "ap-southeast-2"
BASE_PATH = "sam"
PROFILE_NAME = "Cevo-Dev.AWSFullAccountAdmin"
BEST_MODEL = self.MODEL_PKL_FILENAME
@jaeyow
jaeyow / .gitconfig
Created May 23, 2023 11:50
My Favourite git aliases
[alias]
# one-line log
l = log --pretty=format:"%C(yellow)%h\\ %ad%Cred%d\\ %Creset%s%Cblue\\ [%cn]" --decorate --date=short
a = add
ap = add -p
c = commit --verbose
ca = commit -a --verbose
cm = commit -m
cam = commit -a -m
m = commit --amend --verbose
import boto3
from generators.generate_items_and_interactions_personalize import generate_user_items
bucket = "cevo-shopping-demo"
products_filename = "./generators/items.csv"
generate_user_items()
boto3.Session(profile_name=<aws-profile-replace-me>, region_name="ap-southeast-2").resource(
"s3"
import boto3
from generators.generate_items_and_interactions_personalize import generate_interactions
bucket = "cevo-shopping-demo"
interactions_filename = "./generators/interactions.csv"
generate_interactions()
boto3.Session(profile_name=<aws-profile-replace-me>, region_name="ap-southeast-2").resource(
"s3"
import pandas as pd
import boto3
from generators.generate_users_json import generate_users_json
bucket = "cevo-shopping-demo"
users_filename = "./generators/users.csv"
generate_users_json()
boto3.Session(profile_name=<aws-profile-replace-me>, region_name="ap-southeast-2").resource(
@jaeyow
jaeyow / getCustomLabelsOfImage.py
Last active March 7, 2023 03:18
python method to call an Amazon Rekognition Custom Labels label detection
def getCustomLabelsOfImage(model_arn, bucket_name, image):
# Use boto3 call detect_custom_labels API call to get Rekognition Custom Labels
client = boto3.client("rekognition")
response = client.detect_custom_labels(
ProjectVersionArn=model_arn,
Image={"S3Object": {"Bucket": bucket_name, "Name": image}},
MinConfidence=98,
)
return response["CustomLabels"]