derrickaw commented on code in PR #35435: URL: https://github.com/apache/beam/pull/35435#discussion_r2167668738
########## sdks/python/apache_beam/yaml/integration_tests.py: ########## @@ -143,6 +174,67 @@ def temp_bigquery_table(project, prefix='yaml_bq_it_'): logging.info("Deleting dataset %s in project %s", dataset_id, project) bigquery_client.client.datasets.Delete(request) +def instance_prefix(instance): + datestr = "".join(filter(str.isdigit, str(datetime.now(timezone.utc).date()))) + instance_id = '%s-%s-%s' % (instance, datestr, secrets.token_hex(4)) + assert len(instance_id) < 34, "instance id length needs to be within [6, 33]" + return instance_id + +@contextlib.contextmanager +def temp_bigtable_table(project, prefix='yaml_bt_it_'): + INSTANCE = "bt-write-tests" + TABLE_ID = "test-table" + # test_pipeline = TestPipeline(is_integration_test=True) + # args = test_pipeline.get_full_options_as_args() + # project = test_pipeline.get_option('project') + + instance_id = (INSTANCE) + + clientT = client.Client(admin=True, project=project) + # create cluster and instance + instanceT = clientT.instance( + instance_id, + display_name=INSTANCE, + instance_type=instance.Instance.Type.DEVELOPMENT) + cluster = instanceT.cluster("test-cluster", "us-central1-a") + operation = instanceT.create(clusters=[cluster]) + operation.result(timeout=500) + _LOGGER.info( + "Created instance [%s] in project [%s]", + instance_id, + project) + + # create table inside instance + table = instanceT.table(TABLE_ID) + table.create() + col_fam = table.column_family('cf1') + col_fam.create() + + + col_fam = table.column_family('cf2') + col_fam.create() + _LOGGER.info("Created table [%s]", table.table_id) + if (os.environ.get('TRANSFORM_SERVICE_PORT')): + _transform_service_address = ( + 'localhost:' + os.environ.get('TRANSFORM_SERVICE_PORT')) + else: + _transform_service_address = None + + yield f'{instance_id}.{project}.tmp_table' + try: + _LOGGER.info("Deleting table [%s]", table.table_id) + table.delete() + instanceT.delete() + except HttpError: + _LOGGER.warning("Failed to clean up instance") + Review Comment: add a few more comments on whats going on since you started the process -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: github-unsubscr...@beam.apache.org For queries about this service, please contact Infrastructure at: us...@infra.apache.org