translator
Custom translator for enriching dltHub resources with Dagster metadata.
The translator inspects dlt resource metadata and maps it onto Dagster asset constructs. This enables features such as automation conditions, partitions, and validated tags to flow from dlt configuration into Dagster without manual wiring.
CustomDagsterDltTranslator
Bases: DagsterDltTranslator
Translate dlt resource metadata into Dagster asset definitions.
Source code in data_foundation/defs/dlthub/translator.py
17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 | |
get_asset_key(resource)
Generate the Dagster asset key for a dlt resource.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
resource
|
DltResource
|
dlt resource whose name encodes schema and table information. |
required |
Returns:
| Type | Description |
|---|---|
AssetKey
|
dagster.AssetKey: Asset key structured as |
Source code in data_foundation/defs/dlthub/translator.py
get_asset_spec(data)
Create an :class:~dagster.AssetSpec that reflects dlt resource metadata.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
data
|
DltResourceTranslatorData
|
Translator payload that bundles the dlt resource and destination configuration used to inform Dagster metadata. |
required |
Returns:
| Type | Description |
|---|---|
AssetSpec
|
dagster.AssetSpec: Asset specification populated with automation conditions, dependencies, tags, and partitioning inferred from the dlt resource. |
Source code in data_foundation/defs/dlthub/translator.py
get_automation_condition(resource)
Return an automation condition definition if one exists. dlt does not support adding metadata, so this can not be parsed from the resouce itself, and must be defined when the translator is instantiated.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
resource
|
DltResource
|
dlt resource whose |
required |
Returns:
| Type | Description |
|---|---|
AutomationCondition[Any] | None
|
dagster.AutomationCondition | None: Automation condition to apply to the
Dagster asset or |
Source code in data_foundation/defs/dlthub/translator.py
get_deps_asset_keys(resource)
Return external assets that represent upstream data sources.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
resource
|
DltResource
|
dlt resource whose upstream lineage should be mapped to Dagster asset keys. |
required |
Returns:
| Type | Description |
|---|---|
Iterable[AssetKey]
|
Iterable[dagster.AssetKey]: External asset keys representing the raw source tables feeding the resource. |
Source code in data_foundation/defs/dlthub/translator.py
get_group_name(resource)
Group dlt assets by the schema portion of the resource name.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
resource
|
DltResource
|
dlt resource used to determine the Dagster asset group. |
required |
Returns:
| Name | Type | Description |
|---|---|---|
str |
str
|
The schema prefix extracted from the resource name. |
Source code in data_foundation/defs/dlthub/translator.py
get_partitions_def(resource)
Return a partitions definition if one exists. dlt does not support adding metadata, so this can not be parsed from the resouce itself, and must be defined when the translator is instantiated.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
resource
|
DltResource
|
dlt resource whose |
required |
Returns:
| Type | Description |
|---|---|
PartitionsDefinition | None
|
dagster.PartitionsDefinition | None: Partitions definition derived from
metadata or |
Source code in data_foundation/defs/dlthub/translator.py
get_tags(resource)
Return tags if they exists. dlt does not support adding metadata, so this can not be parsed from the resouce itself, and must be defined when the translator is instantiated.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
resource
|
DltResource
|
dlt resource potentially containing tag metadata. |
required |
Returns:
| Type | Description |
|---|---|
Mapping[str, Any]
|
Mapping[str, Any]: Dictionary of Dagster-compliant tags derived from the dlt resource metadata. |