Esempio n. 1
0
def load_config(args):
    if args.config_file:
        cfg = import_config(fname_config_file=args.config_file)
    elif "CT_INGESTER_CONFIG" in os.environ:
        fname_config_file = os.environ["CT_INGESTER_CONFIG"]
        cfg = import_config(fname_config_file=fname_config_file)
    else:
        msg_fmt = "Configuration file path not defined."
        raise ValueError(msg_fmt)

    return cfg
Esempio n. 2
0
    def setUp(self):
        """Instantiates the DAL and creates the schema."""

        # Load the configuration.
        self.cfg = import_config(
            fname_config_file="/etc/ct-ingester/ct-ingester-test.json", )

        self.dal = DalClinicalTrials(sql_username=self.cfg.sql_username,
                                     sql_password=self.cfg.sql_password,
                                     sql_host=self.cfg.sql_host,
                                     sql_port=self.cfg.sql_port,
                                     sql_db=self.cfg.sql_db)

        self.ingester = IngesterDocumentClinicalTrial(dal=self.dal)

        self.parser = ParserXmlClinicaStudy()

        # Drop any schema remnants and recreate it.
        Base.metadata.drop_all(self.dal.engine)
        Base.metadata.create_all(self.dal.engine)
Esempio n. 3
0
        required=False,
        default=False,
        action="store_true",
    )
    argument_parser.add_argument(
        "--config-file",
        dest="config_file",
        help="configuration file",
        required=True,
    )
    arguments = argument_parser.parse_args()

    if arguments.dry_run:
        logger.info("Performing a dry-run.")

    cfg = import_config(arguments.config_file)

    # Initialize the Sentry agent.
    initialize_sentry(cfg=cfg)

    # Create a new DAL.
    _dal = DalClinicalTrials(
        sql_username=cfg.sql_username,
        sql_password=cfg.sql_password,
        sql_host=cfg.sql_host,
        sql_port=cfg.sql_port,
        sql_db=cfg.sql_db,
    )

    populate(
        dal=_dal,
            google_place_ids = [
                facility.google_place_id for facility in facilities
            ]
            responses = pool.map(_get_place_details, google_place_ids)

            for facility, response in zip(facilities, responses):

                if not response:
                    continue

                iodu_canonical_facility_from_google(
                    dal=dal,
                    google_place_id=facility.google_place_id,
                    google_response=response)


if __name__ == '__main__':
    cfg = import_config("/etc/ct-ingester/ct-ingester-dev.json")

    dal = DalClinicalTrials(
        sql_username=cfg.sql_username,
        sql_password=cfg.sql_password,
        sql_host="192.168.0.12",
        sql_port=cfg.sql_port,
        sql_db=cfg.sql_db,
    )

    retriever = RetrieverGoogleMaps(api_key=api_keys[0])

    populate()