Key Concepts¶
This page explains the concepts behind fsspeckit's design: how imports are organized, why path safety matters, the difference between file and dataset operations, and how optional dependencies work.
For the authoritative import list and extras, see the API Guide and the extras matrix.
Import organization¶
fsspeckit splits its surface into domain packages so that an import tells you what a dependency does. Prefer root or domain-package imports; fall back to a direct module import only for backend-specific symbols.
The full canonical-import list is in the Public API Inventory. Older import paths that still work are mapped on the Legacy Imports page.
Importing fsspeckit registers extended I/O methods¶
Importing the package registers fsspeckit's extended I/O methods
(read_json, read_csv, read_parquet, write_parquet, read_files, and
others) on every fsspec AbstractFileSystem. Once you have a filesystem from
filesystem() or get_filesystem(), those methods are available directly:
Path safety and DirFileSystem¶
A plain fsspec filesystem grants access to any path the user can reach. By
default, filesystem() wraps the underlying filesystem in a fsspec
DirFileSystem (dirfs=True), confining every operation to a base directory.
Path traversal outside that root is rejected.
You can also build a DirFileSystem directly when you need explicit control,
or pass an existing filesystem as base_fs to nest confinement. This is the
basis for safe multi-tenant isolation, where each tenant gets a filesystem
rooted at its own directory.
Datasets versus files¶
fsspeckit offers two layers of data access:
- File-level I/O reads or writes a single file (or a glob of files) in one call. Use the extended I/O methods on a filesystem for JSON, CSV, and Parquet files. See Work with Filesystems.
- Dataset handlers treat a directory of parquet files as one logical
dataset with a shared schema, partitioning, and merge semantics. Use
DuckDBDatasetIOorPyarrowDatasetIOfor partitioned writes, incremental merges, and maintenance. See Dataset Handlers.
The key distinction for writes is between two operations that look similar:
write_dataset(data, path, mode="append"|"overwrite")writes new parquet files and returns per-file metadata. It never touches existing rows.merge(data, path, strategy, key_columns, ...)incrementally reconciles the source against the existing dataset, rewriting only the files that contain matching keys. It returns aMergeResultwith inserted, updated, and deleted counts.
See Merge Datasets for the practical recipe.
SQL filter abstraction¶
Each data framework has its own filter syntax. fsspeckit's SQL filter
translation lets you write a filter once as a SQL WHERE clause and convert it
to a PyArrow or Polars expression against a known schema. The translation is
type-aware: comparisons are built from the schema's column types.
SQL filter translation requires the sql extra. See
Use SQL Filters.
Optional dependencies¶
fsspeckit installs with the dependencies needed for core filesystem operations.
Cloud providers and data-processing backends are opt-in extras. Imports always
succeed; an extra is required only when you actually call the feature that
needs it, at which point fsspeckit raises an ImportError naming the package.
Match a missing-dependency error to a row in the
extras matrix to see which extra to
install. Cloud provider options classes (AwsStorageOptions,
GcsStorageOptions, AzureStorageOptions) likewise require their respective
aws, gcp, or azure extras.
Domain package boundaries¶
Each package owns a coherent responsibility:
- Core (
fsspeckit.core): filesystem factories (filesystem,get_filesystem),DirFileSystem, caching, and extended I/O. - Storage options (
fsspeckit.storage_options): structured configuration for local, cloud, and Git providers, plus factory helpers. - Datasets (
fsspeckit.datasets): parquet dataset handlers, schema utilities, and maintenance operations across DuckDB and PyArrow backends. - SQL (
fsspeckit.sql): SQL-to-filter translation. - Common (
fsspeckit.common): dependency-free utilities (parallelism, sync, partitions, security, logging).
fsspeckit.utils is a deprecated backwards-compatibility facade, not a primary
import route. New code imports from the domain packages above.
Configuration flow¶
A typical pipeline threads storage options through a filesystem into a dataset handler:
Security architecture¶
fsspeckit layers security controls across its surface:
- Path safety:
DirFileSystemconfines operations to a base directory, preventing traversal escapes. - Credential protection:
scrub_credentials()redacts secrets from log messages and error text before they are written or displayed. - Input validation:
validate_path(),validate_columns(), andvalidate_compression_codec()reject unsafe input early.
Related documentation¶
- Architecture - system design and domain boundaries.
- API Guide - import selection across all packages.
- How-to Guides - task-oriented recipes.