Пример #1
0
def summary_store(module_dea_index: Index) -> SummaryStore:
    store = SummaryStore.create(module_dea_index)
    store.drop_all()
    module_dea_index.close()
    store.init()
    _make_all_tables_unlogged(_utils.alchemy_engine(module_dea_index),
                              CUBEDASH_METADATA)
    return store
Пример #2
0
def init_dea(index: Index,
             with_permissions: bool,
             log_header=print_header,
             log=print_):
    """
    Create or update a DEA configured ODC instance.
    """
    log_header(f"ODC init of {index.url}")
    was_created = index.init_db(with_default_types=False,
                                with_permissions=with_permissions)

    if was_created:
        log('Created.')
    else:
        log('Updated.')

    log('Checking indexes/views.')
    index.metadata_types.check_field_indexes(
        allow_table_lock=True,
        rebuild_indexes=False,
        rebuild_views=True,
    )

    log_header('Checking DEA metadata types')
    # Add DEA metadata types, products.
    for _, md_type_def in read_documents(DEA_MD_TYPES):
        md = index.metadata_types.add(
            index.metadata_types.from_doc(md_type_def))
        log(f"{md.name}")

    log_header('Checking DEA products')
    for _, product_def in read_documents(*DEA_PRODUCTS_DIR.glob('*.yaml')):
        product = index.products.add_document(product_def)
        log(f"{product.name}")

    log_header('Checking DEA ingested definitions')

    for path in DEA_INGESTION_DIR.glob('*.yaml'):
        ingest_config = ingest.load_config_from_file(path)

        driver_name = ingest_config['storage']['driver']
        driver = storage_writer_by_name(driver_name)
        if driver is None:
            raise ValueError("No driver found for {}".format(driver_name))

        source_type, output_type = ingest.ensure_output_type(
            index, ingest_config, driver.format, allow_product_changes=True)
        log(f"{output_type.name:<20}\t\t← {source_type.name}")
Пример #3
0
def summary_store(module_dea_index: Index) -> SummaryStore:
    store = SummaryStore.create(module_dea_index)
    store.drop_all()
    module_dea_index.close()
    store.init()
    return store
Пример #4
0
 def index_fixture_instance(request):
     db: PostgresDb = request.getfixturevalue(db_fixture_name)
     return Index(db)
Пример #5
0
def summary_store(module_dea_index: Index) -> SummaryStore:
    SummaryStore.create(module_dea_index, init_schema=False).drop_all()
    module_dea_index.close()
    store = SummaryStore.create(module_dea_index, init_schema=True)
    return store