-
Notifications
You must be signed in to change notification settings - Fork 1.5k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[dagster-airbyte][docs] Migrate Airbyte cloud docs to new doc site
- Loading branch information
1 parent
a3c465e
commit 3d01ef8
Showing
15 changed files
with
206 additions
and
5 deletions.
There are no files selected for viewing
This file contains 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
83 changes: 83 additions & 0 deletions
83
docs/docs-beta/docs/integrations/libraries/airbyte/airbyte-cloud.md
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,83 @@ | ||
--- | ||
layout: Integration | ||
status: published | ||
name: Airbyte Cloud | ||
title: Using Dagster with Airbyte Cloud | ||
sidebar_label: Airbyte Cloud | ||
excerpt: Orchestrate Airbyte Cloud connections and schedule syncs alongside upstream or downstream dependencies. | ||
date: 2022-11-07 | ||
apireflink: https://docs.dagster.io/_apidocs/libraries/dagster-airbyte | ||
docslink: https://docs.dagster.io/integrations/airbyte-cloud | ||
partnerlink: https://airbyte.com/tutorials/orchestrate-data-ingestion-and-transformation-pipelines | ||
logo: /integrations/airbyte.svg | ||
categories: | ||
- ETL | ||
enabledBy: | ||
enables: | ||
tags: [dagster-supported, etl] | ||
--- | ||
|
||
This guide provides instructions for using Dagster with Airbyte Cloud using the `dagster-airbyte` library. Your Airbyte Cloud connection tables can be represented as assets in the Dagster asset graph, allowing you to track lineage and dependencies between Airbyte Cloud assets and data assets you are already modeling in Dagster. You can also use Dagster to orchestrate Airbyte Cloud connections, allowing you to trigger syncs for these on a cadence or based on upstream data changes. | ||
|
||
## What you'll learn | ||
|
||
- How to represent Airbyte Cloud assets in the Dagster asset graph, including lineage to other Dagster assets. | ||
- How to customize asset definition metadata for these Airbyte Cloud assets. | ||
- How to materialize Airbyte Cloud connection tables from Dagster. | ||
- How to customize how Airbyte Cloud connection tables are materialized. | ||
|
||
<details> | ||
<summary>Prerequisites</summary> | ||
|
||
- The `dagster` and `dagster-airbyte` libraries installed in your environment | ||
- Familiarity with asset definitions and the Dagster asset graph | ||
- Familiarity with Dagster resources | ||
- Familiarity with Airbyte Cloud concepts, like connections and connection tables | ||
- An Airbyte Cloud workspace | ||
- An Airbyte Cloud client ID and client secret. For more information, see [Configuring API Access](https://docs.airbyte.com/using-airbyte/configuring-api-access) in the Airbyte Cloud REST API documentation. | ||
|
||
</details> | ||
|
||
## Set up your environment | ||
|
||
To get started, you'll need to install the `dagster` and `dagster-airbyte` Python packages: | ||
|
||
```bash | ||
pip install dagster dagster-airbyte | ||
``` | ||
|
||
## Represent Airbyte Cloud assets in the asset graph | ||
|
||
To load Airbyte Cloud assets into the Dagster asset graph, you must first construct a <PyObject module="dagster_airbyte" object="AirbyteCloudWorkspace" /> resource, which allows Dagster to communicate with your Airbyte Cloud workspace. You'll need to supply your workspace ID, client ID and client secret. See [Configuring API Access](https://docs.airbyte.com/using-airbyte/configuring-api-access) in the Airbyte Cloud REST API documentation for more information on how to create your client ID and client secret. | ||
|
||
Dagster can automatically load all connection tables from your Airbyte Cloud workspace as asset specs. Call the <PyObject module="dagster_airbyte" method="load_airbyte_cloud_asset_specs" /> function, which returns list of <PyObject object="AssetSpec" />s representing your Airbyte Cloud assets. You can then include these asset specs in your <PyObject object="Definitions" /> object: | ||
|
||
<CodeExample filePath="integrations/airbyte_cloud/representing_airbyte_cloud_assets.py" language="python" /> | ||
|
||
### Sync and materialize Airbyte Cloud assets | ||
|
||
You can use Dagster to sync Airbyte Cloud connections and materialize Airbyte Cloud connection tables. You can use the <PyObject module="dagster_airbyte" method="build_airbyte_assets_definitions" /> factory to create all assets definitions for your Airbyte Cloud workspace. | ||
|
||
<CodeExample filePath="integrations/airbyte_cloud/sync_and_materialize_airbyte_cloud_assets.py" language="python" /> | ||
|
||
### Customize the materialization of Airbyte Cloud assets | ||
|
||
If you want to customize the sync of your connections, you can use the <PyObject module="dagster_airbyte" method="airbyte_assets" /> decorator to do so. This allows you to execute custom code before and after the call to the Airbyte Cloud sync. | ||
|
||
<CodeExample filePath="integrations/airbyte_cloud/customize_airbyte_cloud_asset_defs.py" language="python" /> | ||
|
||
### Customize asset definition metadata for Airbyte Cloud assets | ||
|
||
By default, Dagster will generate asset specs for each Airbyte Cloud asset and populate default metadata. You can further customize asset properties by passing an instance of the custom <PyObject module="dagster_airbyte" object="DagsterAirbyteTranslator" /> to the <PyObject module="dagster_airbyte" method="load_airbyte_cloud_asset_specs" /> function. | ||
|
||
<CodeExample filePath="integrations/airbyte_cloud/customize_airbyte_cloud_translator_asset_spec.py" language="python" /> | ||
|
||
Note that `super()` is called in each of the overridden methods to generate the default asset spec. It is best practice to generate the default asset spec before customizing it. | ||
|
||
You can pass an instance of the custom <PyObject module="dagster_airbyte" object="DagsterAirbyteTranslator" /> to the <PyObject module="dagster_airbyte" method="airbyte_assets" /> decorator or the <PyObject module="dagster_airbyte" method="build_airbyte_assets_definitions" /> factory. | ||
|
||
### Load Airbyte Cloud assets from multiple workspaces | ||
|
||
Definitions from multiple Airbyte Cloud workspaces can be combined by instantiating multiple <PyObject module="dagster_airbyte" object="AirbyteCloudWorkspace" /> resources and merging their specs. This lets you view all your Airbyte Cloud assets in a single asset graph: | ||
|
||
<CodeExample filePath="integrations/airbyte_cloud/multiple_airbyte_cloud_workspaces.py" language="python" /> |
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
Empty file.
29 changes: 29 additions & 0 deletions
29
...s_snippets/docs_snippets/integrations/airbyte_cloud/customize_airbyte_cloud_asset_defs.py
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
from dagster_airbyte import AirbyteCloudWorkspace, airbyte_assets | ||
|
||
import dagster as dg | ||
|
||
airbyte_workspace = AirbyteCloudWorkspace( | ||
workspace_id=dg.EnvVar("AIRBYTE_CLOUD_WORKSPACE_ID"), | ||
client_id=dg.EnvVar("AIRBYTE_CLOUD_CLIENT_ID"), | ||
client_secret=dg.EnvVar("AIRBYTE_CLOUD_CLIENT_SECRET"), | ||
) | ||
|
||
|
||
@airbyte_assets( | ||
connection_id="airbyte_connection_id", | ||
workspace=airbyte_workspace, | ||
name="airbyte_connection_name", | ||
group_name="airbyte_connection_name", | ||
) | ||
def airbyte_connection_assets( | ||
context: dg.AssetExecutionContext, airbyte: AirbyteCloudWorkspace | ||
): | ||
# Do something before the materialization... | ||
yield from airbyte.sync_and_poll(context=context) | ||
# Do something after the materialization... | ||
|
||
|
||
defs = dg.Definitions( | ||
assets=[airbyte_connection_assets], | ||
resources={"airbyte": airbyte_workspace}, | ||
) |
33 changes: 33 additions & 0 deletions
33
...docs_snippets/integrations/airbyte_cloud/customize_airbyte_cloud_translator_asset_spec.py
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
from dagster_airbyte import ( | ||
AirbyteCloudWorkspace, | ||
AirbyteConnectionTableProps, | ||
DagsterAirbyteTranslator, | ||
load_airbyte_cloud_asset_specs, | ||
) | ||
|
||
import dagster as dg | ||
|
||
airbyte_workspace = AirbyteCloudWorkspace( | ||
workspace_id=dg.EnvVar("AIRBYTE_CLOUD_WORKSPACE_ID"), | ||
client_id=dg.EnvVar("AIRBYTE_CLOUD_CLIENT_ID"), | ||
client_secret=dg.EnvVar("AIRBYTE_CLOUD_CLIENT_SECRET"), | ||
) | ||
|
||
|
||
# A translator class lets us customize properties of the built | ||
# Airbyte Cloud assets, such as the owners or asset key | ||
class MyCustomAirbyteTranslator(DagsterAirbyteTranslator): | ||
def get_asset_spec(self, props: AirbyteConnectionTableProps) -> dg.AssetSpec: | ||
# We create the default asset spec using super() | ||
default_spec = super().get_asset_spec(props) | ||
# We customize the metadata and asset key prefix for all assets | ||
return default_spec.replace_attributes( | ||
key=default_spec.key.with_prefix("prefix"), | ||
).merge_attributes(metadata={"custom": "metadata"}) | ||
|
||
|
||
airbyte_cloud_specs = load_airbyte_cloud_asset_specs( | ||
airbyte_workspace, dagster_airbyte_translator=MyCustomAirbyteTranslator() | ||
) | ||
|
||
defs = dg.Definitions(assets=airbyte_cloud_specs) |
27 changes: 27 additions & 0 deletions
27
...cs_snippets/docs_snippets/integrations/airbyte_cloud/multiple_airbyte_cloud_workspaces.py
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
from dagster_airbyte import AirbyteCloudWorkspace, load_airbyte_cloud_asset_specs | ||
|
||
import dagster as dg | ||
|
||
sales_airbyte_workspace = AirbyteCloudWorkspace( | ||
workspace_id=dg.EnvVar("AIRBYTE_CLOUD_SALES_WORKSPACE_ID"), | ||
client_id=dg.EnvVar("AIRBYTE_CLOUD_SALES_CLIENT_ID"), | ||
client_secret=dg.EnvVar("AIRBYTE_CLOUD_SALES_CLIENT_SECRET"), | ||
) | ||
|
||
marketing_airbyte_workspace = AirbyteCloudWorkspace( | ||
workspace_id=dg.EnvVar("AIRBYTE_CLOUD_MARKETING_WORKSPACE_ID"), | ||
client_id=dg.EnvVar("AIRBYTE_CLOUD_MARKETING_CLIENT_ID"), | ||
client_secret=dg.EnvVar("AIRBYTE_CLOUD_MARKETING_CLIENT_SECRET"), | ||
) | ||
|
||
sales_airbyte_cloud_specs = load_airbyte_cloud_asset_specs( | ||
workspace=sales_airbyte_workspace | ||
) | ||
marketing_airbyte_cloud_specs = load_airbyte_cloud_asset_specs( | ||
workspace=marketing_airbyte_workspace | ||
) | ||
|
||
# Merge the specs into a single set of definitions | ||
defs = dg.Definitions( | ||
assets=[*sales_airbyte_cloud_specs, *marketing_airbyte_cloud_specs], | ||
) |
13 changes: 13 additions & 0 deletions
13
...cs_snippets/docs_snippets/integrations/airbyte_cloud/representing_airbyte_cloud_assets.py
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
from dagster_airbyte import AirbyteCloudWorkspace, load_airbyte_cloud_asset_specs | ||
|
||
import dagster as dg | ||
|
||
airbyte_workspace = AirbyteCloudWorkspace( | ||
workspace_id=dg.EnvVar("AIRBYTE_CLOUD_WORKSPACE_ID"), | ||
client_id=dg.EnvVar("AIRBYTE_CLOUD_CLIENT_ID"), | ||
client_secret=dg.EnvVar("AIRBYTE_CLOUD_CLIENT_SECRET"), | ||
) | ||
|
||
|
||
airbyte_cloud_specs = load_airbyte_cloud_asset_specs(airbyte_workspace) | ||
defs = dg.Definitions(assets=airbyte_cloud_specs) |
16 changes: 16 additions & 0 deletions
16
...ets/docs_snippets/integrations/airbyte_cloud/sync_and_materialize_airbyte_cloud_assets.py
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
from dagster_airbyte import AirbyteCloudWorkspace, build_airbyte_assets_definitions | ||
|
||
import dagster as dg | ||
|
||
airbyte_workspace = AirbyteCloudWorkspace( | ||
workspace_id=dg.EnvVar("AIRBYTE_CLOUD_WORKSPACE_ID"), | ||
client_id=dg.EnvVar("AIRBYTE_CLOUD_CLIENT_ID"), | ||
client_secret=dg.EnvVar("AIRBYTE_CLOUD_CLIENT_SECRET"), | ||
) | ||
|
||
all_airbyte_assets = build_airbyte_assets_definitions(workspace=airbyte_workspace) | ||
|
||
defs = dg.Definitions( | ||
assets=all_airbyte_assets, | ||
resources={"airbyte": airbyte_workspace}, | ||
) |