def do_load_programme_data(progid): ''' Load programme data. This populates the canonical model from the exposure files. ''' try: row = flamingo_db_utils.get_transform_file_names_prog(progid) ts = values.get_timestamp() dest_file_path = str(FILES_DIRECTORY) + "/Exposures/" canonicallocfilename = "CanLocProg" + str(progid) + "_" + str( ts) + ".csv" transform_source_to_canonical(progid, row[0], row[1], row[2], dest_file_path, canonicallocfilename) ts = values.get_timestamp() canonicalaccfilename = "CanAccProg" + str(progid) + "_" + str( ts) + ".csv" transform_source_to_canonical(progid, row[3], row[4], row[5], dest_file_path, canonicalaccfilename) flamingo_db_utils.generate_output_transform_file_records_for_prog( progid, canonicallocfilename, canonicalaccfilename) rows = flamingo_db_utils.get_profile_details(progid) schema_filepath = FILES_DIRECTORY + "/Exposures/Schema.ini" with open(schema_filepath, "w") as schema_file: for line in rows: line = re.sub(",", "\t", str(line)) logging.getLogger().debug(re.sub("[()']", "", str(line))) schema_file.write(re.sub("[()']", "", str(line)) + "\n") flamingo_db_utils.generate_canonical_model(progid) except: logging.getLogger().exception("Error in do_load_programme_data") flamingo_db_utils.update_prog_status(progid, "Failed")
def transform_source_to_canonical(progid, sourcefilename, validationfilelocname, transformationfilename, destinationfilepath, destinationfilename): ''' Transform source to canonical. ''' do_sequence = True trasform_status = _do_transform(progid, sourcefilename, validationfilelocname, transformationfilename, destinationfilepath, destinationfilename, do_sequence) if trasform_status is False: flamingo_db_utils.update_prog_status(progid, "Failed")