---
title: "Python"
description: "252 posts about Python, summarised, each linking to the original."
---

# Python
> 252 posts about Python, summarised, each linking to the original.

## Articles

### [Scaling Nextdoor’s Datastores: Part 3](https://yomu.fyi/post/scaling-nextdoor-s-datastores-part-3.md)
- Company: [Nextdoor](https://yomu.fyi/company/nextdoor.md)
- Author: Ronak Shah
- Published: Mar 19, 2025
- Type: Problem & solution

Look-aside caching with object byte serialization can cause critical compatibility failures when application versions, dependencies, or database schemas change. Serialized cache entries bound to specific runtimes risk deserialization errors during deployments, triggering thundering herd queries against the underlying datastore. To resolve this, Nextdoor replaced runtime-bound serialization like Python pickle with MessagePack to serialize Django model objects. The team achieved forward compatibility by letting MessagePack ignore unrecognized new fields in older application code, while backward compatibility relies on mandatory default values for newly added model attributes. Nextdoor prepends a ten-byte header containing format metadata and version information before writing the serialized payload to cache stores.


### [Scaling Nextdoor’s Datastores: Part 2](https://yomu.fyi/post/scaling-nextdoor-s-datastores-part-2.md)
- Company: [Nextdoor](https://yomu.fyi/company/nextdoor.md)
- Author: Tushar Singla
- Published: Mar 19, 2025
- Type: Problem & solution

Nextdoor encountered scaling issues after adding read replicas when product engineers were initially tasked with deciding whether to route queries to the primary or replica databases. As business logic grew and gained abstraction layers, engineers struggled to track read-after-write consistency constraints across the call stack. To avoid replication lag race conditions, engineers routinely wrapped logic in database transactions, unintentionally directing all queries to the primary node and eroding read replica benefits over several years. The Core-Services team resolved this by injecting custom tracking logic into their Django ORM layer to monitor table writes during web requests and automate routing. They further optimized the system using a timing-based approach that restored replica read eligibility after the p99.9 replication lag elapsed.


### [Scaling Nextdoor’s Datastores: Part 1](https://yomu.fyi/post/scaling-nextdoor-s-datastores-part-1.md)
- Company: [Nextdoor](https://yomu.fyi/company/nextdoor.md)
- Author: Slava Markeyev
- Published: Mar 19, 2025
- Type: Explainer

Nextdoor relies on a Django backend connected to monolithic PostgreSQL databases and Redis look-aside caches. Migrating to distributed SQL datastores proved impractical because legacy business logic depends heavily on multi-table joins that could not be rewritten. Intermediate mitigations, including read replicas and data partitioning by severing foreign keys, extended infrastructure runways but left primary databases vulnerable to load bottlenecks. Furthermore, look-aside caching and replica usage introduced data staleness risks, atomicity losses across partitioned databases, and inconsistent cache-population behaviors. To address these limitations, Nextdoor initiated an architecture redesign focused on dynamic query routing to replicas, replica-driven cache hydration, time-bounded eventual consistency, and schema-resilient cache serialization.


### [Turbo-Charging ML Development](https://yomu.fyi/post/turbo-charging-ml-development.md)
- Company: [Ramp](https://yomu.fyi/company/ramp.md)
- Author: Ryan Stevens, Ryne Carbone
- Published: Feb 10, 2025
- Type: Problem & solution

Ramp describes Turbo, a YAML-based configuration system created to reduce the time and engineering effort required to deploy machine-learning models while preserving reproducibility and explainability. Its abstraction represents end-to-end feature and model pipelines, datasets, and shared train and predict jobs; Python entities and aggregates built with Pydantic are materialized through JobSpec and executed locally or remotely before models are stored. A developer can run a training workflow with a YAML file and a few lines of code, then adapt the same schema for prediction by changing a few configuration lines. The first Credit Risk model required nearly four months and more than 3,000 lines of deployment code; with Turbo, new models deploy in under five minutes using about 40 YAML lines on average. The system also standardizes practices such as holiday alignment in time-series models and supports nearly 20 deployed models built by nine developers.


### [Crush errors with Sandbox testing](https://yomu.fyi/post/crush-errors-with-sandbox-testing.md)
- Company: [Stripe](https://yomu.fyi/company/stripe.md)
- Author: David Edoh-Bedi
- Published: Dec 19, 2024
- Type: Tutorial

Payment integrations can encounter errors caused by external events, such as network issues or outages, or by bugs in application code, and unhandled failures can stall checkout. The post presents Stripe Sandboxes as isolated environments for reproducing live-integration failures without changing live payment settings or traffic, optionally copying settings when a sandbox is created. Developers can use Workbench’s Errors and Logs views to diagnose a card\_declined response, then route test requests through sandbox keys and a test card. On the Python backend, a try/except implementation catches Stripe errors and generic exceptions and returns an error response instead of leaving the payment page stalled. Sandboxes remain separate after creation, but each Stripe account can have at most five, so unused environments may be deleted or have their test data cleared while settings are preserved.


### [Adding payments to your LLM agentic workflows](https://yomu.fyi/post/adding-payments-to-your-llm-agentic-workflows.md)
- Company: [Stripe](https://yomu.fyi/company/stripe.md)
- Author: Steve Kaliski
- Published: Nov 14, 2024
- Type: Explainer

Agentic workflows combine large language models with function calling to turn prompts into sequences of actions, but connecting those actions to financial services requires controlled API access. The Stripe agent toolkit integrates Stripe with Vercel’s AI SDK, LangChain, and CrewAI, supports function-calling LLM providers, and is built on Stripe’s Node.js and Python SDKs. It exposes configurable tools for tasks such as invoicing, creating and sharing payment links, and using Issuing virtual cards with spending limits, authorization checks, and deactivation after purchase. Middleware can record input and completion token counts as billing events for usage-based customer billing. Because agent behavior is non-deterministic, the post recommends test mode, evaluations, restricted keys, limited tool sets, and reduced request and response shapes to improve focus and constrain failures.


### [Leveraging RAG-powered LLMs for analytical tasks](https://yomu.fyi/post/leveraging-rag-powered-llms-for-analytical-tasks.md)
- Company: [Grab](https://yomu.fyi/company/grab.md)
- Author: Edmund Hong
- Published: Oct 9, 2024
- Type: Problem & solution

Data analysts at Grab faced an increasing volume of stakeholder data requests that required manually writing and executing repetitive SQL queries with minor parameter changes. To automate routine tasks like metric reporting and fraud investigations, the Integrity Analytics team paired an internal prompt-management platform, Spellvault, with Data-Arks, an in-house Python-based middleware that packages SQL queries and Python functions into APIs. A scheduler triggers automated report summarization, while an analytical bot named A\* bot executes relevant investigation queries via RAG and returns summarized findings in Slack. Automated report generation saves an estimated three to four hours per report and shortens multi-query fraud investigations to minutes. Grab favored RAG over fine-tuning because it avoids continuous retraining costs, scales faster across diverse use cases, and surfaces current production data.


### [Improving Retrieval on Ramp with Transaction Embeddings](https://yomu.fyi/post/improving-retrieval-on-ramp-with-transaction-embeddings.md)
- Company: [Ramp](https://yomu.fyi/company/ramp.md)
- Author: Calix Huang, Anton Biryukov
- Published: Aug 13, 2024
- Type: Problem & solution

Ramp developed transaction embeddings to help automate accounting coding, where employees choose general ledger (GL) categories for transactions. The model represents enriched transaction features—such as merchant, category, department, location, amount, memo, spend program, and trip—as stringified documents labeled with chart-of-accounts codes. Starting from a pre-trained encoder, it is fine-tuned with sentence-transformers and BatchSemiHardTripletLoss, using large batches and contextual sampling to learn embeddings whose similarity is measured with cosine similarity. Triplet loss pulls same-label transactions together and pushes different-label examples apart, while informed mining addresses subtle distinctions such as Travel: Sales versus Travel: Engineering. The embeddings support GL coding suggestions, high-confidence defaults, business-spend similarity analysis, and transaction context for LLM-enabled features, with the stated aim of keeping predictions personalized and data private.


### [Picture This: Open Source AI for Image Description](https://yomu.fyi/post/picture-this-open-source-ai-for-image-description.md)
- Company: [Fly.io](https://yomu.fyi/company/fly-io.md)
- Published: May 9, 2024
- Type: Tutorial

Nolan Darilek presents a self-hosted image-description service intended to help blind screen-reader users understand photos, diagrams, menus, and other visual material. Humans often provide inadequate alt text, and the post contrasts that history with increasingly capable LLM-generated descriptions from apps and browser add-ons. The implementation combines Ollama, running the Apache-licensed LLaVA 34B multimodal model, with a PocketBase API over SQLite and a small Python client; collection hooks send images and follow-up questions, retain chat history, and enforce per-user access rules. In testing, a cold request on an A100-40GB Fly Machine took about 45 seconds, while stopping idle GPU Machines reduced resource use at the cost of startup delay. The example produced useful scene descriptions but could not reliably identify leafless tree species, illustrating both the prototype’s value and its limitations.


### [Grab Experiment Decision Engine - a Unified Toolkit for Experimentation](https://yomu.fyi/post/grab-experiment-decision-engine-a-unified-toolkit-for-experimentation.md)
- Company: [Grab](https://yomu.fyi/company/grab.md)
- Author: Ruike Zhang
- Published: Apr 9, 2024
- Type: Problem & solution

Grab's Experimentation platform tests thousands of experimental variants weekly, but analyses were largely handled manually using disparate tools unsuited to multi-sided marketplace nuances. To standardize workflows and eliminate reliability issues, Grab developed the GrabX Decision Engine, an internally open-sourced Python toolkit integrated with its Automated Experiment Analysis application. The framework includes a Trusted Advisor component that automates power analysis and sample size estimation while adjusting for clustered standard errors across metric data types. It also bundles a post-experiment statistical toolbox executing default and custom evaluations, ranging from non-parametric tests to regression models that control for confounders and fixed effects. This unified platform institutionalizes experimentation best practices across teams, streamlining collaboration and ensuring consistent statistical inference.


### [Increasing velocity by modernizing a Python codebase](https://yomu.fyi/post/increasing-velocity-by-modernizing-a-python-codebase.md)
- Company: [Ramp](https://yomu.fyi/company/ramp.md)
- Author: Peyton McCullough
- Published: Feb 27, 2024
- Type: Problem & solution

An expanding monorepo of machine learning workflows became difficult to change safely as contributors and projects multiplied, undermining the velocity it was intended to support. The team replaced requirements.txt with Poetry, using pyproject.toml for direct dependencies and poetry.lock to record transitive dependencies and hashes, while virtual environments simplified setup. Ruff standardized formatting, linting, and CI enforcement; pytest addressed corner cases and bad assumptions, and mypy added annotations and stricter checks that could expose incompatible changes across call sites. To adopt these controls incrementally, the team used ignore comments and staged remediation, including a script for mypy exceptions, while an ignored revision preserved useful git blame history. The resulting codebase was kept in better shape, enabling faster iteration with greater confidence.


### [Deploy Your Own (Not) Midjourney Bot on Fly GPUs](https://yomu.fyi/post/deploy-your-own-not-midjourney-bot-on-fly-gpus.md)
- Company: [Fly.io](https://yomu.fyi/company/fly-io.md)
- Published: Jan 4, 2024
- Type: Tutorial

This tutorial builds a Discord image-generation bot that uses Fooocus, an open-source interface for Stable Diffusion, to provide a Midjourney-like /imagine command. It separates the system into a normal Fly Machine running a Python Pycord bot and a GPU Machine running Fooocus-API, with Flycast connecting them over Fly.io’s private network. The bot defers Discord responses, polls for the generated image each second, and uploads the resulting file, while the post notes that this blocking flow will not perform well for hundreds of simultaneous users. Fly GPU rootfs supports the nearly 12GB image, and an L40S setup costs about $3.20/hr when running, with scale-to-zero intended to avoid charges for unused compute. GPU activity is verified with nvidia-smi, and the source code can be extended with additional commands and image-to-image features.


### [How I Built an Okta Documentation Chatbot in Python](https://yomu.fyi/post/how-i-built-an-okta-documentation-chatbot-in-python.md)
- Company: [Okta](https://yomu.fyi/company/okta.md)
- Author: Tanish Kumar
- Published: Dec 20, 2023
- Type: Tutorial

Okta developer documentation contains information developers need for integrations, but the author observed that it was underused. They built Oktanaut, a Python chatbot in Jupyter Notebook, comparing a LlamaIndex-based prototype trained on Okta documentation with a GPT-3.5-powered version using the OpenAI API. The first favored precision for focused questions, while the second handled a broader range; the final demo used OpenAI API for its larger models and user-friendly experience. For both versions, the author curated questions, answers, and support engineer information, stored training data in Google Drive for Colab, and retained historical interactions so replies could use session context. Panel provided the frontend, and the author chose Jupyter Notebook for simple setup despite noting bugs and glitches.


### [How to Use pgvector for Similarity Search on Heroku Postgres](https://yomu.fyi/post/how-to-use-pgvector-for-similarity-search-on-heroku-postgres.md)
- Company: [Heroku](https://yomu.fyi/company/heroku.md)
- Author: Valerie Woolard
- Published: Nov 16, 2023
- Type: Tutorial

Heroku Postgres now supports pgvector on all Standard-tier or higher databases running Postgres 15, adding vector storage and functions for similarity search and machine-learning applications. Older Postgres versions require an upgrade to Postgres 15. The workflow generates embeddings, adds a VECTOR(100) column, and stores values using SQL or Python with psycopg, pgvector-python, and Wikipedia2Vec’s pretrained 100-dimensional model. Queries can rank vectors with Euclidean, cosine, or inner-product distance; the example uses <-> to return five animals nearest to shark, producing crocodile, dolphin, whale, turtle, and alligator. Results depend on the embedding model and corpus, while indexes introduce approximate nearest-neighbor search; pgvector supports IVFFlat and HNSW, with IVFFlat requiring table data for better recall.


### [Transcribing on Fly GPU Machines](https://yomu.fyi/post/transcribing-on-fly-gpu-machines.md)
- Company: [Fly.io](https://yomu.fyi/company/fly-io.md)
- Published: Nov 13, 2023
- Type: Tutorial

Fly GPU Machines are used to run Whisper Webservice for audio transcription, with the post noting that Fly GPUs are deprecated and unavailable after August 1. The setup uses a GPU-friendly Docker image, an a100-pcie-40gb Machine, and a Fly Volume mounted at /root/.cache/whisper so model files download and persist outside the image; ASR\_MODEL=large and ASR\_ENGINE=faster\_whisper configure the service. It shows flyctl commands for creating the app, GPU-hosted volume, Machine, public IPs, and HTTPS routes, then verifies GPU availability with nvidia-smi and exposes the web UI and OpenAPI specification. A second path automates volume and Machine creation through the Machines API, requiring cpu\_kind plus valid cpus and memory\_mb values. It also demonstrates a custom Ubuntu 22.04 image with NVIDIA CUDA libraries, FFmpeg, Python, and Whisper, concluding that GPU Machines can support composable AI workloads.


### [Supabase Beta July 2023](https://yomu.fyi/post/supabase-beta-july-2023.md)
- Company: [Supabase](https://yomu.fyi/company/supabase.md)
- Author: ant\_wilson
- Published: Aug 2, 2023
- Type: Announcement

Supabase’s July 2023 update lists product releases, community content, and preparations for Launch Week 8, which was scheduled to begin the following week. The shipped changes include a new Android Kotlin client library, Login with Figma as an OAuth provider, Resend support as a custom SMTP provider, pgsodium 3.1.8, and PostgREST 11.1. A performance benchmark examines pgvector 0.4.0’s strengths and limitations, while noting that work on HNSW had started and was not far away. The update also features a Snowflake natural-language query application built with Python, Streamlit, Open AI, and Supabase Vector, plus tutorials, courses, community projects, and hiring announcements.


### [Supporting Devs Through Advocacy](https://yomu.fyi/post/supporting-devs-through-advocacy.md)
- Company: [Okta](https://yomu.fyi/company/okta.md)
- Author: Semona Igama
- Published: Jun 6, 2023
- Type: Announcement

Semona describes her transition from Okta Developer Support Engineer to Developer Advocate after three years supporting admins, developers, Independent Software Vendors, and partners integrating with Okta workforce products. Her earlier work included OpenID Connect, OAuth 2.0, external and social identity providers, SCIM, OIN App Submission, Okta SDKs, the Okta Sign-in Widget, Token Inline Hooks, and Terraform, while cross-functional alliances connected her with Customer Success, Product, Engineering, Solutions Engineering, and Architects. She saw support cases as a way to understand developer problems and collect feedback that could inform improvements. In advocacy, she plans to use that experience to help developers avoid common problems, build community, learn with developers, and advocate for Okta developer community needs, with Python as her favorite programming language.


### [Python Async Workers on Fly Machines](https://yomu.fyi/post/python-async-workers-on-fly-machines.md)
- Company: [Fly.io](https://yomu.fyi/company/fly-io.md)
- Published: May 31, 2023
- Type: Tutorial

A Python web app needed to build and install libraries without blocking HTTP requests or risking backend failures when resource-heavy builds overlapped. The initial backend implementation sometimes ran for more than 30 minutes and could kill the backend, while always-on Celery workers left capacity idle. The proposed proof of concept stores job parameters in Redis, starts a Fly Machine through the Machines API with Redis key environment variables, executes a Python function, and writes the result back. A status endpoint polls the Machine state and returns PENDING until completion, after which cleanup deletes the Machine and Redis entries. The design pays for worker resources only during jobs, but the example requires JSON-serializable arguments and results and is presented as a simple implementation rather than a full job system.


### [Supabase Vecs: a vector client for Postgres](https://yomu.fyi/post/supabase-vecs-a-vector-client-for-postgres.md)
- Company: [Supabase](https://yomu.fyi/company/supabase.md)
- Author: oli\_rice
- Published: May 29, 2023
- Type: Announcement

Vecs is a new Python library for managing embeddings in Postgres databases that use pgvector, offering a vector-store-like interface for table creation, indexing, querying, and metadata filtering. Collections are stored in a vecs schema with an id text primary key, a vector column, and JSONB metadata; queries support cosine distance, l2 distance, and maximum inner dot product, with optional filters and returned values. A short Python workflow can create a collection, upsert records, create an index after insertion, and search by vector; the collection can also be queried without an index. With Supabase, a collection can be exposed through a public-schema view and accessed from supabase-js, while proposed preprocessing transforms and an asynchronous client remain under debate.


### [ChatGPT plugins now support Postgres & Supabase](https://yomu.fyi/post/chatgpt-plugins-now-support-postgres-supabase.md)
- Company: [Supabase](https://yomu.fyi/company/supabase.md)
- Author: egor\_romanov,paul\_copplestone
- Published: May 25, 2023
- Type: Tutorial

Retrieval plugins let ChatGPT access relevant content from private datasets by chunking documents, generating embeddings with OpenAI’s text-embedding-ada-002, and querying a vector database. The article describes Postgres and Supabase datastore implementations using pgvector, with a shared documents schema and a match\_page\_sections function that filters by source, author, document, and date before ranking vectors with inner product distance. It then gives a local example: downloading the Postgres 15 documentation as a PDF, uploading it through the plugin’s /upsert-file endpoint, and configuring environment variables for Supabase or Postgres. The example produced 7,904 document records, and an optional IVFFlat index can trade exact nearest-neighbor search for approximate search; after registering the local plugin in ChatGPT, users can ask questions answered from the documentation.


[Newer posts](https://yomu.fyi/topic/python/page/7.md) · [Older posts](https://yomu.fyi/topic/python/page/9.md)
