contextbase-plugin-github 0.2.0__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.
@@ -0,0 +1,9 @@
1
+ Metadata-Version: 2.3
2
+ Name: contextbase-plugin-github
3
+ Version: 0.2.0
4
+ Summary: GitHub 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.0
8
+ Requires-Dist: dagster==1.12.14
9
+ Requires-Python: >=3.14, <3.15
@@ -0,0 +1,9 @@
1
+ plugin_github/__init__.py,sha256=AbpHGcgLb-kRsJGnwFEktk7uzpZOCcBY74-YBdrKVGs,1
2
+ plugin_github/binding_config.py,sha256=nrNItI0zY74tEMjQrNL2DQUOPjXLqRqpsSGFLm0nAUI,1003
3
+ plugin_github/component.py,sha256=JmPpr2tzL5Uh3I5YuH5tvBFprLqexELzE_mnUzf2F-Q,3553
4
+ plugin_github/defs/__init__.py,sha256=AbpHGcgLb-kRsJGnwFEktk7uzpZOCcBY74-YBdrKVGs,1
5
+ plugin_github/defs/defs.yaml,sha256=XFgImJ736B1jpU6obO9RzsvNJPq2fz4qV872G_G4fhk,50
6
+ plugin_github/plugin.json,sha256=o02Wrx_g1yBE86CMdigGd_K9911APE1Gc4RpaGVucik,82
7
+ contextbase_plugin_github-0.2.0.dist-info/WHEEL,sha256=fWriCkzqm-pffF5af4gJC9iI5FMFaJTuN9UxxxzOmdY,81
8
+ contextbase_plugin_github-0.2.0.dist-info/METADATA,sha256=AHKdfjXpiqpxECx7Acfazh6KrGSSRS0Lo1VshV-N-K8,324
9
+ contextbase_plugin_github-0.2.0.dist-info/RECORD,,
@@ -0,0 +1,4 @@
1
+ Wheel-Version: 1.0
2
+ Generator: uv 0.11.14
3
+ Root-Is-Purelib: true
4
+ Tag: py3-none-any
@@ -0,0 +1 @@
1
+
@@ -0,0 +1,33 @@
1
+ from __future__ import annotations
2
+
3
+ from typing import Annotated
4
+
5
+ from pydantic import Field, StringConstraints
6
+
7
+ from shared_plugins.bindings import (
8
+ BaseBindingConfigModel,
9
+ NonEmptyText,
10
+ UtcTimestampText,
11
+ )
12
+
13
+ # An ``org/repo`` pattern where ``repo`` may be the literal ``*`` wildcard.
14
+ # Owner and repo segments must each be non-empty and contain no additional
15
+ # slashes — this mirrors GitHub's own repository addressing rules and the
16
+ # Airbyte source-github connector's ``repositories`` contract.
17
+ _REPOSITORY_PATTERN = r"^[^/]+/(?:[^/]+|\*)$"
18
+
19
+
20
+ class GithubBindingConfig(BaseBindingConfigModel):
21
+ repositories: list[
22
+ Annotated[
23
+ str,
24
+ StringConstraints(
25
+ strip_whitespace=True,
26
+ min_length=1,
27
+ pattern=_REPOSITORY_PATTERN,
28
+ ),
29
+ ]
30
+ ] = Field(min_length=1)
31
+ start_date: UtcTimestampText | None = None
32
+ api_url: NonEmptyText | None = None
33
+ branches: list[NonEmptyText] | None = None
@@ -0,0 +1,104 @@
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 GithubBindingConfig
26
+
27
+ PLUGIN_ID = plugin_id_from_module(__file__)
28
+ DOCKER_IMAGE = "airbyte/source-github:2.1.18"
29
+ SOURCE_UPDATED_AT_FIELDS = {
30
+ "issues": "updated_at",
31
+ "pull_requests": "updated_at",
32
+ }
33
+
34
+
35
+ def _build_connector_config(
36
+ cfg: GithubBindingConfig,
37
+ auth: ApiKeyAuth,
38
+ ) -> dict[str, object]:
39
+ return {
40
+ **cfg.model_dump(mode="json", exclude_none=True),
41
+ "credentials": {
42
+ "option_title": "PAT Credentials",
43
+ "personal_access_token": auth.api_key,
44
+ },
45
+ }
46
+
47
+
48
+ class GithubSyncComponent(dg.Component):
49
+ def build_defs(self, context: dg.ComponentLoadContext) -> dg.Definitions:
50
+ partitions_def = dg.DynamicPartitionsDefinition(
51
+ name=dagster_partition_def_name(PLUGIN_ID)
52
+ )
53
+
54
+ @dg.asset(
55
+ key=dagster_airbyte_sync_asset_key(PLUGIN_ID),
56
+ group_name=dagster_asset_group_name(PLUGIN_ID),
57
+ tags=dagster_asset_tags(PLUGIN_ID),
58
+ automation_condition=non_overlapping_automation_condition(
59
+ dg.AutomationCondition.on_missing()
60
+ | dg.AutomationCondition.on_cron("*/15 * * * *")
61
+ ),
62
+ partitions_def=partitions_def,
63
+ pool=dagster_pool_name(PLUGIN_ID),
64
+ )
65
+ def github_sync_asset(
66
+ context: AssetExecutionContext,
67
+ control_plane: dg.ResourceParam[ControlPlaneClient],
68
+ ):
69
+ binding = resolve_partition_binding(
70
+ context=context,
71
+ control_plane=control_plane,
72
+ plugin_id=PLUGIN_ID,
73
+ )
74
+ binding_id = str(binding.binding_id)
75
+ cfg = parse_binding_config(binding, GithubBindingConfig)
76
+ auth = require_api_key(binding)
77
+ selected_stream_names = require_pyairbyte_selected_stream_names(binding)
78
+
79
+ connector_config = _build_connector_config(cfg, auth)
80
+ source = build_pyairbyte_source(
81
+ docker_image=DOCKER_IMAGE,
82
+ connector_config=connector_config,
83
+ )
84
+
85
+ return run_pyairbyte_sync(
86
+ context=context,
87
+ plugin_id=PLUGIN_ID,
88
+ binding_id=binding_id,
89
+ selected_stream_names=selected_stream_names,
90
+ source_updated_at_fields=SOURCE_UPDATED_AT_FIELDS,
91
+ source=source,
92
+ )
93
+
94
+ automation_sensor = dg.AutomationConditionSensorDefinition(
95
+ name="github_automation_sensor",
96
+ target=dg.AssetSelection.assets(github_sync_asset),
97
+ default_status=dg.DefaultSensorStatus.RUNNING,
98
+ minimum_interval_seconds=30,
99
+ )
100
+
101
+ return dg.Definitions(
102
+ assets=[github_sync_asset],
103
+ sensors=[automation_sensor],
104
+ )
@@ -0,0 +1 @@
1
+
@@ -0,0 +1 @@
1
+ type: plugin_github.component.GithubSyncComponent
@@ -0,0 +1,7 @@
1
+ {
2
+ "auth": {
3
+ "type": "api_key"
4
+ },
5
+ "mode": "dagster",
6
+ "plugin_id": "github"
7
+ }