def test_dataset_create_import_delete(capsys): name = _id("d_cr_dl") dataset = automl_tables_dataset.create_dataset(PROJECT, REGION, name) assert dataset is not None assert dataset.display_name == name automl_tables_dataset.import_data(PROJECT, REGION, name, GCS_DATASET) out, _ = capsys.readouterr() assert "Data imported." in out automl_tables_dataset.delete_dataset(PROJECT, REGION, name) with pytest.raises(exceptions.NotFound): automl_tables_dataset.get_dataset(PROJECT, REGION, name)
def ensure_dataset_ready(): dataset = None name = STATIC_DATASET try: dataset = automl_tables_dataset.get_dataset(PROJECT, REGION, name) except exceptions.NotFound: dataset = automl_tables_dataset.create_dataset(PROJECT, REGION, name) if dataset.example_count is None or dataset.example_count == 0: automl_tables_dataset.import_data(PROJECT, REGION, name, GCS_DATASET) dataset = automl_tables_dataset.get_dataset(PROJECT, REGION, name) automl_tables_dataset.update_dataset( PROJECT, REGION, dataset.display_name, target_column_spec_name="Deposit", ) return dataset