""" minutes, seconds = self._get_duration() print("Elapsed Time: {} minutes, {} seconds".format(minutes, seconds)) print("Total Matches: {}".format(self._num_matches)) json_samples = self._get_sample_output_as_json() print("Sample Output: {}".format(json_samples)) # pylint: disable=invalid-name if __name__ == "__main__": from frivenmeld.loggingsetup import init_logging # pragma: no cover import time # pragma: no cover init_logging(logging.DEBUG) # pragma: no cover mcollector = MetricsCollector() # pragma: no cover time.sleep(2 * 60 + 15) # pragma: no cover mcollector.add_sample_row(row_dict={ 'cat': 'meow', 'color': 'red' }) # pragma: no cover mcollector.add_sample_row(row_dict={ 'cat': 'shivvers', 'color': 'red' }) # pragma: no cover mcollector.add_sample_row(row_dict={ 'cat': 'tree', 'color': 'black' }) # pragma: no cover
def main(): """ Entry point to program """ arg_object = parse_args() if arg_object.verbose: init_logging(loglevel=logging.DEBUG) else: init_logging(loglevel=logging.INFO) mcollector = MetricsCollector() config = load_config() # Configure the FrivenLoader # api_url = config["FRIENDLY_VENDOR_API_URL"] friven_loader = FrivenLoader(friven_api_url=api_url) friven_loader.init_queue_data_percent(percent=FRIENDLY_WORKING_DATA_PERCENT) friven_loader.set_page_range(first_page_number=arg_object.start_page, last_page_number=arg_object.end_page) # Configure the MysqlLoader # mysql_loader = MysqlLoader(host=config["MYSQL_HOST"], port=config["MYSQL_PORT"], database=config["MYSQL_SCHEMA"], username=config["MYSQL_USER"], password=config["MYSQL_PASS"]) mysql_loader.init_queue_data_percent(percent=DOXIMITY_WORKING_DATA_PERCENT) # Configure MysqlWriter # mysql_writer = MysqlWriter(host=config["WRITE_MYSQL_HOST"], port=config["WRITE_MYSQL_PORT"], database=config["WRITE_MYSQL_SCHEMA"], username=config["WRITE_MYSQL_USER"], password=config["WRITE_MYSQL_PASS"]) mysql_writer.set_friendly_vendor_match_table(tablename=config["WRITE_MYSQL_FQ_MATCH_TABLE"]) mysql_writer.init_queue(batchsize=arg_object.output_batchsize) mysql_writer.set_worker_id(worker_id=arg_object.worker_id) if arg_object.delete_existing: mysql_writer.remove_records_for_date(arg_object.report_date) if arg_object.dry_run: mysql_writer.set_dry_run(is_dry_run=arg_object.dry_run) combining_engine = CombiningEngine(metrics_collector=mcollector, report_date=arg_object.report_date, mysql_writer=mysql_writer) # Configure the Melder # melder = Melder(friven_loader=friven_loader, mysql_loader=mysql_loader, combining_engine=combining_engine, friven_timeout=arg_object.timeout, mysql_timeout=arg_object.timeout) # Do the work melder.meld() mysql_writer.run_inserts() # Gather results mcollector.mark_end_time() mcollector.print_summary() # Print the DDL print_ddl() logging.getLogger(APP_LOGNAME).info("Job complete.")
def test_global_init(): """ test static init_logging() """ init_logging(logging.DEBUG)
self._user_queue.put(user) current_page += 1 # usually _page_range_end will be None, # but it is configurable if we want # to process a smaller window of user pages if self._page_range_end and current_page > self._page_range_end: break # pylint: disable=invalid-name if __name__ == "__main__": # Integration Testing from frivenmeld.loggingsetup import init_logging # pragma: no cover init_logging(logging.INFO) # pragma: no cover api_url = os.getenv('FRIENDLY_VENNDOR_API_URL') # pragma: no cover friven_loader = FrivenLoader(friven_api_url=api_url) # pragma: no cover #friven_loader.init_queue(maxsize=20000) # pragma: no cover friven_loader.init_queue_data_percent(percent=10) # pragma: no cover friven_loader.start() # pragma: no cover count = 0 # pragma: no cover while True: # pragma: no cover friven_loader.get_queue().get(timeout=10) # pragma: no cover count += 1 # pragma: no cover if count == 100: # pragma: no cover # simulate early temination friven_loader.stop() # pragma: no cover break # pragma: no cover
""" test_melder.py """ import datetime import queue import logging import pytest # pylint: disable=import-error from frivenmeld.melder import Melder from frivenmeld.combining_engine import CombiningEngine from frivenmeld.loggingsetup import init_logging init_logging(logging.DEBUG) @pytest.fixture() def metrics_collector(): """ Fixture of an instantiaed MetricsCollector object """ class MockMetricsCollector(): """ Mocks MetricsCollector """ def increment_matches(self): """ mimicks real increment_matches() """ pass