Skip to content

dev events #2

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Draft
wants to merge 3 commits into
base: master
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 10 additions & 0 deletions data_diff/dbt.py
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,7 @@ def dbt_diff(
custom_schemas = datadiff_variables.get("custom_schemas")
# custom schemas is default dbt behavior, so default to True if the var doesn't exist
custom_schemas = True if custom_schemas is None else custom_schemas
dbt_user_id = dbt_parser.get_dbt_user_id("dbt_user_id")

if not is_cloud:
dbt_parser.set_connection()
Expand Down Expand Up @@ -327,6 +328,15 @@ def get_models(self):
rich.print(f"Found {str(len(models))} successful model runs from the last dbt command.")
return models

def get_dbt_user_id(self):
with open(DbtParser.project_dir / MANIFEST_PATH) as manifest:
manifest_dict = json.load(manifest)
manifest_obj = self.parse_manifest(manifest=manifest_dict)

dbt_user_id = parse_version(manifest_obj.metadata.user_id)

return dbt_user_id

def get_primary_keys(self, model):
return list((x.name for x in model.columns.values() if "primary-key" in x.tags))

Expand Down
5 changes: 4 additions & 1 deletion data_diff/tracking.py
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,7 @@ def create_end_event_json(
error: Optional[str],
diff_id: Optional[int] = None,
is_cloud: bool = False,
#dbt_user_id: str,
):
return {
"event": "os_diff_run_end",
Expand All @@ -112,6 +113,7 @@ def create_end_event_json(
"entrypoint_name": entrypoint_name,
"is_cloud": is_cloud,
"diff_id": diff_id,
"dbt_user_id": dbt_user_id,
},
}

Expand All @@ -122,7 +124,8 @@ def send_event_json(event_json):

headers = {
"Content-Type": "application/json",
"Authorization": "Basic MkhndE00SGNxOUJtZWlDcU5ZaHo3Tzl0a2pNOg==",
#"Authorization": "Basic MkhndE00SGNxOUJtZWlDcU5ZaHo3Tzl0a2pNOg==", #prod
"Authorization": "Basic MkhnZ2o5NWhOc0JzeFNBNW1IaXJQYkk5d3pXOg==",
}
data = json.dumps(event_json).encode()
try:
Expand Down