def cli(config: LocalConfig, allow_cache: bool, product_name: str, year: int, month: int, day: int, event_log_file: str, verbose: bool): """ Print the recorded summary information for the given product """ init_logging(open(event_log_file, 'a') if event_log_file else None, verbose=verbose) store = _get_store(config, 'setup') dataset_type = store.get_dataset_type(product_name) region_info = RegionInfo.for_product(dataset_type) t = time.time() if allow_cache: summary = store.get_or_update(product_name, year, month, day) else: summary = store.update(product_name, year, month, day) t_end = time.time() echo(f"{summary.dataset_count} ", nl=False) secho(product_name, nl=False, bold=True) echo(f" datasets for ", nl=False) secho(f"{year or 'all'} {month or 'all'} {day or 'all'}", fg='blue') if summary.size_bytes is not None: echo(sizeof_fmt(summary.size_bytes)) echo(f"{round(t_end - t, 2)} seconds") echo() if region_info is not None: echo(region_info.description) print_count_table(summary.region_dataset_counts)
def region_page( product_name: str = None, region_code: str = None, year: int = None, month: int = None, day: int = None, ): product, product_summary, selected_summary = _load_product( product_name, year, month, day) region_info = RegionInfo.for_product(product) if not region_info: abort(404, f"Product {product_name} has no region specification.") datasets = list( _model.STORE.find_datasets_for_region(product_name, region_code, year, month, day, limit=_HARD_SEARCH_LIMIT)) if len(datasets) == 1 and "feelinglucky" in flask.request.args: return flask.redirect( url_for("dataset.dataset_page", id_=datasets[0].id)) if request_wants_json(): return as_rich_json( dict(datasets=[ build_dataset_info(_model.STORE.index, d) for d in datasets ])) return utils.render( "region.html", year=year, month=month, day=day, region_code=region_code, product=product, product_region_info=region_info, # Summary for the whole product product_summary=product_summary, # Summary for the users' currently selected filters. selected_summary=selected_summary, datasets=datasets, result_limit=_HARD_SEARCH_LIMIT, )
def find_examples_of_all_public_urls(index: Index): yield "/" yield "/about" yield "/products.txt" yield "/product-audit/" yield "/product-audit/day-times.txt" for mdt in index.metadata_types.get_all(): name = mdt.name yield f"/metadata-type/{name}" yield f"/metadata-type/{name}.odc-type.yaml" for dt in index.products.get_all(): name = dt.name yield f"/{name}" yield f"/datasets/{name}" yield f"/product/{name}" yield f"/product/{name}.odc-product.yaml" has_datasets = index.datasets.search_eager(product=name, limit=1) if has_datasets: dataset = has_datasets[0] time = dataset.center_time yield f"/{name}/{time:%Y}" yield f"/{name}/{time:%Y/%m}" yield f"/{name}/{time:%Y/%m/%d}" yield f"/datasets/{name}/{time:%Y}" yield f"/datasets/{name}/{time:%Y/%m}" yield f"/datasets/{name}/{time:%Y/%m/%d}" yield f"/api/datasets/{name}" yield f"/api/footprint/{name}/{time:%Y/%m/%d}" region_info = RegionInfo.for_product(dt) if region_info is not None: region_code = region_info.dataset_region_code(dataset) if region_code is not None: yield f"/api/regions/{name}/{time:%Y/%m/%d}" yield f"/region/{name}/{region_code}" yield f"/region/{name}/{region_code}/{time:%Y/%m/%d}" yield f"/dataset/{dataset.id}" yield f"/dataset/{dataset.id}.odc-metadata.yaml"
def overview_page(product_name: str = None, year: int = None, month: int = None, day: int = None): product, product_summary, selected_summary = _load_product( product_name, year, month, day) theme = app.theme_manager.themes[ flask.current_app.config["CUBEDASH_THEME"]] _LOG.debug( "overview.page.theme", theme=flask.current_app.config["CUBEDASH_THEME"], options=theme.options, ) default_zoom = theme.options["startZoom"] default_center = theme.options["startCoords"] return utils.render( "overview.html", year=year, month=month, day=day, # Which data to preload with the page? regions_geojson=_model.get_regions_geojson(product_name, year, month, day), datasets_geojson= None, # _model.get_datasets_geojson(product_name, year, month, day), footprint_geojson=_model.get_footprint_geojson(product_name, year, month, day), product=product, product_region_info=RegionInfo.for_product(product), # Summary for the whole product product_summary=product_summary, # Summary for the users' currently selected filters. selected_summary=selected_summary, # Map defaults default_zoom=default_zoom, default_center=default_center, )
def overview_page( product_name: str = None, year: int = None, month: int = None, day: int = None ): product, product_summary, selected_summary = _load_product( product_name, year, month, day ) return utils.render( "overview.html", year=year, month=month, day=day, # Which data to preload with the page? regions_geojson=_model.get_regions_geojson(product_name, year, month, day), datasets_geojson=None, # _model.get_datasets_geojson(product_name, year, month, day), footprint_geojson=_model.get_footprint_geojson(product_name, year, month, day), product=product, product_region_info=RegionInfo.for_product(product), # Summary for the whole product product_summary=product_summary, # Summary for the users' currently selected filters. selected_summary=selected_summary, )
def get_product_region_info(self, product_name: str) -> RegionInfo: dt = self.get_dataset_type(product_name) return RegionInfo.for_product(dt, self._region_geoms(product_name))
def find_examples_of_all_public_urls(index: Index): yield "/" yield "/arrivals" yield "/arrivals.csv" yield "/products.txt" yield "/metadata-types.txt" yield "/audit/storage" yield "/audit/storage.csv" yield "/audit/product-metadata" yield "/audit/day-query-times.txt" yield "/stac" yield "/stac/collections" yield "/stac/arrivals" yield "/stac/arrivals/items" for mdt in index.metadata_types.get_all(): name = mdt.name yield f"/metadata-types/{name}" yield f"/metadata-types/{name}.odc-type.yaml" for dt in index.products.get_all(): name = dt.name yield f"/{name}" yield f"/datasets/{name}" yield f"/products/{name}" yield f"/products/{name}.odc-product.yaml" yield f"/stac/collections/{name}" yield f"/stac/collections/{name}/items" yield f"/stac/search?collection={name}&limit=1" yield f"/stac/search?collection={name}&limit=1&_full=true" has_datasets = index.datasets.search_eager(product=name, limit=1) if has_datasets: dataset = has_datasets[0] time = dataset.center_time yield f"/products/{name}/extents/{time:%Y}" yield f"/products/{name}/extents/{time:%Y/%m}" yield f"/products/{name}/extents/{time:%Y/%m/%d}" yield f"/products/{name}/datasets/{time:%Y}" yield f"/products/{name}/datasets/{time:%Y/%m}" yield f"/products/{name}/datasets/{time:%Y/%m/%d}" yield f"/api/datasets/{name}" yield f"/api/footprint/{name}/{time:%Y/%m/%d}" region_info = RegionInfo.for_product(dt) if region_info is not None: region_code = region_info.dataset_region_code(dataset) if region_code is not None: yield f"/api/regions/{name}/{time:%Y/%m/%d}" yield f"/region/{name}/{region_code}" yield f"/region/{name}/{region_code}/{time:%Y/%m/%d}" yield f"/dataset/{dataset.id}" yield f"/dataset/{dataset.id}.odc-metadata.yaml" yield f"/stac/collections/{name}/items/{dataset.id}"