def ls5_dataset_w_children(index, example_ls5_dataset_path, indexed_ls5_scene_products): # type: (Driver, Path, DatasetType) -> Dataset # TODO: We need a higher-level API for indexing paths, rather than reaching inside the cli script datasets = list( dataset_script.load_datasets( [example_ls5_dataset_path], dataset_script.load_rules_from_types(index))) assert len(datasets) == 1 d = index.datasets.add(datasets[0]) return index.datasets.get(d.id, include_sources=True)
def add_dataset(index: Index, dataset_id: uuid.UUID, uri: str): """ Index a dataset from a file uri. A better api should be pushed upstream to core: it currently only has a "scripts" implementation intended for cli use. """ path = uri_to_local_path(uri) for d in dataset_script.load_datasets([path], _get_rules(index)): if d.id == dataset_id: index.datasets.add(d, sources_policy='ensure') break else: raise RuntimeError('Dataset not found at path: %s, %s' % (dataset_id, uri))