Skip to content

Commit

Permalink
feat: optional row count validation (#340)
Browse files Browse the repository at this point in the history
  • Loading branch information
ralphrass authored Aug 18, 2023
1 parent 6b78a50 commit 2a19009
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 8 deletions.
17 changes: 9 additions & 8 deletions butterfree/load/sink.py
Original file line number Diff line number Diff line change
Expand Up @@ -69,14 +69,15 @@ def validate(
"""
failures = []
for writer in self.writers:
try:
writer.validate(
feature_set=feature_set,
dataframe=dataframe,
spark_client=spark_client,
)
except AssertionError as e:
failures.append(e)
if writer.row_count_validation:
try:
writer.validate(
feature_set=feature_set,
dataframe=dataframe,
spark_client=spark_client,
)
except AssertionError as e:
failures.append(e)

if failures:
raise RuntimeError(
Expand Down
2 changes: 2 additions & 0 deletions butterfree/load/writers/writer.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,13 +26,15 @@ def __init__(
debug_mode: bool = False,
interval_mode: bool = False,
write_to_entity: bool = False,
row_count_validation: bool = True,
) -> None:
super().__init__()
self.db_config = db_config
self.transformations: List[Dict[str, Any]] = []
self.debug_mode = debug_mode
self.interval_mode = interval_mode
self.write_to_entity = write_to_entity
self.row_count_validation = row_count_validation

def with_(
self, transformer: Callable[..., DataFrame], *args: Any, **kwargs: Any
Expand Down

1 comment on commit 2a19009

@chip-n-dale
Copy link

@chip-n-dale chip-n-dale bot commented on 2a19009 Aug 18, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hi @ralphrass!

The GitLeaks SecTool reported some possibly exposed credentials/secrets, how about giving them a look?

GitLeaks Alert Sync
[
  {
    "line": "    webhook: REDACTED",
    "lineNumber": 141,
    "offender": "REDACTED",
    "offenderEntropy": -1,
    "commit": "b6a5daf28abc035f74b9685aab573d384680b9d1",
    "repo": "butterfree",
    "repoURL": "",
    "leakURL": "",
    "rule": "Slack Webhook",
    "commitMessage": "initial commit\n",
    "author": "Alvaro",
    "email": "[email protected]",
    "file": ".drone.yml",
    "date": "2020-01-03T14:21:51-03:00",
    "tags": "key, slack"
  },
  {
    "line": "    webhook: REDACTED",
    "lineNumber": 159,
    "offender": "REDACTED",
    "offenderEntropy": -1,
    "commit": "b6697aa708fec0c5a9e3af0b2713cee6f45ff675",
    "repo": "butterfree",
    "repoURL": "",
    "leakURL": "",
    "rule": "Slack Webhook",
    "commitMessage": "hail to the butterfree\n",
    "author": "Alvaro",
    "email": "[email protected]",
    "file": ".drone.yml",
    "date": "2020-01-03T11:07:44-03:00",
    "tags": "key, slack"
  }
]

In case of false-positives, more information is available on GitLeaks FAQ
If you had any other problem or question during this process, be sure to contact us on the Security space on GChat!

Please sign in to comment.