Przeglądaj źródła

change log functions MigrationCleaning

tsteuer 5 lat temu
rodzic
commit
9d7c25aacc
1 zmienionych plików z 9 dodań i 9 usunięć
  1. 9 9
      cdplib/db_migration/MigrationCleaning.py

+ 9 - 9
cdplib/db_migration/MigrationCleaning.py

@@ -36,7 +36,7 @@ class MigrationCleaning:
                  schema_parser: type = ParseJsonSchema):
         '''
         '''
-        self._log = Log('Migration Cleaning')
+        self.log = Log('Migration Cleaning')
         self._exception_handler = ExceptionsHandler()
 
         assert isinstance(inconsist_report_table, str),\
@@ -141,7 +141,7 @@ class MigrationCleaning:
                     (target_field in target_types) and\
                     (target_types[target_field] != source_types[source_field]):
 
-                self.log_and_raise_error(("Type {0} of field {1} "
+                self.log.log_and_raise_error(("Type {0} of field {1} "
                                     "in schema does not match "
                                     "type {2} of field {3} in "
                                     "migration mapping")
@@ -249,7 +249,7 @@ class MigrationCleaning:
         del data_inconsist
         gc.collect()
 
-        self._log.warning(("Filtering: {0} ."
+        self.log.warning(("Filtering: {0} ."
                            "Filtered {1} rows "
                            "and {2} instances"
                            .format(reason, n_rows_filtered, n_instances_filtered)))
@@ -315,11 +315,11 @@ class MigrationCleaning:
 
             except Exception as e:
 
-                self._exception_handler.log_and_raise_error(("Failed to replace {0} values "
+               self.log.log_and_raise_error(("Failed to replace {0} values "
                                     "in {1}. Exit with error {2}"
                                     .format(default_str, column, e)))
 
-        self._log.info("Replaced {} values".format(default_str))
+        self.log.info("Replaced {} values".format(default_str))
 
         return data
 
@@ -352,7 +352,7 @@ class MigrationCleaning:
 
                 elif (python_type == int) and data[column].isnull().any():
 
-                    self.log_and_raise_error(("Column {} contains missing values "
+                    self.log.log_and_raise_error(("Column {} contains missing values "
                                         "and cannot be of integer type"
                                         .format(column)))
 
@@ -367,7 +367,7 @@ class MigrationCleaning:
 
                 if data[column].dtype != python_type:
 
-                    self._log.warning(("After conversion type in {0} "
+                    self.log.warning(("After conversion type in {0} "
                                        "should be {1} "
                                        "but is still {2}"
                                        .format(column,
@@ -376,11 +376,11 @@ class MigrationCleaning:
 
             except Exception as e:
 
-                self._exception_handler.log_and_raise_error(("Failed to convert types in {0}. "
+                self.log.log_and_raise_error(("Failed to convert types in {0}. "
                                     "Exit with error {1}"
                                     .format(column, e)))
 
-        self._log.info("Converted dtypes")
+        self.log.info("Converted dtypes")
 
         return data