def __init__(self, schema_name, report_path, compression): """Initialize the report processor. Args: schema_name (str): The name of the customer schema to process into report_path (str): Where the report file lives in the file system compression (CONST): How the report file is compressed. Accepted values: UNCOMPRESSED, GZIP_COMPRESSED """ if compression.upper() not in ALLOWED_COMPRESSIONS: err_msg = f'Compression {compression} is not supported.' raise MasuProcessingError(err_msg) self._schema_name = schema_name self._report_path = report_path self._compression = compression.upper() self._report_name = path.basename(report_path) self._datetime_format = Config.AWS_DATETIME_STR_FORMAT self._batch_size = Config.REPORT_PROCESSING_BATCH_SIZE self.processed_report = ProcessedReport() # Gather database accessors self.report_common_db = ReportingCommonDBAccessor() self.column_map = self.report_common_db.column_map self.report_common_db.close_session() self.report_db = ReportDBAccessor(schema=self._schema_name, column_map=self.column_map) self.report_schema = self.report_db.report_schema self.temp_table = self.report_db.create_temp_table( AWS_CUR_TABLE_MAP['line_item']) self.line_item_columns = None self.hasher = Hasher(hash_function='sha256') self.hash_columns = self._get_line_item_hash_columns() self.current_bill = self.report_db.get_current_cost_entry_bill() self.existing_cost_entry_map = self.report_db.get_cost_entries() self.existing_product_map = self.report_db.get_products() self.existing_pricing_map = self.report_db.get_pricing() self.existing_reservation_map = self.report_db.get_reservations() LOG.info('Initialized report processor for file: %s and schema: %s', self._report_name, self._schema_name)
def __init__(self, schema_name, report_path, compression, provider_id): """Initialize the report processor base class. Args: schema_name (str): The name of the customer schema to process into report_path (str): Where the report file lives in the file system compression (CONST): How the report file is compressed. Accepted values: UNCOMPRESSED, GZIP_COMPRESSED """ if compression.upper() not in ALLOWED_COMPRESSIONS: err_msg = f'Compression {compression} is not supported.' raise MasuProcessingError(err_msg) self._schema_name = schema_name self._report_path = report_path self._compression = compression.upper() self._provider_id = provider_id