Skip to content

Instantly share code, notes, and snippets.

@mtanco
mtanco / python_threading_example.py
Created February 3, 2025 18:57
Python Multi-threading Examples: Demonstrates three common patterns - Basic Thread Synchronization, Queue-based Communication, and Modern Thread Pools
"""
Python Multi-threading Examples
-----------------------------
This example demonstrates three common patterns for multi-threading in Python:
1. Basic thread synchronization using Lock
2. Thread communication using Queue
3. Modern thread pools using concurrent.futures
Key concepts demonstrated:
- Thread creation and management
@mtanco
mtanco / h2ogpte_banking_rag_demo.py
Created February 3, 2025 18:08
h2oGPTe Banking RAG Demo - Intelligent Document Processing for Financial Services This demo showcases how to leverage h2oGPTe's powerful RAG capabilities for banking and financial services use cases. It demonstrates: - Automated knowledge base creation from banking documentation - Intelligent Q&A using RAG - Best practices for financial documen…
"""
h2oGPTe Banking RAG Demo
Demonstrates using h2oGPTe for intelligent document processing in financial services
This demo shows how to:
1. Crawl relevant banking documentation
2. Create a knowledge base
3. Perform intelligent Q&A using RAG
"""
@mtanco
mtanco / hello_world.py
Created February 3, 2025 17:48
A classic 'Hello, World!' program in Python. This simple program demonstrates the basic syntax of Python and serves as a traditional first program for learning Python programming. It showcases Python's straightforward and readable syntax by using the print() function to output text to the console.
print("Hello, World!")
@mtanco
mtanco / mlops_throughput.sh
Last active January 23, 2025 00:06
This code uses a running deployment to test throughput in a range of situations. Replicas are changed elsewhere with MLOps UI or API
#!/bin/bash
# Define the base command and endpoint
URL="https://model.dev.h2o.ai/496095fa-d429-4da0-b7d1-8239fe644410/model/score"
BASE_CMD="ab -T \"application/json\" "
TEST_SIZE=500
# Initialize the results table
echo "| Test Size | Batch Size | Replicas | Concurrency | r/s |"
echo "|-----------|------------|----------|-------------|-----|"
# Define test scenarios
@mtanco
mtanco / mlops_throughput.py
Created January 22, 2025 01:08
Some basic testing of throughput for calls in MLOps
import os
import requests
import json
import time
import h2o_authn
import h2o_discovery
import h2o_mlops
import pandas as pd
from h2o_wave import main, app, Q, ui, on, run_on, data
@app('/')
async def serve(q: Q):
print(q.args)
print(q.events)
# First time a browser comes to the app
if not q.client.initialized:
await initialize_client_session(q)
@mtanco
mtanco / export_import.py
Created June 10, 2024 17:13
Download all collection data upload all collection data
import os
from h2ogpte import H2OGPTE
EMAIL = "[email protected]"
client = H2OGPTE(
address='https://playground.h2ogpte.h2o.ai',
api_key='sk-',
)
from h2o_wave import main, app, Q, ui, on, run_on, data
@app('/')
async def serve(q: Q):
print(q.args)
# First time a browser comes to the app
if not q.client.initialized:
await initialize_client_session(q)
@mtanco
mtanco / long_running_tasks.py
Created June 4, 2024 16:02
Wave long running task
from h2o_wave import main, app, Q, ui, on, handle_on
@app('/')
async def serve(q: Q):
# First time a browser comes to the app
if not q.client.initialized:
await init(q)
q.client.initialized = True
@mtanco
mtanco / att.css
Created April 24, 2024 19:02
Example for chatbots, waiting dialogs, and custom CSS
[data-test="header"] {
background: #000000 !important;
}
/* will be used by default for buttons*/
.ms-Button--default {
background-color: #6c757d;
color: #FFFFFF;
border-color: #6c757d;
border-radius: 2rem;
}