How to Move Independent Work Through an asyncio Pipeline
A practical asyncio workflow for moving independent work through typed events, queues, concurrent tasks, and awaited API calls. Learn where validation and fallback belong.
Loading…
Topic
252 posts about Python. Every summary links to the original.
See the idea
A practical asyncio workflow for moving independent work through typed events, queues, concurrent tasks, and awaited API calls. Learn where validation and fallback belong.
The Good Stuff
Paid picks we use ourselves. Links carry a referral code — a subscription through one earns us a commission at no extra cost to you.
Newest first
Integrating Sentry into systems already instrumented with OpenTelemetry does not require replacing existing backend SDKs or rewriting service instrumentation. A hybrid architecture pairs the Sentry SDK on the frontend for browser tracing, Session Replay, and logs with existing OpenTelemetry configurations across backend services. Frontend requests propagate W3C traceparent headers to backend endpoints, which then export traces and logs over OTLP directly to Sentry endpoints or through an intermediate OpenTelemetry Collector. Ingested telemetry attaches backend spans and standard Python logs to the initial frontend user actions, establishing a unified distributed trace across the entire request path. Although Sentry's OTLP ingest currently supports logs and traces rather than metrics, dedicated backend Sentry SDKs remain an optional addition later for backend exception tracking and profiling.
Apache Spark’s Pandas UDFs improve Python UDF throughput through Arrow-based serialization and batching, but Pandas/Arrow conversion can add copies, limit zero-copy behavior, and weaken support for complex datatypes. Native Arrow UDFs, introduced in Databricks Runtime 18.0, operate directly on Arrow data without converting inputs to Pandas or NumPy objects, preserving columnar layout and enabling vectorized processing through Arrow’s compute and memory model. The new @arrow_udf decorator supports scalar, aggregate, and table functions, while type-hinted @udf definitions, mapInArrow, and applyInArrow extend the interface to DataFrame and grouped operations; iterator-based modes can amortize initialization costs. In a comparison, an Arrow UDF ran about 10% faster than a Pandas UDF and used about 40% less memory, with better complex-datatype support.
MemEx addresses the context-window bottleneck in LLM agents, where large tool outputs persist in the shared prompt even when later steps need only a small portion. It gives the agent a persistent, typed Python kernel: tool results remain as objects in scope, code can filter, summarize, and compose them, and only printed values are materialized as context tokens. MemEx preserves existing Tool Calling schemas while adding typed submit(), persistent state, backend-agnostic execution, and asynchronous spawn_agent() sub-agents, enabling multi-step workflows and parallel trajectory analysis. Across nine-model evaluations on OfficeQA Pro and Enterprise Structured Retrieval, it was reported as better and cheaper than parallel structured Tool Calling; examples include roughly 10-point OfficeQA gains for some models and Qwen structured-retrieval accuracy rising from 18% to 36% and 20% to 38% at lower token cost.
amazon.science
Enterprise applications rely on mature large language model prompts that incorporate intricate business logic and regulatory constraints, making further optimization and cross-model migration challenging. Promptimus automates prompt refinement through a four-step iterative loop that evaluates candidate prompts against decomposed metric checkpoints, diagnoses failure bottlenecks, and generates targeted improvement strategies. The system operates either via full prompt rewrites in standard mode or through surgical, programmatic find-and-replace edits in edit mode to preserve structured taxonomies and schemas. Tested across multimodal classification and code generation tasks, the framework achieves performance gains with small development datasets of 20 to 50 samples. Amazon is making the model-agnostic optimization system available through Amazon Bedrock to support enterprise generative-AI model migration without manual engineering.
DeepInfra is now a supported Inference Provider on the Hugging Face Hub, adding its serverless inference platform and catalog of more than 100 models to model pages and client integrations. The initial integration supports conversational and text-generation tasks, with access to open-weight LLMs including DeepSeek V4, Kimi-K2.6, and GLM-5.1; support for text-to-image, text-to-video, embeddings, and other tasks will roll out soon. Users can configure provider API keys and preferences in account settings, or authenticate with a Hugging Face token so requests are routed through Hugging Face, including from the Python and JavaScript SDKs and supported agent harnesses. Direct requests are billed by the provider, while routed requests use standard provider API rates without additional markup, and Hugging Face PRO users receive $2 of monthly Inference credits.
The article presents three web applications built around OpenAI’s open-source Privacy Filter, a PII detector that labels eight categories in one forward pass over a 128k-token context. Document Privacy Explorer extracts PDF or DOCX text and returns category-labeled spans, while Image Anonymizer combines Tesseract word boxes with character offsets to produce editable pixel redaction rectangles. SmartRedact Paste replaces detected spans with category placeholders, stores public and token-gated views, and evicts expired pastes in a daemon thread. Across the apps, gradio.Server’s @server.api routes model work through Gradio’s queue and gradio_client, while plain FastAPI routes serve custom HTML, views, and lightweight lookups. The implementations keep browser-side filtering, canvas edits, and PNG export out of server round-trips, and the paste service is about 200 lines including storage.
Shopify built a tool-calling agent for Sidekick that converts natural-language requests into Shopify Flow workflows, addressing the cold-start problem by working backward from thousands of anonymized production workflows. The team generated synthetic queries and tool trajectories, fine-tuned Qwen3-32B, and changed Flow’s nested JSON DSL into an equivalent Python representation connected by a round-trip transpiler. Using Python improved syntactic correctness by 22 points and semantic correctness by 13 points on a 300-example benchmark, while matching production tool names, ordering, responses, and prompts proved essential to avoid degradation. Production evaluation exposed a 35% gap masked by benchmark parity, so Shopify built a weekly feedback loop that scores conversations, filters training data, identifies slice gaps, retrains, and deploys. The resulting agent serves most production traffic, runs 2.2 times faster at 68% lower cost, and outperforms closed models.
Yelp maintains two major applications across Web, iOS, and Android, which previously led to fragmented server-driven UI implementations with mismatched backend component representations. To unify its server-driven UI framework, CHAOS, with its cross-platform design system, Cookbook, Yelp built an automated bridge library called Konbini. Konbini reads centralized JSON interface definitions through Jenkins pipelines to automatically generate synchronized libraries for Python, Kotlin, Swift, and TypeScript. These generated libraries handle component serialization on the backend and deserialization on client platforms. To maintain backward compatibility when component interfaces introduce breaking changes, client requests pass versioned spec identifiers, prompting the backend to execute migration methods that downcast newer component models to older supported versions.
Sentence Transformers provides a Python library for training and using embedding and reranker models across text, images, audio, and video in retrieval and semantic search applications. The post shows how to finetune multimodal models on task-specific data, using Visual Document Retrieval as the example: matching text queries with document page images while preserving charts, tables, and layout. It describes the SentenceTransformerTrainer pipeline, model and processor configuration, dataset handling, and alternative Router-based encoders, while also covering multimodal reranker training with BinaryCrossEntropyLoss and direction-specific datasets. On its evaluation data, finetuning Qwen/Qwen3-VL-Embedding-2B raised NDCG@10 from 0.888 to 0.947 and outperformed all tested VDR models, including models up to 4x its size.
The Google Cloud AI Agent Bake-Off is presented as a test of building autonomous agents under severe time constraints for e-commerce, banking modernization, and startup go-to-market problems. Its five patterns recommend decomposing monolithic prompts into specialized sub-agents under a supervisor, designing modularly because model capabilities can quickly replace custom harnesses, and treating multimodality as native. It also advocates open protocols—including MCP, A2A, UCP, AP2, A2UI, and AG-UI—for agent and tool connections instead of bespoke wrappers. Finally, it separates probabilistic reasoning from execution: strict JSON schemas such as Pydantic validate LLM outputs before deterministic Python functions or SQL perform calculations and writes. The stated conclusion is that reliable production agents depend on rigorous software architecture rather than elaborate prompts or flashy single-shot demos.
Sentence Transformers v5.4 adds multimodal embedding and reranking support for text, images, audio, and video through its Python API. Embedding models map modalities into a shared space, while multimodal Cross Encoder rerankers score relevance for mixed-modality pairs, enabling cross-modal similarity, retrieval, and multimodal RAG workflows. The guide shows model loading, URL-based image encoding, encode_query() and encode_document() prompt handling, similarity calculation, and ranking, with a Qwen3-VL-Embedding-2B example producing 2,048-dimensional image vectors and matching text queries to images. It notes that cross-modal scores can be lower because of the modality gap, while relative ordering can still support retrieval, and that rerankers generally offer higher quality at the cost of slower per-pair processing; installation extras and GPU memory requirements vary by modality and model.
gradio.Server enables applications built with React, Svelte, or plain HTML/JavaScript to use Gradio’s backend facilities instead of Gradio components. The post demonstrates this with Text Behind Image, whose browser UI layers a background, styled text, and a transparent foreground produced by BiRefNet, then exports a PNG client-side. A roughly 50-line Python backend extends FastAPI, exposes a standard HTML route, and defines an @app.api("remove_background") endpoint; @spaces.GPU handles ZeroGPU allocation while Gradio supplies queuing, concurrency control, SSE streaming, and gradio_client compatibility. The frontend calls the endpoint through the Gradio JavaScript client, so image-processing requests pass through the queue while rendering and compositing remain in the browser. The result is a custom frontend that retains Spaces hosting and Gradio infrastructure.
The official ClickHouse Python client, clickhouse-connect, originally addressed asynchronous execution by wrapping its synchronous HTTP client in a thread pool executor. However, this executor model experienced thread exhaustion, GIL contention, and severe tail latency variance under heavy concurrent workloads. To resolve these scalability bottlenecks, the developers redesigned the client around a half-sync/half-async pattern utilizing aiohttp for async network I/O. A custom bounded queue bridges streaming socket reads on the event loop with synchronous, CPU-intensive binary parsing running inside background threads. Benchmarks demonstrate that this architecture stabilizes tail latencies, delivering an average P95 latency of 556 milliseconds compared to 869 milliseconds for the legacy executor client.
chDB 4 introduces Data Store, a native component that allows users to write Pandas-like code that executes on the ClickHouse OLAP SQL engine. Standard Pandas workflows suffer from eager execution, excessive memory materialization, and lack of automatic query optimizations. To solve this, Data Store implements a four-layer architecture that lazily records operations as a chain of LazyOp objects and compiles them into optimized ClickHouse SQL plans upon evaluation triggers. When encountering operations unsupported by ClickHouse, the QueryPlanner splits the pipeline into segments, routing tasks between ClickHouse and Pandas while using Python's memoryview to minimize data copying overhead. This release also integrates natively into Hex notebooks.
Hugging Face introduces Storage Buckets as a mutable, S3-like object storage layer on the Hub for intermediate machine-learning artifacts such as checkpoints, optimizer states, processed shards, logs, and traces. Unlike versioned Models and Datasets repositories, Buckets support frequent writes, overwrites, directory synchronization, and cleanup while retaining standard Hub permissions and public or private visibility. Built on Xet, they chunk and deduplicate content across files, reducing repeated bytes, bandwidth, transfer time, and, for Enterprise customers, billed storage. The CLI and Python APIs support creation, syncing, dry runs, plans, inspection, individual file operations, and programmatic workflows; HfFileSystem and fsspec also allow compatible libraries to read and write through hf:// paths. Pre-warming can place hot data near AWS or GCP compute, while roadmap work aims to connect Buckets directly with versioned repos.
Modular Diffusers introduces a composable alternative to Diffusers’ existing DiffusionPipeline for building diffusion workflows from reusable blocks. A ModularPipeline can load a workflow definition, load model components separately with settings such as bfloat16, and preserve the familiar inference API, while blocks for text encoding, image encoding, denoising, and decoding can be inspected, run independently, or rearranged. Custom Python blocks declare components, inputs, outputs, and computation logic; the example adds a Depth Anything V2 depth processor to a Qwen Image ControlNet workflow, with data flowing between compatible blocks. Blocks and complete pipelines can be published to the Hub, and Mellon can generate node interfaces from their consistent definitions. The post presents the system as an early, flexible direction and says Mellon is not ready for production use.
The post presents a workflow for fine-tuning the LiquidAI/LFM2.5-1.2B-Instruct small language model with Unsloth on Hugging Face Jobs, including optional use of Claude Code, Codex, or another coding agent. It explains that Unsloth is described as providing about 2x faster training and 60% lower VRAM use than standard methods, while the model runs under 1GB of memory and is optimized for on-device deployment. The tutorial covers claiming free Hugging Face Jobs credits through the Unsloth Jobs Explorers organization, installing the hf CLI or a model-training skill, and submitting a job with a dataset, GPU flavor, timeout, and output repository. An agent can generate a UV training script using 4-bit loading and LoRA, submit the managed cloud-GPU job, report Trackio monitoring details, and push the trained model to the Hugging Face Hub.
The post presents Gradio 6’s gr.HTML as a way to build interactive web components in a single Python file, combining custom HTML templates, scoped CSS, and JavaScript interactivity without a separate build step. It describes applications including a Pomodoro timer, contribution heatmap, Kanban board, spinning wheel, and machine-learning viewers for detection, 3D camera control, and speech transcription. Within the component API, ${value} injects Python state into the template, props.value updates that state from JavaScript, and trigger('change') synchronizes it back to Python; CSS keyframes and native HTML5 drag events supply richer behavior. For reuse, a gr.HTML subclass packages the templates and script so the result can be used like built-in Gradio components, while reload mode and Spaces deployment support rapid iteration from generated code to a live app.
Traditional movie search mechanisms depend on coarse filters such as genre, actor, or title, which fail to capture emotional context and narrative nuances. This guide demonstrates building a mood-based semantic recommendation system by combining the voyage-4-nano open-weights embedding model, Hugging Face datasets, and MongoDB Atlas Vector Search. The architecture uses Sentence Transformers to generate embeddings and exposes an endpoint through FastAPI to match user moods against movie plots. Truncating the Matryoshka embeddings from 2048 to 1024 dimensions balances semantic retrieval quality, storage footprint, and query latency. Testing shows that while abstract emotional queries return moderate similarity scores around 0.62 to 0.67, concrete descriptive queries exceed 0.75 without requiring exact keyword matches.
Building AI applications that connect multiple models and APIs often results in fragile scripts or requires complex production orchestration tools. To address rapid experimentation needs, Daggr introduces an open-source Python library created by the Gradio team for chaining AI workflows programmatically. Developers define workflows in Python code using components like GradioNode, FnNode, and InferenceNode, which automatically generate an interactive visual canvas served on port 7860. The interface allows users to inspect intermediate outputs, modify inputs, rerun individual pipeline steps without complete re-execution, and maintain persistent state across workspaces called sheets. Currently in beta, Daggr supports local execution with automatic fallback to remote APIs and integrates directly with Hugging Face Spaces.
The best engineering reads, once a week.