Skip to content

Commit

Permalink
Print CLI output as JSON
Browse files Browse the repository at this point in the history
  • Loading branch information
hkeeler committed Oct 16, 2023
1 parent bd8f3c0 commit d044b60
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 7 deletions.
8 changes: 4 additions & 4 deletions regtech_data_validator/checks.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,16 +2,16 @@
Subclasses of Pandera's `Check` class
"""

from enum import Enum, auto
from enum import StrEnum
from typing import Any, Callable, Type

from pandera import Check
from pandera.backends.base import BaseCheckBackend
from pandera.backends.pandas.checks import PandasCheckBackend

class Severity(Enum):
ERROR = auto()
WARNING = auto()
class Severity(StrEnum):
ERROR = 'error'
WARNING = 'warning'

class SBLCheck(Check):
"""
Expand Down
13 changes: 10 additions & 3 deletions regtech_data_validator/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,11 @@
Run from the terminal to see the generated output.
"""

import pprint
import json
import sys

import pandas as pd

from regtech_data_validator.create_schemas import validate_phases


Expand All @@ -22,10 +23,13 @@ def run_validation_on_df(df: pd.DataFrame, lei: str|None) -> None:
the terminal.
"""

pprint.pprint(validate_phases(df, lei))
validation_dict = validate_phases(df, lei)
validation_json = json.dumps(validation_dict, indent=4)

print(validation_json)

if __name__ == "__main__":

def main():
csv_path = None
lei: str|None = None
if len(sys.argv) == 1:
Expand All @@ -40,3 +44,6 @@ def run_validation_on_df(df: pd.DataFrame, lei: str|None) -> None:

df = csv_to_df(csv_path)
run_validation_on_df(df, lei)

if __name__ == "__main__":
main()

0 comments on commit d044b60

Please sign in to comment.