Skip to content

Commit

Permalink
rename cin_validator_class to cin_validator
Browse files Browse the repository at this point in the history
  • Loading branch information
tab1tha committed Aug 22, 2023
1 parent b2d9352 commit 3656109
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 15 deletions.
10 changes: 5 additions & 5 deletions cin_validator/__main__.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
import click
import pytest

from cin_validator import cin_validator_class as cin_class
from cin_validator import cin_validator
from cin_validator.ruleset import create_registry


Expand Down Expand Up @@ -72,10 +72,10 @@ def run_all(filename: str, ruleset, select, output):
fulltree = ET.parse(filename)
root = fulltree.getroot()

raw_data = cin_class.convert_data(root)
data_files = cin_class.process_data(raw_data)
raw_data = cin_validator.convert_data(root)
data_files = cin_validator.process_data(raw_data)

validator = cin_class.CinValidator(ruleset, data_files, selected_rules=select)
validator = cin_validator.CinValidator(ruleset, data_files, selected_rules=select)

issue_instances = validator.issue_instances
full_issue_df = validator.full_issue_df
Expand Down Expand Up @@ -170,7 +170,7 @@ def cli_converter(filename: str):
fulltree = ET.parse(filename)
root = fulltree.getroot()

cin_tables_dict = cin_class.convert_data(root)
cin_tables_dict = cin_validator.convert_data(root)
for k, v in cin_tables_dict.items():
# TODO output CSVs as a zip file
filepath = Path(f"output_csvs/{k}.csv")
Expand Down
File renamed without changes.
18 changes: 8 additions & 10 deletions rpc_main.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,11 @@

from prpc_python import RpcApp

from cin_validator import cin_validator_class as cin_class
from cin_validator import cin_validator
from cin_validator.ruleset import create_registry

app = RpcApp("validate_cin")

# TODO add logging to the rest of the files

logger = logging.getLogger(__name__)
handler = logging.FileHandler(
datetime.datetime.now().strftime("lac validator --%d-%m-%Y %H.%M.%S.log")
Expand All @@ -24,7 +22,7 @@


@app.call
def get_rules(ruleset: str = "cin2022_23") -> list[dict]:
def get_rules(ruleset: str = "cin2022_23") -> str:
"""
:param str ruleset: validation ruleset according to year published.
:return rules_df: available rule codes and definitions according to chosen ruleset.
Expand Down Expand Up @@ -55,7 +53,7 @@ def generate_tables(cin_data: dict) -> dict[str, dict]:
filetext = cin_data_file.read().decode("utf-8")
root = ET.fromstring(filetext)

data_files = cin_class.convert_data(root)
data_files = cin_validator.convert_data(root)

# make data json-serialisable
cin_data_tables = {
Expand All @@ -80,14 +78,14 @@ def cin_validate(
:return issue_report: issue locations in the data.
:return rule_defs: rule codes and descriptions of the rules that triggers issues in the data.
"""

filetext = cin_data.read().decode("utf-8")
cin_data_file = cin_data["This year"][0]
filetext = cin_data_file.read().decode("utf-8")
root = ET.fromstring(filetext)

# fulltree = ET.parse("fake_data\\fake_CIN_data.xml")
# root = fulltree.getroot()

raw_data = cin_class.convert_data(root)
raw_data = cin_validator.convert_data(root)

# Send string-format data to the frontend.
cin_data_tables = {
Expand All @@ -96,10 +94,10 @@ def cin_validate(
}

# Convert date columns to datetime format to enable comparison in rules.
data_files = cin_class.process_data(raw_data)
data_files = cin_validator.process_data(raw_data)

# run validation
validator = cin_class.CinValidator(
validator = cin_validator.CinValidator(
ruleset, data_files, selected_rules=selected_rules
)

Expand Down

0 comments on commit 3656109

Please sign in to comment.