portal-data-connectors

Implement async Parquet extractors with threadpool offloading, TTL caching, and typed silo errors.

Updated Jul 27, 2026
One-click install
npx skills add https://github.com/ArthurZizumbo/karisma-data --skill portal-data-connectors-arthurzizumbo
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: portal-data-connectors
Source: https://github.com/ArthurZizumbo/karisma-data/tree/main/.claude/skills/portal-data-connectors
Command: npx skills add https://github.com/ArthurZizumbo/karisma-data --skill portal-data-connectors-arthurzizumbo

SYSTEM DOCUMENTATION & REQUIREMENTS

💡 This Skill requires polars, structlog, pydantic, pytest-asyncio.

What problem does it solve? Reading financial Parquet silos (creditos, liquidez, derivados) synchronously blocks the async event loop, and a single failing silo can crash the entire service. This Skill provides the patterns to build non-blocking, fault-isolated data connectors. ## Core Features & Use Cases - Async Parquet Extraction: Offload Polars scans to a threadpool via asyncio.to_thread, returning pl.LazyFrame so the semantic compiler decides what to materialize. - Graceful Degradation: Typed exceptions (SiloUnavailableError, SiloTimeoutError) ensure one failed silo returns a 503 while the others keep responding. - In-Memory TTL Cache: Configurable cache (SILO_CACHE_TTL_SECONDS, default 300) avoids repeated disk scans, with explicit invalidation support. - Use Case: Write ml/data/extractors.py for a FastAPI backend that serves three financial silos, then validate it with pytest-asyncio tests covering success, silo-down, and cache hit/miss scenarios. ## Quick Start Use the portal-data-connectors skill to write the async Parquet extractors in ml/data/extractors.py with typed silo errors and pytest-asyncio tests.

Frequently Asked Questions about portal-data-connectors

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
How do I read Parquet files asynchronously in Python without blocking the event loop?

Wrap the synchronous Polars scan in asyncio.to_thread or run_in_executor so the IO runs on a threadpool. Never call pl.scan_parquet directly inside an async handler, since Polars IO is synchronous and would block the event loop.

How to implement a TTL cache for repeated data reads in Python?

Store a (timestamp, value) tuple per key in a dict and compare time.monotonic() against a configurable TTL, such as SILO_CACHE_TTL_SECONDS defaulting to 300. Provide an invalidate function that clears one key or the whole cache.

Should I use pl.scan_parquet or pl.read_parquet for data extraction?

Use pl.scan_parquet, which returns a LazyFrame and defers materialization so downstream query compilation decides what to load. pl.read_parquet loads everything into memory eagerly, which wastes resources when only a subset is needed.

How do I handle one failing data source without crashing the whole service?

Raise typed exceptions like SiloUnavailableError carrying the silo name, then catch them per-silo in the service layer and return an HTTP 503 for that silo only. Other silos continue responding normally, achieving graceful degradation.

How do I test async extractor cache hit and miss behavior with pytest?

Use pytest-asyncio with pytestmark = pytest.mark.asyncio, monkeypatch the sync scan function to record calls, and call the extractor twice. Assert the scan ran exactly once, proving the second call was served from cache.