Skip to content

Commit a378d51

Browse files
committed
fix metadata, add fivetran
1 parent 1259974 commit a378d51

7 files changed

Lines changed: 68 additions & 9 deletions

File tree

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -187,4 +187,4 @@ prefect config set PREFECT_API_KEY=this_must_be_a_different_api_key_as_they_are_
187187
- simple dbt flows are **parametrized** to make it easy to execute any dbt command for the relevant project
188188
- all ingestion flows are parametrized to make **backfills** a breeze - just change the start and end date, and the interval in your parameter values when triggering the run, and you can trigger a backfill from the same flow as usual -- see the flow parameters e.g. in the flow [flows/ingestion/ingest_jaffle_shop.py](flows/ingestion/ingest_jaffle_shop.py)
189189
- optionally, you can track each dbt model or test as a separate task by using the ``dbt_run_from_manifest.py`` logic -- [dataplatform/blocks/dbt.py](dataplatform/blocks/dbt.py)
190-
- it's fun to use! if you want to change how your dbt tasks look like for Halloween or Christmas, change the emoji on the block 🤗
190+
- it's fun to use! if you want to change how your dbt tasks look like for Halloween or Christmas, change the emoji on the block 🤗

flows/syncs_fivetran/block.py

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
from dotenv import load_dotenv
2+
import os
3+
from prefect_fivetran import FivetranCredentials
4+
5+
load_dotenv()
6+
7+
fivetran_credentials = FivetranCredentials(
8+
api_key=os.environ.get("FIVETRAN_API_KEY"),
9+
api_secret=os.environ.get("FIVETRAN_API_SECRET_KEY"),
10+
)
11+
fivetran_credentials.save("default")

flows/syncs_fivetran/fivetran.py

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
from prefect import flow, Task
2+
from prefect_fivetran import FivetranCredentials
3+
from prefect_fivetran.connectors import fivetran_sync_flow
4+
5+
6+
@flow
7+
def my_flow():
8+
fivetran_result = await fivetran_sync_flow(
9+
fivetran_credentials=FivetranCredentials.load("default"),
10+
connector_id="my_connector_id",
11+
schedule_type="my_schedule_type",
12+
poll_status_every_n_seconds=30,
13+
)
14+
15+
16+
my_flow()
Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
"""
2+
pip install prefect_fivetran
3+
prefect block register -m prefect_fivetran
4+
"""
5+
from prefect import flow
6+
from prefect_fivetran import FivetranCredentials
7+
from prefect_fivetran.connectors import (
8+
wait_for_fivetran_connector_sync,
9+
start_fivetran_connector_sync,
10+
)
11+
12+
13+
@flow
14+
def example_flow(connector_id: str):
15+
fivetran_credentials = FivetranCredentials.load("default")
16+
17+
last_sync = start_fivetran_connector_sync(
18+
connector_id=connector_id,
19+
fivetran_credentials=fivetran_credentials,
20+
)
21+
22+
return wait_for_fivetran_connector_sync(
23+
connector_id=connector_id,
24+
fivetran_credentials=fivetran_credentials,
25+
previous_completed_at=last_sync,
26+
poll_status_every_n_seconds=60,
27+
)
28+
29+
30+
if __name__ == "__main__":
31+
example_flow("bereft_indices")
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
prefect
2+
prefect_fivetran

utilities/create_blocks.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,6 @@
1515
from dataplatform.deploy_utils import save_block, DEFAULT_BLOCK
1616
from dataplatform.environment import get_env
1717

18-
1918
load_dotenv()
2019

2120

@@ -26,7 +25,7 @@
2625
workspace = Workspace(
2726
name=get_env(),
2827
block_name=DEFAULT_BLOCK,
29-
settings=dict(workspace_owner="Data Engineering", environment="Development"),
28+
metadata=dict(workspace_owner="Data Engineering", environment="Development"),
3029
)
3130
save_block(workspace)
3231

utilities/dummy_sa.json

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
11
{
22
"type": "service_account",
3-
"project_id": "xxx",
4-
"private_key_id": "xxx",
5-
"private_key": "xxx",
6-
"client_email": "generic@xxx.iam.gserviceaccount.com",
7-
"client_id": "xxx",
3+
"project_id": "prefect-community",
4+
"private_key_id": "uuid",
5+
"private_key": "-----BEGIN PRIVATE KEY-----\n a looooooong string",
6+
"client_email": "prefect@prefect-community.iam.gserviceaccount.com",
7+
"client_id": "numbers",
88
"auth_uri": "https://accounts.google.com/o/oauth2/auth",
99
"token_uri": "https://oauth2.googleapis.com/token",
1010
"auth_provider_x509_cert_url": "https://www.googleapis.com/oauth2/v1/certs",
11-
"client_x509_cert_url": "https://www.googleapis.com/robot/v1/metadata/x509/generic%40prefect-community.iam.gserviceaccount.com"
11+
"client_x509_cert_url": "https://www.googleapis.com/robot/v1/metadata/x509/sa_name_and_project_name.iam.gserviceaccount.com"
1212
}

0 commit comments

Comments
 (0)