Skip to content
tezvyn:

Search

Find a bite, explore a topic or look for a role.

Results for Python

Bites 291

Python & FastAPI2 min read

FastAPI `yield` Dependencies for Setup and Teardown

A yield dependency is a context manager for your endpoints. Code before yield runs setup, like getting a DB connection; code after yield runs teardown.

Python & FastAPI2 min read

FastAPI: Use UploadFile for Efficient File Uploads

FastAPI handles file uploads as 'form data', giving you a streamable UploadFile object instead of a raw byte blob. Use this for endpoints like image or document submissions. The footgun is reading large files into memory instead of streaming them.

FastAPI: Returning HTML with HTMLResponse
Python & FastAPI2 min read

FastAPI: Returning HTML with HTMLResponse

Override FastAPI's default JSON output by using HTMLResponse to return a raw HTML string directly from an endpoint. It's for simple status pages or server-side rendered components.

Pydantic Computed Fields: Serialize Derived Values
Python & FastAPI2 min read

Pydantic Computed Fields: Serialize Derived Values

A Pydantic computed field makes a derived value, like an area from width and length, part of your model's serialized output. Use it to include calculated attributes when calling .model_dump().

Python & FastAPI2 min read

Starlette's Request Object: A Clean API for ASGI

Starlette's Request object is a high-level wrapper around the raw ASGI scope, providing a clean API for request data. Use it in endpoints to read headers, query params, or parse the body. The footgun: the request body can only be read once.

Python & FastAPI2 min read

FastAPI: Use HTTPException to Return Client Errors

FastAPI's HTTPException is your tool for stopping an operation and sending a clean HTTP error. Raise it when business logic fails, like a missing database record. The footgun is catching it yourself; just raise it and let FastAPI do the rest.

FastAPI: Set a Response's HTTP Status Code
Python & FastAPI1 min read

FastAPI: Set a Response's HTTP Status Code

In FastAPI, set the success status code in the decorator, not the function. Use status_code=201 in @app.post() to signal resource creation. The common footgun is placing status_code in the function signature instead of the decorator itself.

FastAPI Response Models: Shape Your API's Output
Python & FastAPI2 min read

FastAPI Response Models: Shape Your API's Output

A FastAPI response_model defines your API's output shape, acting as a data filter and automatic documentation generator. Use it to prevent data leaks and provide clear schemas.

Python & FastAPI2 min read

Uvicorn Workers: Scaling Your FastAPI App

Uvicorn workers are like adding cashiers to a store. Instead of one process handling all requests, you run multiple, letting your FastAPI app use all CPU cores to serve more users concurrently.

Path Parameters: Turning URL Parts into Variables
Python & FastAPI2 min read

Path Parameters: Turning URL Parts into Variables

Path parameters turn parts of a URL, like /users/123, into typed function arguments. FastAPI uses this to create endpoints for specific resources, like fetching a user by their ID. The footgun is forgetting type hints; without int, 123 is just a string.

FastAPI Application Instance: Your API's Central Hub
Python & FastAPI2 min read

FastAPI Application Instance: Your API's Central Hub

The FastAPI instance is your API's central switchboard, connecting incoming requests to your code. You create it once (e.g., app = FastAPI()) and use its decorators like @app.get to define all your endpoints. The footgun is creating multiple instances.

package.json: The Blueprint for Your Node.js Project
Node.js & Express2 min read

package.json: The Blueprint for Your Node.js Project

The package.json file is the blueprint for a Node.js project, listing its dependencies and runnable scripts. It's essential for installing libraries (npm install) and running tasks (npm test).

Executable Runbooks: Code, Not Just Checklists
Monitoring & SRE2 min read

Executable Runbooks: Code, Not Just Checklists

An executable runbook turns a procedural document into an automated script. Instead of reading steps, you run them. It's used for incident response or maintenance, ensuring consistency. The footgun is not making them idempotent, which can worsen an outage.

Monitoring & SRE2 min read

Elasticsearch: The Search Engine in the ELK Stack

Elasticsearch is a distributed search engine for querying massive, schema-free JSON datasets via an HTTP API. It's the core of log analysis platforms like the ELK stack, enabling fast search over terabytes of logs.

Monitoring & SRE2 min read

OpenTelemetry SDK: The Engine for Your Telemetry

The OpenTelemetry SDK is the engine that processes and exports your telemetry data. It implements the OTel API, letting you configure how traces and metrics are sampled, batched, and sent to a backend.

Monitoring & SRE2 min read

OpenTelemetry API: The Stable Interface for Your Code

The OpenTelemetry API provides stable interfaces for your code to generate telemetry. This lets you instrument your application once, while the SDK implementation handles the actual data processing and export, which can be swapped out later.

MLOps & Infrastructure2 min read

TensorFlow Serving: A Production Server for ML Models

Think of TensorFlow Serving as a dedicated web server for your ML models. It provides a stable API for inference and manages model versions, abstracting away deployment complexity. The main footgun is thinking it only serves models; it serves any 'Servable'.

MLOps & Infrastructure2 min read

Compute Abstraction Layer: Run Code Anywhere

A Compute Abstraction Layer is a universal adapter for your code, letting you run it on a laptop, cloud GPU, or cluster without changes. It's used in MLOps to scale a script from local debug to production training. The footgun is a leaky abstraction.

MLOps & Infrastructure2 min read

Vertex AI Pipelines: Orchestrating ML Workflows

Think of it as an assembly line for your machine learning models, automating everything from data prep to deployment. Use it to build reproducible, production-grade ML systems on Google Cloud.

Amazon SageMaker Pipelines: Repeatable ML Workflows
MLOps & Infrastructure2 min read

Amazon SageMaker Pipelines: Repeatable ML Workflows

Think of SageMaker Pipelines as a CI/CD pipeline for ML models, automating workflows from data prep to deployment. Use it for reproducible training and automated retraining.