-
Notifications
You must be signed in to change notification settings - Fork 11
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* feature: handle null date in show snapshot * feature: rename my_handler by drift handler * feature: get transport from user defined file * feature: function loader handles array of function * feature: add alert transport * feature: replace print by console alerttransport * feature: implement github alert transport * feature: move the datadrift config in a .datadrift.py * feature: clean transport folder * feature: make compatibility with 3.8 * feature: add some logs * feature: add a gitlab transport
- Loading branch information
Showing
9 changed files
with
126 additions
and
26 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
from .console import ConsoleAlertTransport | ||
from .github import GithubAlertTransport | ||
from .gitlab import GitlabAlertTransport | ||
from .interface import AbstractAlertTransport |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
|
||
from ..interface import DriftEvaluation, DriftEvaluatorContext | ||
from .interface import AbstractAlertTransport | ||
|
||
|
||
class ConsoleAlertTransport(AbstractAlertTransport): | ||
def send(self, title: str, drift_evalutation: DriftEvaluation, drift_context: DriftEvaluatorContext) -> None: | ||
print(title) | ||
drift_summary = drift_context.summary | ||
print("added_rows \n", drift_summary["added_rows"].to_markdown()) | ||
print("deleted_rows \n", drift_summary["deleted_rows"].to_markdown()) | ||
print("modified_patterns \n", drift_summary["modified_patterns"].to_markdown()) | ||
print("modified_rows_unique_keys \n", drift_summary["modified_rows_unique_keys"]) | ||
|
||
print("should alert \n", drift_evalutation.should_alert) | ||
print("alert message \n", drift_evalutation.message) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
from github import GithubException, Repository | ||
from github.MainClass import Github | ||
|
||
from ..interface import DriftEvaluation, DriftEvaluatorContext | ||
from .interface import AbstractAlertTransport | ||
|
||
|
||
class GithubAlertTransport(AbstractAlertTransport): | ||
def __init__(self, github_client: Github, repository_name: str, assignees = []) -> None: | ||
self.github_client = github_client | ||
self.repo = github_client.get_repo(repository_name) | ||
self.assignees = assignees | ||
|
||
def send(self, title: str, drift_evalutation: DriftEvaluation, drift_context: DriftEvaluatorContext) -> None: | ||
if not drift_evalutation.should_alert: | ||
print("No alert needed") | ||
return | ||
try: | ||
issue = self.repo.create_issue( | ||
title=title, | ||
body=drift_evalutation.message, | ||
assignees=self.assignees, | ||
) | ||
print("Issue created: " + issue.html_url) | ||
except GithubException as e: | ||
if e.status == 422: | ||
print("Issue already exists. skipping...") | ||
else: | ||
raise e |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
from gitlab import Gitlab | ||
|
||
from ..interface import DriftEvaluation, DriftEvaluatorContext | ||
from .interface import AbstractAlertTransport | ||
|
||
|
||
class GitlabAlertTransport(AbstractAlertTransport): | ||
def __init__(self, gitlab_client: Gitlab, project_id: str, assignees = []) -> None: | ||
self.gitlab_client = gitlab_client | ||
self.project = gitlab_client.projects.get(project_id) | ||
self.assignees = assignees | ||
|
||
def send(self, title: str, drift_evalutation: DriftEvaluation, drift_context: DriftEvaluatorContext) -> None: | ||
if not drift_evalutation.should_alert: | ||
print("No alert needed") | ||
return | ||
try: | ||
issue = self.project.issues.create({'title': title, 'description': drift_evalutation.message}) | ||
print("Issue created: " + issue.attributes['web_url']) | ||
except Exception as e: | ||
print("Error creating the issue") | ||
raise e |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
from abc import ABC, abstractmethod | ||
|
||
from ..interface import DriftEvaluation, DriftEvaluatorContext | ||
|
||
|
||
class AbstractAlertTransport(ABC): | ||
@abstractmethod | ||
def send(self, title: str, drift_evalutation: DriftEvaluation, drift_context: DriftEvaluatorContext) -> None: | ||
pass |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1 @@ | ||
version = "0.1.3-a.10" | ||
version = "0.1.3-a.13" |