in dagify/converter/report_generator.py [0:0]
def generate_report(self):
"""Function that generates the json and txt report"""
templates_to_validate = []
# Config_File_Info parameters
config_job_types = []
config_job_types_count = 0
# Source_file_Info parameters
source_files_count = 1
source_file_info = []
job_types_source = []
job_types_source_count = 0
# Get the Job_types from config_file
config_job_types, config_job_types_count = get_jobtypes_andcount(self.config_file)
# Get the Job_types from source xml
if is_directory(self.source_path) is False:
source_file_info.append(self.source_path.split("/")[-1])
job_types_source, job_types_source_count = get_jobtypes_andcount(self.source_path)
# Get templates INFO
with open(self.config_file, encoding="utf-8") as stream:
try:
self.config = yaml.safe_load(stream)
except yaml.YAMLError as exc:
raise exc
for idx, config in enumerate(self.config["config"]["mappings"]):
self.config["config"]["mappings"][idx]["job_type"] = \
self.config["config"]["mappings"][idx]["job_type"].upper()
templates_to_validate.append(self.config["config"]["mappings"][idx]["template_name"])
# Get job related info
job_info = get_job_info(self.source_path)
unconverted_job_name, converted_job_name, \
non_converted_job_percent, converted_job_percent, conv_job_count = \
get_job_statistics(job_info, config_job_types)
# Statistics Info parameters
job_types_converted, job_types_not_converted, converted_percentage, \
non_converted_percentage = \
get_tasktype_statistics(job_types_source, config_job_types)
# Get Manual Intervention Job_Name Info
manual_job_names = filter_jobs_by_parameter_in_child(self.source_path, "CONFIRM")
# Table Info
statistics = [
f"Job Types Converted: {len(job_types_converted)}/{len(job_types_source)}",
f"Percentage of Job Types Converted: {converted_percentage}%",
f"Percentage of Job Types not Converted: {non_converted_percentage}%",
f"Jobs Converted: {conv_job_count}/{len(job_info)}",
f"Percentage of Jobs Converted: {converted_job_percent}%",
f"Percentage of Jobs not Converted: {non_converted_job_percent}%",
]
title = "Job Conversion Details"
columns = ["TASK", "INFO", "COUNT"]
rows = [
["Source File", "\n".join(source_file_info), source_files_count],
["Source File Job Types", "\n".join(job_types_source), job_types_source_count],
["Config File Job Types", "\n".join(config_job_types), config_job_types_count],
["Job Types Converted", "\n".join(job_types_converted), len(job_types_converted)],
["Job Types not Converted", "\n".join(job_types_not_converted) if job_types_not_converted else "-", len(job_types_not_converted)],
["Jobs Converted", "\n".join(converted_job_name) if converted_job_name else "-", len(converted_job_name)],
["Jobs not Converted", "\n".join(unconverted_job_name) if unconverted_job_name else "-", len(unconverted_job_name)],
["Jobs Requiring Manual Approval", "\n".join(manual_job_names) if manual_job_names else "-", len(manual_job_names)],
["Templates Validated", "\n".join(templates_to_validate), len(templates_to_validate)]
]
warning_line = "NOTE: \n \
1. If \"Job Type\" is not defined in the config.yaml, or it does not have a matching template defined, it will be converted into a DUMMYOPERATOR by default\n \
2. \"Jobs Requiring Manual Approval\" - indicates that the job(s) has a CONFIRM PARAMTER defined, implying the workflow should be changed for manual approval for these job(s)"
return title, columns, rows, statistics, warning_line