This library provides a Dagster integration with dlt.
For more information on getting started, see the dlt & Dagster documentation.
Asset Factory for using data load tool (dlt).
dlt_source (DltSource) – The DltSource to be ingested.
dlt_pipeline (Pipeline) – The dlt Pipeline defining the destination parameters.
name (Optional[str], optional) – The name of the op.
group_name (Optional[str], optional) – The name of the asset group.
dagster_dlt_translator (DagsterDltTranslator, optional) – Customization object for defining asset parameters from dlt resources.
partitions_def (Optional[PartitionsDefinition]) – Optional partitions definition.
op_tags (Optional[Mapping[str, Any]]) – The tags for the underlying op.
Examples
Loading Hubspot data to Snowflake with an auto materialize policy using the dlt verified source:
from dagster_dlt import DagsterDltResource, DagsterDltTranslator, dlt_assets
class HubspotDagsterDltTranslator(DagsterDltTranslator):
@public
def get_auto_materialize_policy(self, resource: DltResource) -> Optional[AutoMaterializePolicy]:
return AutoMaterializePolicy.eager().with_rules(
AutoMaterializeRule.materialize_on_cron("0 0 * * *")
)
@dlt_assets(
dlt_source=hubspot(include_history=True),
dlt_pipeline=pipeline(
pipeline_name="hubspot",
dataset_name="hubspot",
destination="snowflake",
progress="log",
),
name="hubspot",
group_name="hubspot",
dagster_dlt_translator=HubspotDagsterDltTranslator(),
)
def hubspot_assets(context: AssetExecutionContext, dlt: DagsterDltResource):
yield from dlt.run(context=context)
Loading Github issues to snowflake:
from dagster_dlt import DagsterDltResource, dlt_assets
@dlt_assets(
dlt_source=github_reactions(
"dagster-io", "dagster", items_per_page=100, max_items=250
),
dlt_pipeline=pipeline(
pipeline_name="github_issues",
dataset_name="github",
destination="snowflake",
progress="log",
),
name="github",
group_name="github",
)
def github_reactions_dagster_assets(context: AssetExecutionContext, dlt: DagsterDltResource):
yield from dlt.run(context=context)
Build a list of asset specs from a dlt source and pipeline.
dlt_source (DltSource) – dlt source object
dlt_pipeline (Pipeline) – dlt pipeline object
dagster_dlt_translator (Optional[DagsterDltTranslator]) – Allows customizing how to map dlt project to asset keys and asset metadata.
List[AssetSpec] list of asset specs from dlt source and pipeline
Defines asset key for a given dlt resource key and dataset name.
This method can be overriden to provide custom asset key for a dlt resource.
resource (DltResource) – dlt resource
AssetKey of Dagster asset derived from dlt resource
Defines resource specific auto materialize policy.
This method can be overriden to provide custom auto materialize policy for a dlt resource.
resource (DltResource) – dlt resource
The automaterialize policy for a resource
Optional[AutoMaterializePolicy]
Defines resource specific automation condition.
This method can be overridden to provide custom automation condition for a dlt resource.
resource (DltResource) – dlt resource
The automation condition for a resource
Optional[AutomationCondition]
Defines upstream asset dependencies given a dlt resource.
Defaults to a concatenation of resource.source_name and resource.name.
resource (DltResource) – dlt resource
The Dagster asset keys upstream of dlt_resource_key.
Iterable[AssetKey]
A method that takes in a dlt resource returns the Dagster description of the resource.
This method can be overriden to provide a custom description for a dlt resource.
resource (DltResource) – dlt resource
The Dagster description for the dlt resource.
Optional[str]
A method that takes in a dlt resource and returns the Dagster group name of the resource.
This method can be overriden to provide a custom group name for a dlt resource.
resource (DltResource) – dlt resource
A Dagster group name for the dlt resource.
Optional[str]
A method that takes in a dlt resource and returns the kinds which should be attached. Defaults to the destination type and “dlt”.
This method can be overriden to provide custom kinds for a dlt resource.
resource (DltResource) – dlt resource
The kinds of the asset.
Set[str]
Defines resource specific metadata.
resource (DltResource) – dlt resource
The custom metadata entries for this resource.
Mapping[str, Any]
A method that takes in a dlt resource and returns the Dagster owners of the resource.
This method can be overriden to provide custom owners for a dlt resource.
resource (DltResource) – dlt resource
A sequence of Dagster owners for the dlt resource.
Optional[Sequence[str]]
A method that takes in a dlt resource and returns the Dagster tags of the structure.
This method can be overriden to provide custom tags for a dlt resource.
resource (DltResource) – dlt resource
dlt resource.
Optional[Mapping[str, str]]
( experimental ) > This API may break in future versions, even between dot releases.
Runs the dlt pipeline with subset support.
context (Union[OpExecutionContext, AssetExecutionContext]) – Asset or op execution context
dlt_source (Optional[DltSource]) – optional dlt source if resource is used from an @op
dlt_pipeline (Optional[Pipeline]) – optional dlt pipeline if resource is used from an @op
dagster_dlt_translator (Optional[DagsterDltTranslator]) – optional dlt translator if resource is used from an @op
**kwargs (dict[str, Any]) – Keyword args passed to pipeline run method
An iterator of MaterializeResult or AssetMaterialization
DltEventIterator[DltEventType]