Core¶
Authored metadata and Python models have separate owners
Authored JSON fields are rendered on the Metadata reference page. Hydrated Python model details and runtime-only properties remain the responsibility of this API reference. Driver session and replay models are rendered on the Runtime configuration page. This page owns core helpers, registries, secrets and exceptions.
The model constructors below use keyword fields. Authored JSON/YAML is a
separate input shape: a metadata provider resolves connection references and
hydrates nested Connection, Source, Destination, Transform, and
DataFlow objects before the Driver executes them. For example, this is a
small programmatic model graph and its derived file path:
from datacoolie.core.models.connection import Connection
from datacoolie.core.models.source import Source
connection = Connection(
name="orders",
format="csv",
configure={"base_path": "input"},
)
source = Source(connection=connection, table="orders")
assert connection.connection_type == "file"
assert source.path == "input/orders"
The example uses Python keyword arguments. A provider can start from authored
JSON/YAML, resolve a connection_name reference, and then pass the resulting
values to these same model constructors. The schema reference remains the
authority for authored keys and validation; this page is the authority for the
hydrated Python objects.
Registry factories¶
The package root exposes six registry-backed factories. Each name selects a
registered implementation and **kwargs are passed to that implementation.
The factories describe runtime construction; entry-point discovery and
metadata format validation are separate contracts.
datacoolie
¶
DataCoolie — Metadata-driven, engine-unified, cloud-agnostic ETL framework.
The package root is intentionally lazy. Importing a pure framework utility must not import optional engine/platform SDKs; registries and built-in plugins are initialized the first time a runtime factory or registry is requested.
create_engine
¶
Create an engine instance by name (e.g. "spark", "polars").
create_platform
¶
Create a platform instance by name (e.g. "local", "fabric").
create_source
¶
Create a source reader by name (e.g. "delta", "csv").
create_destination
¶
Create a destination writer by name (e.g. "delta", "parquet").
create_transformer
¶
Create a transformer by name (e.g. "schema_converter").
create_resolver
¶
Create a secret resolver by name (e.g. "env").
Models and constants¶
CompatModel supplies the keyword construction, nested mapping coercion, and
model_dump* helpers used by the metadata models. Its subclasses use
@dataclass(init=False), so their generated dataclass signature is not the
runtime constructor contract. The class signatures are hidden here and the
declared fields are listed explicitly so the reference does not suggest an
empty constructor.
CompatModel
¶
Connection
dataclass
¶
Bases: CompatModel
Endpoint configuration for a data source or destination.
The configure JSON field stores type-specific settings (host, port,
read_options, write_options, etc.). Frequently-used values are
surfaced as computed properties.
connection_type
class-attribute
instance-attribute
¶
connection_type: str = ConnectionType.FILE.value
configure
class-attribute
instance-attribute
¶
database_type
property
¶
Database type (mysql, mssql, postgresql, oracle, sqlite).
schema_hint_type_system
property
¶
Raw source convention used when interpreting transform hints.
The model preserves the authored value. Normalization and validation belong to the transform resolver when a schema hint is actually used.
auth_type
property
¶
Database authentication type (password, service_principal, managed_identity, access_token).
merge_options
property
¶
Return options intended for merge/upsert operations.
athena_output_location
property
¶
S3 path for Athena DDL query results.
When set, the writer always registers a native Delta table via
Athena DDL (DROP + CREATE EXTERNAL TABLE ... TBLPROPERTIES
('table_type'='DELTA')) after every write and maintenance.
generate_manifest
property
¶
Generate _symlink_format_manifest/ after writes and maintenance.
register_symlink_table
property
¶
Register a SymlinkTextInputFormat table in Glue after writes.
Implies :attr:generate_manifest.
symlink_database_prefix
property
¶
Prefix for symlink Glue database name. Default "symlink_".
date_backward
property
¶
Backward look-back offset for date-folder partition discovery.
Reads backward_days, backward_months, backward_hours as
top-level keys from config, or a nested backward dict.
Strategies:
Fixed offset — subtract days / months / hours from watermark::
config:
backward_days: 7
# or
backward: {days: 7, months: 1}
Closing-day — monthly period boundary based on current date::
config:
backward: {closing_day: 10}
Source
dataclass
¶
Bases: CompatModel
Read-side pipeline configuration.
watermark_columns
class-attribute
instance-attribute
¶
configure
class-attribute
instance-attribute
¶
read_options
property
¶
Merged read options: connection defaults + source overrides.
has_watermark_state
property
¶
Whether ordinary execution needs persisted source state.
A file source with date-folder discovery can emit the internal folder cursor even when the user did not author a row watermark column. That cursor must be loaded on the next run so discovery can prune folders older than the saved frontier.
date_backward
property
¶
Backward look-back offset, source-level overrides connection-level.
Reads from configure (same keys as
:attr:Connection.date_backward). If no source-level config
is present, falls back to the connection's value.
Example (YAML / source configure)::
configure:
backward_days: 7 # overrides connection setting
# or
backward: {months: 1}
# or closing-day strategy
backward: {closing_day: 10}
PartitionColumn
dataclass
¶
Bases: CompatModel
Partition column definition.
expression is an optional SQL expression used to derive the partition
value (e.g. "year(event_date)").
Destination
dataclass
¶
Bases: CompatModel
Write-side pipeline configuration.
partition_columns
class-attribute
instance-attribute
¶
partition_columns: List[PartitionColumn] = field(
default_factory=list
)
configure
class-attribute
instance-attribute
¶
write_options
property
¶
Merged write options: connection defaults + destination overrides.
merge_options
property
¶
Merged merge options with a compatibility bridge for old aliases.
merge_keys_extended
property
¶
Return merge keys extended with partition columns.
scd2_effective_column
property
¶
SQL expression used as __valid_from for SCD2 loads.
Read from destination.configure["scd2_effective_column"].
Returns None when not set (non-SCD2 destinations).
replace_by_watermark
property
¶
Whether merge_overwrite should use range-based window replace.
When True, the strategy deletes all target rows within the
watermark window (watermark_effective → new_watermark) instead of
doing key-based delete. This handles source-side deletions.
Requires date_backward on the source to ensure the read window
covers the delete scope.
SchemaHint
dataclass
¶
AdditionalColumn
dataclass
¶
Bases: CompatModel
Computed column added during the transform phase.
ValueRule
dataclass
¶
HashColumn
dataclass
¶
MaskingRule
dataclass
¶
Transform
dataclass
¶
Bases: CompatModel
Transformation rules applied between source read and destination write.
deduplicate_columns
class-attribute
instance-attribute
¶
latest_data_columns
class-attribute
instance-attribute
¶
additional_columns
class-attribute
instance-attribute
¶
additional_columns: List[AdditionalColumn] = field(
default_factory=list
)
schema_hints
class-attribute
instance-attribute
¶
schema_hints: List[SchemaHint] = field(default_factory=list)
select_columns
class-attribute
instance-attribute
¶
drop_columns
class-attribute
instance-attribute
¶
rename_columns
class-attribute
instance-attribute
¶
value_rules
class-attribute
instance-attribute
¶
value_rules: List[ValueRule] = field(default_factory=list)
hash_columns
class-attribute
instance-attribute
¶
hash_columns: List[HashColumn] = field(default_factory=list)
masking_rules
class-attribute
instance-attribute
¶
masking_rules: List[MaskingRule] = field(
default_factory=list
)
configure
class-attribute
instance-attribute
¶
convert_timestamp_ntz
property
¶
Whether to convert timestamp_ntz columns to timestamp.
Reads convert_timestamp_ntz from :attr:configure.
Defaults to False so a naive wall-clock value is not silently
interpreted as an instant.
Example (YAML / metadata)::
transform:
configure:
convert_timestamp_ntz: false
timestamp_timezone
property
¶
Timezone used when an explicit NTZ-to-instant conversion is requested.
The value is passed to the engine adapter, which validates whether it can implement the conversion without mutating shared session state.
deduplicate_by_rank
property
¶
Whether to use RANK-based deduplication instead of ROW_NUMBER.
Reads deduplicate_by_rank from :attr:configure.
Defaults to False.
Example (YAML / metadata)::
transform:
configure:
deduplicate_by_rank: true
deduplicate_column_names
¶
Return dedup columns, falling back to merge_keys.
DataFlow
dataclass
¶
Bases: CompatModel
Complete ETL pipeline configuration.
Composes :class:Source, :class:Destination, and :class:Transform.
processing_mode
class-attribute
instance-attribute
¶
processing_mode: str = ProcessingMode.BATCH.value
transform
class-attribute
instance-attribute
¶
configure
class-attribute
instance-attribute
¶
order_columns
property
¶
Columns used to order rows during deduplication.
Returns transform.latest_data_columns when set, otherwise
falls back to source.watermark_columns.
constants
¶
Framework-wide enums and constants for the DataCoolie framework.
Every enum inherits from str so its .value is a plain string
that serialises naturally to JSON/YAML and matches database values.
CONNECTION_TYPE_FORMATS
module-attribute
¶
CONNECTION_TYPE_FORMATS: Dict[str, frozenset] = {
ConnectionType.FILE.value: frozenset(
{
Format.PARQUET.value,
Format.CSV.value,
Format.JSON.value,
Format.JSONL.value,
Format.AVRO.value,
Format.EXCEL.value,
}
),
ConnectionType.LAKEHOUSE.value: frozenset(
{Format.DELTA.value, Format.ICEBERG.value}
),
ConnectionType.DATABASE.value: frozenset(
{Format.SQL.value}
),
ConnectionType.API.value: frozenset({Format.API.value}),
ConnectionType.FUNCTION.value: frozenset(
{Format.FUNCTION.value}
),
ConnectionType.STREAMING.value: frozenset(),
}
TRAILING_COLUMNS
module-attribute
¶
TRAILING_COLUMNS: tuple[str, ...] = (
*((c.value) for c in SCD2Column),
*((c.value) for c in FileInfoColumn),
*((c.value) for c in SystemColumn),
)
LoadType
¶
Bases: str, Enum
Supported load (write) strategies.
Format
¶
Bases: str, Enum
Supported data formats.
ConnectionType
¶
Bases: str, Enum
Connection endpoint categories.
ProcessingMode
¶
Bases: str, Enum
ETL processing modes.
DataFlowStatus
¶
Bases: str, Enum
Dataflow execution statuses.
ExecutionType
¶
Bases: str, Enum
ETL execution types.
DatabaseType
¶
Bases: str, Enum
Supported database types for connection URL generation.
DatabaseAuthType
¶
Bases: str, Enum
Supported authentication types for database connections.
MaintenanceType
¶
Bases: str, Enum
Maintenance operation types.
ColumnCaseMode
¶
Bases: str, Enum
Column name case-conversion modes used by :class:ColumnNameSanitizer.
SystemColumn
¶
Bases: str, Enum
Column names automatically added to every destination write.
FileInfoColumn
¶
Bases: str, Enum
Column names injected for file-based sources.
SCD2Column
¶
Bases: str, Enum
Column names for Slowly Changing Dimension Type 2.
registry
¶
Thread-safe plugin registry with lazy entry-point discovery.
Registry state transitions are synchronized, while entry-point loading and user constructors run outside the state lock. This keeps plugin imports from deadlocking the registry and makes failed construction visible to callers.
PluginRegistry
¶
Bases: Generic[T]
Registry for manually registered and entry-point plugins.
clear_singletons
¶
Evict cached instances and remembered construction failures.
get
¶
Construct a fresh plugin instance outside the registry lock.
get_or_create
¶
Return one singleton, with deterministic concurrent construction.
get_or_create_optional
¶
Return a singleton or None for proven absence; selected failures raise.
Incomplete discovery cannot prove absence. Unrelated failed entry points do not prevent healthy plugins or genuinely absent names from resolving.
register
¶
Register or replace a plugin class and invalidate its instance.
unregister
¶
Remove a registered plugin and invalidate its cached state.
exceptions
¶
Exception hierarchy for the DataCoolie framework.
All framework exceptions inherit from :class:DataCoolieError which carries
a human-readable message and an optional details dict for structured
error context.
ConfigurationError
¶
DataCoolieError
¶
Bases: Exception
Base exception for all DataCoolie errors.
Attributes:
| Name | Type | Description |
|---|---|---|
message |
Human-readable error description. |
|
details |
Optional structured context for logging / debugging. |
DataFlowError
¶
DataFlowError(
message: str,
dataflow_id: str | None = None,
stage: str | None = None,
details: dict[str, Any] | None = None,
)
Bases: DataCoolieError
Raised for dataflow-level execution errors.
Attributes:
| Name | Type | Description |
|---|---|---|
dataflow_id |
Identifier of the failed dataflow. |
|
stage |
Pipeline stage where the error occurred. |
DestinationError
¶
DestinationError(
message: str,
details: dict[str, Any] | None = None,
*,
runtime_info: DestinationRuntimeInfo | None = None,
)
EngineError
¶
MetadataError
¶
PipelineError
¶
PipelineError(
message: str,
attempt: AttemptRuntimeInfo | None = None,
details: dict[str, Any] | None = None,
)
Bases: DataCoolieError
Raised when a pipeline step fails, carrying partial runtime results.
Attributes:
| Name | Type | Description |
|---|---|---|
attempt |
The attempt observation collected before the failure. |
PlatformError
¶
SourceError
¶
SourceError(
message: str,
details: dict[str, Any] | None = None,
*,
runtime_info: SourceRuntimeInfo | None = None,
)
TransformError
¶
TransformError(
message: str,
details: dict[str, Any] | None = None,
*,
runtime_info: TransformRuntimeInfo | None = None,
)
WatermarkError
¶
provider
¶
Secret provider abstraction and resolution utilities.
:class:BaseSecretProvider defines the contract for fetching secrets
from platform-specific vaults. :func:resolve_secrets wires a provider
(or any :class:~datacoolie.core.secrets.resolver.BaseSecretResolver) into
a :class:Connection by replacing vault key references with real values.
:class:SecretStr is an opaque wrapper that prevents accidental exposure
of secret values through str(), repr(), print(), f-strings,
and tracebacks. The raw value is never exposed via a public method.
Framework internals use :func:unwrap_secret / :func:unwrap_configure
to obtain plain strings at I/O boundaries (HTTP auth, JDBC, etc.).
BaseSecretProvider
¶
Bases: ABC
Abstract base class for secret providers.
Implementations fetch secrets from a platform-specific vault (Azure Key Vault, AWS Secrets Manager, Databricks Secrets, env vars).
Supports optional in-memory caching with a configurable TTL.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
cache_ttl
|
int
|
Time-to-live for cached secrets in seconds.
|
300
|
get_secret
¶
Fetch a single secret by key from the given source.
Uses the cache when available and not expired, otherwise
delegates to :meth:_fetch_secret.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
key
|
str
|
Vault key / secret name. For AWS this is the JSON field name within the secret; for other platforms it is the secret key within the scope / vault. |
required |
source
|
str
|
Source identifier whose meaning depends on the platform:
scope for Databricks, vault URL for Fabric, env prefix for
Local, and secret name/ARN ( |
''
|
Raises:
| Type | Description |
|---|---|
DataCoolieError
|
If the secret cannot be retrieved. |
get_secrets
¶
Fetch multiple secrets by keys from the given source.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
keys
|
List[str]
|
Secret key names (JSON field names for AWS). |
required |
source
|
str
|
Source identifier (scope, vault URL, env prefix, or
secret name/ARN for AWS). Defaults to |
''
|
Returns:
| Type | Description |
|---|---|
Dict[str, str]
|
Mapping of key → secret value. |
SecretStr
¶
Opaque wrapper that hides secret values from all public access.
str(), repr(), print(), format(), and logging
all render *** instead of the real value.
There is no public method to extract the underlying string.
Framework internals access the value via :func:unwrap_secret or
:func:unwrap_configure.
The wrapper is immutable, unhashable-by-value, and unpicklable to prevent accidental persistence or cache-key leaks.
resolve_secrets
¶
resolve_secrets(
connection: Connection,
provider: BaseSecretProvider,
*,
resolver_lookup: ResolverLookup | None = None,
) -> None
Resolve secret references in connection.
connection.secrets_ref maps each source (scope / vault URL / prefix /
SecretId) to a list of configure field names. Each listed field
must already be present in configure with the vault key name as its
value; resolve_secrets replaces that value with the real secret.
Repeated calls are idempotent: fields already holding
:class:SecretStr are left unchanged.
Source keys may contain a <resolver>:<arg> prefix (e.g.
"env:APP_"). When resolver_lookup is provided and returns a
resolver for that prefix, the plugin resolver is used. Otherwise the
platform-native provider handles the request via
:class:~datacoolie.core.secrets.resolver.NativeProviderResolver.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
connection
|
Connection
|
A :class: |
required |
provider
|
BaseSecretProvider
|
The platform-native secret provider. |
required |
resolver_lookup
|
ResolverLookup | None
|
Optional callable that maps a prefix string to
a :class: |
None
|
Raises:
| Type | Description |
|---|---|
DataCoolieError
|
If |
unwrap_configure
¶
Return a shallow copy with all :class:SecretStr values unwrapped.
Call this once at the I/O boundary (HTTP auth, JDBC connect, etc.)
to obtain a plain-string dict for external libraries. The original
configure dict retains its SecretStr wrappers.
unwrap_secret
¶
Return the raw string if value is a :class:SecretStr, else pass through.
resolver
¶
Pluggable secret resolver abstraction.
:class:BaseSecretResolver defines the single plugin contract for fetching
secrets — whether from environment variables, a cloud vault, HashiCorp Vault,
1Password, or any other backend.
Resolvers are registered via :data:datacoolie.resolver_registry and
dispatched by prefix in secrets_ref source keys ("env:APP_").
Sources without a prefix use the platform-native provider via
:class:NativeProviderResolver.
BaseSecretResolver
¶
Bases: ABC
Abstract base class for pluggable secret resolvers.
This is the single interface that every secret backend implements.
Subclasses must implement :meth:resolve which fetches a single
secret value given a key and a source argument.
resolve
abstractmethod
¶
Fetch a single secret.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
key
|
str
|
The secret / field name (value from |
required |
source
|
str
|
Backend-specific source identifier. For prefixed
sources ( |
required |
Returns:
| Type | Description |
|---|---|
str
|
The secret value as a string. |
Raises:
| Type | Description |
|---|---|
DataCoolieError
|
If the secret cannot be retrieved. |
EnvResolver
¶
Bases: BaseSecretResolver
Resolve secrets from environment variables.
The environment variable name is {source}{key}. For example
with source "APP_" and key "DB_PASSWORD" this looks up
os.environ["APP_DB_PASSWORD"].
NativeProviderResolver
¶
NativeProviderResolver(
provider: BaseSecretProvider, **_: object
)
Bases: BaseSecretResolver
Adapter that wraps a :class:BaseSecretProvider as a resolver.
This bridges the existing platform secret providers (Local, Fabric,
Databricks, AWS) into the unified :class:BaseSecretResolver
interface so that resolve_secrets needs only one code path.
parse_source
¶
parse_source(
source: str,
fallback: BaseSecretResolver,
resolver_lookup: ResolverLookup | None = None,
) -> tuple[BaseSecretResolver, str]
Parse an optional <prefix>:<arg> source key.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
source
|
str
|
The raw source key from |
required |
fallback
|
BaseSecretResolver
|
The resolver to use when source has no recognized
prefix (the :class: |
required |
resolver_lookup
|
ResolverLookup | None
|
Optional callable that maps a prefix string to
a :class: |
None
|
Returns:
| Type | Description |
|---|---|
BaseSecretResolver
|
A |
str
|
|