dagster-airbyte 0.23.7__py3-none-any.whl → 0.25.10__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.

Potentially problematic release.


This version of dagster-airbyte might be problematic. Click here for more details.

@@ -1,7 +1,7 @@
1
1
  from dagster._core.libraries import DagsterLibraryRegistry
2
2
 
3
3
  try:
4
- from .managed import (
4
+ from dagster_airbyte.managed import (
5
5
  AirbyteConnection as AirbyteConnection,
6
6
  AirbyteDestination as AirbyteDestination,
7
7
  AirbyteDestinationNamespace as AirbyteDestinationNamespace,
@@ -14,20 +14,28 @@ try:
14
14
  except ImportError:
15
15
  pass
16
16
 
17
- from .asset_defs import (
17
+ from dagster_airbyte.asset_decorator import airbyte_assets as airbyte_assets
18
+ from dagster_airbyte.asset_defs import (
18
19
  build_airbyte_assets as build_airbyte_assets,
20
+ build_airbyte_assets_definitions as build_airbyte_assets_definitions,
19
21
  load_assets_from_airbyte_instance as load_assets_from_airbyte_instance,
20
- load_assets_from_airbyte_project as load_assets_from_airbyte_project,
21
22
  )
22
- from .ops import airbyte_sync_op as airbyte_sync_op
23
- from .resources import (
23
+ from dagster_airbyte.ops import airbyte_sync_op as airbyte_sync_op
24
+ from dagster_airbyte.resources import (
24
25
  AirbyteCloudResource as AirbyteCloudResource,
26
+ AirbyteCloudWorkspace as AirbyteCloudWorkspace,
25
27
  AirbyteResource as AirbyteResource,
26
- AirbyteState as AirbyteState,
27
28
  airbyte_cloud_resource as airbyte_cloud_resource,
28
29
  airbyte_resource as airbyte_resource,
30
+ load_airbyte_cloud_asset_specs as load_airbyte_cloud_asset_specs,
31
+ )
32
+ from dagster_airbyte.translator import (
33
+ AirbyteConnectionTableProps as AirbyteConnectionTableProps,
34
+ AirbyteJobStatusType as AirbyteJobStatusType,
35
+ AirbyteState as AirbyteState,
36
+ DagsterAirbyteTranslator as DagsterAirbyteTranslator,
29
37
  )
30
- from .types import AirbyteOutput as AirbyteOutput
31
- from .version import __version__ as __version__
38
+ from dagster_airbyte.types import AirbyteOutput as AirbyteOutput
39
+ from dagster_airbyte.version import __version__ as __version__
32
40
 
33
41
  DagsterLibraryRegistry.register("dagster-airbyte", __version__)
@@ -0,0 +1,113 @@
1
+ from typing import Any, Callable, Optional
2
+
3
+ from dagster import AssetsDefinition, multi_asset
4
+ from dagster._annotations import experimental
5
+
6
+ from dagster_airbyte.resources import AirbyteCloudWorkspace
7
+ from dagster_airbyte.translator import AirbyteMetadataSet, DagsterAirbyteTranslator
8
+
9
+
10
+ @experimental
11
+ def airbyte_assets(
12
+ *,
13
+ connection_id: str,
14
+ workspace: AirbyteCloudWorkspace,
15
+ name: Optional[str] = None,
16
+ group_name: Optional[str] = None,
17
+ dagster_airbyte_translator: Optional[DagsterAirbyteTranslator] = None,
18
+ ) -> Callable[[Callable[..., Any]], AssetsDefinition]:
19
+ """Create a definition for how to sync the tables of a given Airbyte connection.
20
+
21
+ Args:
22
+ connection_id (str): The Airbyte Connection ID.
23
+ workspace (AirbyteCloudWorkspace): The Airbyte workspace to fetch assets from.
24
+ name (Optional[str], optional): The name of the op.
25
+ group_name (Optional[str], optional): The name of the asset group.
26
+ dagster_airbyte_translator (Optional[DagsterAirbyteTranslator], optional): The translator to use
27
+ to convert Airbyte content into :py:class:`dagster.AssetSpec`.
28
+ Defaults to :py:class:`DagsterAirbyteTranslator`.
29
+
30
+ Examples:
31
+ Sync the tables of an Airbyte connection:
32
+
33
+ .. code-block:: python
34
+
35
+ from dagster_airbyte import AirbyteCloudWorkspace, airbyte_assets
36
+
37
+ import dagster as dg
38
+
39
+ airbyte_workspace = AirbyteCloudWorkspace(
40
+ workspace_id=dg.EnvVar("AIRBYTE_CLOUD_WORKSPACE_ID"),
41
+ client_id=dg.EnvVar("AIRBYTE_CLOUD_CLIENT_ID"),
42
+ client_secret=dg.EnvVar("AIRBYTE_CLOUD_CLIENT_SECRET"),
43
+ )
44
+
45
+
46
+ @airbyte_assets(
47
+ connection_id="airbyte_connection_id",
48
+ workspace=airbyte_workspace,
49
+ )
50
+ def airbyte_connection_assets(context: dg.AssetExecutionContext, airbyte: AirbyteCloudWorkspace):
51
+ yield from airbyte.sync_and_poll(context=context)
52
+
53
+
54
+ defs = dg.Definitions(
55
+ assets=[airbyte_connection_assets],
56
+ resources={"airbyte": airbyte_workspace},
57
+ )
58
+
59
+ Sync the tables of an Airbyte connection with a custom translator:
60
+
61
+ .. code-block:: python
62
+
63
+ from dagster_airbyte import (
64
+ DagsterAirbyteTranslator,
65
+ AirbyteConnectionTableProps,
66
+ AirbyteCloudWorkspace,
67
+ airbyte_assets
68
+ )
69
+
70
+ import dagster as dg
71
+
72
+ class CustomDagsterAirbyteTranslator(DagsterAirbyteTranslator):
73
+ def get_asset_spec(self, props: AirbyteConnectionTableProps) -> dg.AssetSpec:
74
+ default_spec = super().get_asset_spec(props)
75
+ return default_spec.merge_attributes(
76
+ metadata={"custom": "metadata"},
77
+ )
78
+
79
+ airbyte_workspace = AirbyteCloudWorkspace(
80
+ workspace_id=dg.EnvVar("AIRBYTE_CLOUD_WORKSPACE_ID"),
81
+ client_id=dg.EnvVar("AIRBYTE_CLOUD_CLIENT_ID"),
82
+ client_secret=dg.EnvVar("AIRBYTE_CLOUD_CLIENT_SECRET"),
83
+ )
84
+
85
+
86
+ @airbyte_assets(
87
+ connection_id="airbyte_connection_id",
88
+ workspace=airbyte_workspace,
89
+ dagster_airbyte_translator=CustomDagsterAirbyteTranslator()
90
+ )
91
+ def airbyte_connection_assets(context: dg.AssetExecutionContext, airbyte: AirbyteCloudWorkspace):
92
+ yield from airbyte.sync_and_poll(context=context)
93
+
94
+
95
+ defs = dg.Definitions(
96
+ assets=[airbyte_connection_assets],
97
+ resources={"airbyte": airbyte_workspace},
98
+ )
99
+ """
100
+ dagster_airbyte_translator = dagster_airbyte_translator or DagsterAirbyteTranslator()
101
+
102
+ return multi_asset(
103
+ name=name,
104
+ group_name=group_name,
105
+ can_subset=True,
106
+ specs=[
107
+ spec
108
+ for spec in workspace.load_asset_specs(
109
+ dagster_airbyte_translator=dagster_airbyte_translator
110
+ )
111
+ if AirbyteMetadataSet.extract(spec.metadata).connection_id == connection_id
112
+ ],
113
+ )