def METHOD_NAME(sm: SMInstance, my_ds_id):
    old_ds = sm.dataset(id=my_ds_id)
    new_name = 'foo' if old_ds.name != 'foo' else 'bar'
    metadata = deepcopy(old_ds.metadata)
    metadata['Sample_Information']['Organism'] = new_name
    sm.update_dataset(id=my_ds_id, name=new_name, metadata=metadata)
    # Wait for reindexing, as dataset updates are async
    attempts = 0
    while sm.dataset(id=my_ds_id).name != new_name and attempts < 10:
        time.sleep(1)
        attempts += 1
    assert sm.dataset(id=my_ds_id).name == new_name