feat: unifica toolkit_layer — mode=sql su raw, catalog mode (datasets), scope validation - #422
Merged
Merged
Conversation
…), scope validation
- _resolve_datasets converte qualsiasi s3:// in https://storage.googleapis.com/ (vale sia per clean che per mart) - year=None entries incluse nel filtro anno (serie storiche) - Sort key corretto per year=None
- Import CLEAN_BUCKET/MART_BUCKET da lab_connectors.gcs.paths invece di ridefinirli in catalog_ops.py
L'import del modulo server.py chiama create_mcp_server() a livello modulo, che richiede 'mcp'. pytest.importorskip a livello modulo skipka l'intero file se mcp non e' installato. In CI: 22 skipped invece di 4 error. In locale con lab-connectors[mcp]: 22 passed.
pytest.importorskip('mcp') trova il package 'mcp' ma non garantisce
che mcp.server.fastmcp.FastMCP sia disponibile. Usa importorskip
sul submodulo che crea_mcp_server() importa davvero.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Sintesi
toolkit_layerdiventa il tool SQL unico: supporta SQL su layer raw (CSV), cross-dataset SQL via slugs, e scope validation. Tre unificazioni in uno.Contesto collegato
Continua il percorso di unificazione iniziato con le PR #419, #420, #421.
Cosa cambia
1.
mode=sqlora funziona sulayer=rawPrima era bloccato (
ValueError: mode=sql non e' supportato per layer=raw). Ora DuckDB legge il CSV primario viaread_csv_autoe lo espone come tabelladata.2. Catalog mode:
datasets=[slug1, slug2, ...]Nuovo parametro
datasets(mutuamente esclusivo conconfig_path) per query cross-dataset su dataset pubblicati GCS/workspace. UsaCatalogResolverper risolvere slug → URL parquet, costruisce CTE multipli, esegue SQL.3. Scope validation (catalog mode)
Portata da clean-query: blocca DDL/DML (
DROP,ALTER,INSERT...),read_parquet()diretto, tabelle non dichiarate nei CTE. Hard cap a 500 righe.Backward compat
toolkit_layer(config_path=..., mode=sql, layer=clean)invariato.datasets=Nonedi default.Impatto
Verifica
terna_electricity_by_sourceGROUP BY regione → 8 righe, oktoolkit_layer(mode=sql, config_path=...)invariatoControlli
regressioncon link all'issueNote per chi revisiona
toolkit_layer(mode=schema/preview/profile/sql con config_path)