contextbase-plugin-notion 0.2.6__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.
- contextbase_plugin_notion-0.2.6.dist-info/METADATA +9 -0
- contextbase_plugin_notion-0.2.6.dist-info/RECORD +9 -0
- contextbase_plugin_notion-0.2.6.dist-info/WHEEL +4 -0
- plugin_notion/__init__.py +0 -0
- plugin_notion/binding_config.py +7 -0
- plugin_notion/component.py +107 -0
- plugin_notion/defs/__init__.py +0 -0
- plugin_notion/defs/defs.yaml +1 -0
- plugin_notion/plugin.json +7 -0
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
Metadata-Version: 2.3
|
|
2
|
+
Name: contextbase-plugin-notion
|
|
3
|
+
Version: 0.2.6
|
|
4
|
+
Summary: Notion plugin for ContextBase (PyAirbyte-backed)
|
|
5
|
+
Author: Alizain Feerasta
|
|
6
|
+
Author-email: Alizain Feerasta <alizain.feerasta@gmail.com>
|
|
7
|
+
Requires-Dist: contextbase-shared-plugins==0.2.6
|
|
8
|
+
Requires-Dist: dagster==1.12.14
|
|
9
|
+
Requires-Python: >=3.14, <3.15
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
plugin_notion/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
2
|
+
plugin_notion/binding_config.py,sha256=x2eHUTfvhvOZNFiSRZmNXBulmVeqWB5Lumn5YDT796M,213
|
|
3
|
+
plugin_notion/component.py,sha256=oSrQ2myscmeT1b8LgiFhGGy71v32vJJ2vazAL9zSTVk,3604
|
|
4
|
+
plugin_notion/defs/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
5
|
+
plugin_notion/defs/defs.yaml,sha256=a1NijtXoQym9C0PKtLM1fHO_GXT3A4rkGTFbEdOBu8A,50
|
|
6
|
+
plugin_notion/plugin.json,sha256=nECJqvexC_iYxADtK4FlmgBJxH1ueQwqMwVXBPqJPdg,82
|
|
7
|
+
contextbase_plugin_notion-0.2.6.dist-info/WHEEL,sha256=i9aSRDivn5iP9LaR1BLQX2GNAuriQWPsFwbbWygTX2k,81
|
|
8
|
+
contextbase_plugin_notion-0.2.6.dist-info/METADATA,sha256=QDupGRHkCFh5JNL-1Jh9Z7dZ7vWAo63C0Lk9mAE67Y0,324
|
|
9
|
+
contextbase_plugin_notion-0.2.6.dist-info/RECORD,,
|
|
File without changes
|
|
@@ -0,0 +1,107 @@
|
|
|
1
|
+
import dagster as dg
|
|
2
|
+
from dagster import AssetExecutionContext
|
|
3
|
+
from shared_plugins.automation import non_overlapping_automation_condition
|
|
4
|
+
from shared_plugins.bindings import (
|
|
5
|
+
parse_binding_config,
|
|
6
|
+
require_api_key,
|
|
7
|
+
)
|
|
8
|
+
from shared_plugins.control_plane import ControlPlaneClient
|
|
9
|
+
from shared_plugins.dlt import resolve_partition_binding
|
|
10
|
+
from shared_plugins.naming import (
|
|
11
|
+
dagster_airbyte_sync_asset_key,
|
|
12
|
+
dagster_asset_group_name,
|
|
13
|
+
dagster_asset_tags,
|
|
14
|
+
dagster_partition_def_name,
|
|
15
|
+
dagster_pool_name,
|
|
16
|
+
plugin_id_from_module,
|
|
17
|
+
)
|
|
18
|
+
from shared_plugins.pyairbyte import (
|
|
19
|
+
build_pyairbyte_source,
|
|
20
|
+
require_pyairbyte_selected_stream_names,
|
|
21
|
+
run_pyairbyte_sync,
|
|
22
|
+
)
|
|
23
|
+
from shared_types.api_key_auth import ApiKeyAuth
|
|
24
|
+
|
|
25
|
+
from .binding_config import NotionBindingConfig
|
|
26
|
+
|
|
27
|
+
PLUGIN_ID = plugin_id_from_module(__file__)
|
|
28
|
+
DOCKER_IMAGE = "airbyte/source-notion:4.0.5"
|
|
29
|
+
|
|
30
|
+
SOURCE_UPDATED_AT_FIELDS = {
|
|
31
|
+
"pages": "last_edited_time",
|
|
32
|
+
"data_sources": "last_edited_time",
|
|
33
|
+
"blocks": "last_edited_time",
|
|
34
|
+
"comments": "last_edited_time",
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
|
|
38
|
+
def _build_connector_config(
|
|
39
|
+
cfg: NotionBindingConfig,
|
|
40
|
+
auth: ApiKeyAuth,
|
|
41
|
+
) -> dict[str, object]:
|
|
42
|
+
return {
|
|
43
|
+
**cfg.model_dump(mode="json", exclude_none=True),
|
|
44
|
+
"credentials": {
|
|
45
|
+
"auth_type": "token",
|
|
46
|
+
"token": auth.api_key,
|
|
47
|
+
},
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
|
|
51
|
+
class NotionSyncComponent(dg.Component):
|
|
52
|
+
def build_defs(self, context: dg.ComponentLoadContext) -> dg.Definitions:
|
|
53
|
+
partitions_def = dg.DynamicPartitionsDefinition(
|
|
54
|
+
name=dagster_partition_def_name(PLUGIN_ID)
|
|
55
|
+
)
|
|
56
|
+
|
|
57
|
+
@dg.asset(
|
|
58
|
+
key=dagster_airbyte_sync_asset_key(PLUGIN_ID),
|
|
59
|
+
group_name=dagster_asset_group_name(PLUGIN_ID),
|
|
60
|
+
tags=dagster_asset_tags(PLUGIN_ID),
|
|
61
|
+
automation_condition=non_overlapping_automation_condition(
|
|
62
|
+
dg.AutomationCondition.on_missing()
|
|
63
|
+
| dg.AutomationCondition.on_cron("*/15 * * * *")
|
|
64
|
+
),
|
|
65
|
+
partitions_def=partitions_def,
|
|
66
|
+
pool=dagster_pool_name(PLUGIN_ID),
|
|
67
|
+
)
|
|
68
|
+
def notion_sync_asset(
|
|
69
|
+
context: AssetExecutionContext,
|
|
70
|
+
control_plane: dg.ResourceParam[ControlPlaneClient],
|
|
71
|
+
):
|
|
72
|
+
binding = resolve_partition_binding(
|
|
73
|
+
context=context,
|
|
74
|
+
control_plane=control_plane,
|
|
75
|
+
plugin_id=PLUGIN_ID,
|
|
76
|
+
)
|
|
77
|
+
binding_id = str(binding.binding_id)
|
|
78
|
+
cfg = parse_binding_config(binding, NotionBindingConfig)
|
|
79
|
+
auth = require_api_key(binding)
|
|
80
|
+
selected_stream_names = require_pyairbyte_selected_stream_names(binding)
|
|
81
|
+
|
|
82
|
+
connector_config = _build_connector_config(cfg, auth)
|
|
83
|
+
source = build_pyairbyte_source(
|
|
84
|
+
docker_image=DOCKER_IMAGE,
|
|
85
|
+
connector_config=connector_config,
|
|
86
|
+
)
|
|
87
|
+
|
|
88
|
+
return run_pyairbyte_sync(
|
|
89
|
+
context=context,
|
|
90
|
+
plugin_id=PLUGIN_ID,
|
|
91
|
+
binding_id=binding_id,
|
|
92
|
+
selected_stream_names=selected_stream_names,
|
|
93
|
+
source_updated_at_fields=SOURCE_UPDATED_AT_FIELDS,
|
|
94
|
+
source=source,
|
|
95
|
+
)
|
|
96
|
+
|
|
97
|
+
automation_sensor = dg.AutomationConditionSensorDefinition(
|
|
98
|
+
name="notion_automation_sensor",
|
|
99
|
+
target=dg.AssetSelection.assets(notion_sync_asset),
|
|
100
|
+
default_status=dg.DefaultSensorStatus.RUNNING,
|
|
101
|
+
minimum_interval_seconds=30,
|
|
102
|
+
)
|
|
103
|
+
|
|
104
|
+
return dg.Definitions(
|
|
105
|
+
assets=[notion_sync_asset],
|
|
106
|
+
sensors=[automation_sensor],
|
|
107
|
+
)
|
|
File without changes
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
type: plugin_notion.component.NotionSyncComponent
|